help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: easy-to-use bookmarks functionality


From: alex_sv
Subject: Re: easy-to-use bookmarks functionality
Date: Tue, 04 May 2010 15:42:36 -0000
User-agent: G2/1.0

On Mar 16, 11:58 pm, José A. Romero L. <escherdra...@gmail.com> wrote:
>...

Great!
I didn't noticed possibility to use read-kbd-macro and back-quote
form.
Thank you!

I slightly modified your function - now it prints message that
bookmark is set, just a copestone:

(defun bind-navigation-commands-to-numkeys ()
  "provides easy-to-use bookmarking functionality - binds navigation
commands to
C-{index}, M-{index} keys, where index is a numeric key from 1 to 9,
C-{index} - saves bookmark, M-{index} - jumps to the saved point"
  ;; assign handlers for C/M-[1..9] keys
  (loop for key-index from 1 to 9 do
       (let ((key-str (int-to-string key-index)))
         ;; save point
         (local-set-key
          ;; retrieve C-{index} keyboard sequence
          (read-kbd-macro (concat "C-" (int-to-string key-index)))
          ;; handler form
          `(lambda ()
             (interactive)
             (point-to-register ,key-index)
             (message (concat "setting bookmark #" ,key-str))))

         ;; goto saved point
         (local-set-key
          ;; retrieve M-{index} keyboard sequence
          (read-kbd-macro (concat "M-" (int-to-string key-index)))
          ;; handler form
          `(lambda () (interactive) (register-to-point ,key-index))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]