From: "Thomas" <totohero@empal.com>
Subject: Re: vim's jumplist equivalent in emacs?
Date: 11 Dec 2006 21:54:23 -0800 [thread overview]
Message-ID: <1165902863.411164.54180@l12g2000cwl.googlegroups.com> (raw)
In-Reply-To: lnbqmfpqvq.fsf@mfk.tu-dresden.de
Thank you all for the answers about using marks.
But I thought they lack jumping forward and I decided to start my first
emacs lisp code as follows. (I mapped C-p, C-o, C-l to the functions) I
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?
(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)))
(defun get-current-place ()
"Return (current-buffer current-point)"
(interactive)
(cons (current-buffer) (point)))
(defun push-current-place ()
"Push current-place to backward-jump-list and clear
forward-jump-list"
(interactive)
(setq forward-jump-list nil)
(push-place-uniq (get-current-place) backward-jump-list))
(defun backward-jump ()
"Move to the place at the head of backward-jump-list."
"Pop it from backward-jump-list and push it to forward-jump-list"
(interactive)
(cond
(backward-jump-list
(push-place-uniq (get-current-place) forward-jump-list)
(setq next-place (pop backward-jump-list))
(cond ((equal next-place (get-current-place))
(setq next-place (pop backward-jump-list))))
(setq current-buffer (car next-place))
(setq current-point (cdr next-place))
(switch-to-buffer current-buffer)
(goto-char current-point)
(push-place-uniq next-place forward-jump-list))))
(defun forward-jump ()
"Move to the place at the head of forward-jump-list."
"Pop it from forward-jump-list and push it to backward-jump-list"
(interactive)
(cond
(forward-jump-list
(push-place-uniq (get-current-place) backward-jump-list)
(setq next-place (pop forward-jump-list))
(cond ((equal next-place (get-current-place))
(setq next-place (pop forward-jump-list))))
(setq current-buffer (car next-place))
(setq current-point (cdr next-place))
(switch-to-buffer current-buffer)
(goto-char current-point)
(push-place-uniq next-place backward-jump-list))))
(global-set-key "\C-p" 'push-current-place)
(global-set-key "\C-o" 'backward-jump)
(global-set-key "\C-l" 'forward-jump)
Holger Sparr 작성:
> On Thu, 07 Dec 2006, "Robert Thorpe" <rthorpe@realworldtech.com> wrote:
>
> > Emacs has no jump list unfortunately. Almost every operation will set
> > the mark though, as Mathias said.
> >
> > If you do a search you can get back to where you were using C-u C-spc.
> > There are other useful operations. If you find a tag with M-. then C-u
> > C-spc will return you to where you were. Though in Emacs C-u C-spc
> > will not return you to where you were when opening a file.
>
> You could push the mark before opening another file (advice the opening
> function) and use the global-mark-ring with C-x C-SPC to jump back.
>
> Holger
>
> --
next prev parent reply other threads:[~2006-12-12 5:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-07 8:46 vim's jumplist equivalent in emacs? Thomas
2006-12-07 10:57 ` Mathias Dahl
2006-12-07 13:02 ` Robert Thorpe
2006-12-07 17:17 ` Holger Sparr
2006-12-12 5:43 ` totohero
2006-12-12 7:58 ` Holger Sparr
2006-12-12 5:54 ` Thomas [this message]
2006-12-12 7:41 ` Thomas
2006-12-12 18:43 ` Robert Thorpe
2006-12-13 0:50 ` Thomas
2006-12-13 1:15 ` Thomas
2006-12-17 2:17 ` Drew Adams
2006-12-13 8:29 ` Holger Sparr
2006-12-07 17:07 ` Holger Sparr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1165902863.411164.54180@l12g2000cwl.googlegroups.com \
--to=totohero@empal.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).