From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: totohero@gmail.com Newsgroups: gmane.emacs.help Subject: Re: vim's jumplist equivalent in emacs? Date: 11 Dec 2006 21:43:57 -0800 Organization: http://groups.google.com Message-ID: <1165902237.003732.23390@l12g2000cwl.googlegroups.com> References: <1165481183.610837.121580@79g2000cws.googlegroups.com> <1165496555.501169.277080@80g2000cwy.googlegroups.com> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="euc-kr" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1165905640 21714 80.91.229.10 (12 Dec 2006 06:40:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Dec 2006 06:40:40 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 12 07:40:38 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gu1Jd-0001RI-Jy for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Dec 2006 07:40:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gu1Jd-00037p-7E for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Dec 2006 01:40:37 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!l12g2000cwl.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 90 Original-NNTP-Posting-Host: 210.94.41.89 Original-X-Trace: posting.google.com 1165902242 1758 127.0.0.1 (12 Dec 2006 05:44:02 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 12 Dec 2006 05:44:02 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 Gumi_proxy4:8080 (DataReactor/4.0.6) Complaints-To: groups-abuse@google.com Injection-Info: l12g2000cwl.googlegroups.com; posting-host=210.94.41.89; posting-account=zquq9w0AAADWlQ0cf4LF42_nIMxkc7Nx Original-Xref: shelby.stanford.edu gnu.emacs.help:143849 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39452 Archived-At: 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 =C0=DB=BC=BA: > On Thu, 07 Dec 2006, "Robert Thorpe" 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. >=20 > Holger >=20 > --