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: Christian Dietrich
Subject: Re: easy-to-use bookmarks functionality
Date: Tue, 04 May 2010 15:42:52 -0000
User-agent: slrn/pre0.9.9-111 (Linux)

alex_sv <avshabanov@gmail.com> schrieb:
> 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 just used the given function to implement a switch position, which
uses register 9 to save the last position in in. With H-x, i jump to
register 9 and save the last position in it. So i can jump fore and
backwards.

(loop for key-index from 1 to 9 do
      (let ((key-str (int-to-string key-index)))
        ;; save point
        (global-set-key
         ;; retrieve C-{index} keyboard sequence
         (read-kbd-macro (concat "H-s " (int-to-string key-index)))
         ;; handler form
         `(lambda ()
            (interactive)
            (point-to-register 9)
            (point-to-register ,key-index)
            (message (concat "setting bookmark #" ,key-str))))
        ;; goto saved point
        (global-set-key
         ;; retrieve M-{index} keyboard sequence
         (read-kbd-macro (concat "H-l " (int-to-string key-index)))
         ;; handler form
         `(lambda () (interactive) 
            (point-to-register 9)
            (register-to-point ,key-index)))))

(global-set-key 
 (kbd "H-x")
 '(lambda () (interactive)
    "Switch point with position in register 9"
    (let ((marker (point-marker)))
      (jump-to-register 9)
      (setcdr (assoc 9 register-alist) marker))))

greetz didi


reply via email to

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