reiner@slithy-tove.shs.ohio-state.edu (Reiner Wilhelms) (08/08/90)
If I call emacs with, say, 5 file names: %emacs f1 f2 f3 f4 f5 and then list the buffers via 'list-buffers (C-x C-b), I get a list of buffers which shows f5 first, and f1 last. f5 is the buffer on top. If I type 'switch-to-buffer RET (which is C-x b, followed by return) it will switch to buffer f4. If I repeat this switching, it switches to buffer f5 again, not to buffer f3. Of course, I could always type in the buffer name instead of just hitting return, but that's too much work. Rather, I'd like it to switch circularly through the whole list: f5->f4->f3->f2->f1->f5->... I wonder if this feature is not built in. Does someone know how to program it as key binding, e.g. via key board macro definition? This is the version of our emacs: GNU Emacs 18.55.8 of Fri Dec 8 1989 on jabberwock (berkeley-unix) Thanks in advance for any hints - Reiner
choo@cs.yale.edu (young-il choo) (08/08/90)
In article <236@jabberwock.shs.ohio-state.edu> reiner@slithy-tove.shs.ohio-state.edu (Reiner Wilhelms) writes: > If I call emacs with, say, 5 file names: > %emacs f1 f2 f3 f4 f5 > ... > Rather, I'd like it to switch circularly through the whole list: > f5->f4->f3->f2->f1->f5->... > I wonder if this feature is not built in. > Does someone know how to program it as key binding, e.g. > via key board macro definition? > Thanks in advance for any hints > - Reiner Put the following in your .emacs: (global-set-key "\C-x\C-p" 'bury-buffer) (global-set-key "\C-x\C-n" 'yic-next-buffer) (global-set-key "\C-x\C-o" 'yic-other-buffer) (global-set-key "\C-x\C-k" 'yic-kill-current-buffer) (defun yic-next-buffer () "Switch to previous buffer in current window." (interactive) (switch-to-buffer (car (reverse (buffer-list))))) (defun yic-other-buffer () "Switch to the other buffer (2nd in list-buffer) in current window." (interactive) (switch-to-buffer (other-buffer))) (defun yic-kill-current-buffer () "Kill current buffer." (interactive) (kill-buffer (current-buffer))) ;; end Note: 'bury-buffer is the primitive that cycles through the buffers in one direction (while ignoring insignificant buffers) 'yic-next-buffer is a simple function to cycle through the other way. It even displays buffers that are usually ignored, since I don't bother to check them. 'yic-other-buffer changes to the default other buffer, without waiting for a RET 'yic-kill-current-buffer kills current buffer. I use these all the time to move back and forth between buffers, and also the ability to kill buffers easily is great when I am in dired-mode. Hope this helps. -- Young-il Choo Yale Computer Science New Haven CT 06520-2158 choo-young-il@yale.edu
acevedo@navigator.bloom-beacon (Gabriel) (08/08/90)
>Rather, I'd like it to switch circularly through the whole list: >f5->f4->f3->f2->f1->f5->... >I wonder if this feature is not built in. >Does someone know how to program it as key binding, e.g. >via key board macro definition? The function `bury-buffer' makes the current buffer the last buffer in the buffer list. So if you bind a key to `bury-buffer' this will have the effect you want. If you also want to visit buffers in the reverse direction from `bury-buffer', this little function may be of use: (defun raise-buffer () (interactive) (let ((buffer-list (nreverse (buffer-list))) buffer) (while (string-match "\\` " (buffer-name (prog1 (setq buffer (car buffer-list)) (setq buffer-list (cdr buffer-list)))))) (switch-to-buffer buffer))) It takes the last buffer in the buffer list, and makes it the current buffer. (The little while loop is so that you don't select a buffer whose name starts with a space; those buffers are not meant to be selected. E.g., the name of the minibuffer is " *Minibuf-0*".) Raul -- Raul