[Top][All Lists]

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

Re: vim's jumplist equivalent in emacs?

From: Robert Thorpe
Subject: Re: vim's jumplist equivalent in emacs?
Date: 12 Dec 2006 10:43:43 -0800
User-agent: G2/1.0

Thomas wrote:
> Thank you all for the answers about using marks.
> But I thought they lack jumping forward

How do you "jump forward".  You can't really jump to something you have
not yet visited.

> and I decided to start my first
> emacs lisp code as follows. (I mapped C-p, C-o, C-l to the functions) I

I find I use some of those, such as C-l quite a lot, you might not

Maybe try mapping to places in the Emacs keymap that Emacs does not
map.  For example both C-digit and M-digit produce a prefix argument
corresponding to whatever the digit happens to be.  So C-8 C-p means
move 8 lines previous.  You don't need both, so why not use one of them
for your own personal keys.  Or use the function keys.

> think this code is really ugly and any comments are welcome. And can
> anyone please advice me how to make 'push-place-uniq' automatically
> called every time when I execute some kind of jump actions like
> searching texts, opening a file or searching tags etc?

Jump actions are not treated uniformally in Emacs, except in that they
set mark as we discussed earlier.  What you could do is look in the
mark ring.

> (defvar backward-jump-list nil)
> (defvar forward-jump-list nil)
> (setq backward-jump-list nil)
> (setq forward-jump-list nil)
> (defmacro push-place-uniq (place jump-list)
>   ;; if the place is already at the head of jump-list, ignore it
>   ;; otherwise add it at the head of jump-list
>   (list 'if
>         (list 'equal place (list 'car jump-list))
>         t
>         (list 'push place jump-list)))

You could do that a little more tidily with quasiquotation.  See C-h f

<remaining code snipped>

Nothing in your code screams at me as though it's wrong, but it seems
to replicate the job of the mark rings.

I think I see your problem though.  It seems the behaviour of C-u C-SPC
is quite strange.
Maybe what you may want is something like the cycle function in this

There may be something better though, I'll think about it.

reply via email to

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