Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!bbn!jr@bbn.com From: jr@bbn.com (John Robinson) Newsgroups: comp.emacs Subject: Re: switch-to-buffer NORECORD Message-ID: <35959@bbn.COM> Date: 13 Feb 89 22:18:39 GMT References: <6314@phoenix.Princeton.EDU> <35945@bbn.COM> Sender: news@bbn.COM Reply-To: jr@bbn.com (John Robinson) Organization: BBN Systems and Technologies Corporation, Cambridge MA Lines: 42 In-reply-to: jr@bbn.com (John Robinson) In article <35945@bbn.COM>, jr@bbn (John Robinson) [that's me!] writes: >In article <6314@phoenix.Princeton.EDU>, eliot@phoenix (Eliot Handelman) writes: >>If I'm bapping around between two files that I'm editing and a lisp >>process, I want the default value sent to switch-to-buffer to be >>the last file visited, not the *lisp* buffer. It turns out that >>switch to buffer has a second optional value, called NORECORD, which >>should do what I want. Now if only I could figure out how to use it. Stephen Gildea (gildea@bbn.com) wrote this function to replicate some zwei (Symbolics lisp machine Zmacs edition of emacs) functionality: (defun switch-to-previous-buffer (n) "Switch to Nth previously selected buffer. N defaults to 2, which switches to the most recently selected buffer. If N is 1, repeated calls will cycle through all buffers, otherwise the first N buffers on the buffer list are rotated." (interactive "P") (if (not n) (setq n 2) (setq n (prefix-numeric-value n))) (if (= n 1) (progn (bury-buffer (current-buffer)) (setq n 2))) (let ((buffer-list (buffer-list))) (while (and (> n 1) buffer-list) (setq n (1- n)) (setq buffer-list (cdr buffer-list)) (while (eq (elt (buffer-name (car buffer-list)) 0) ? ) (setq buffer-list (cdr buffer-list)))) (if buffer-list (switch-to-buffer (car buffer-list)) (error "There aren't that many buffers")))) Suggested binding: (global-set-key "\e\C-l" 'switch-to-previous-buffer) Then, saying M-1 M-C-l at your *lisp* will have the desired effect. -- /jr jr@bbn.com or bbn!jr