wsd@cs.brown.edu (Wm. Scott `Spot' Draves) (03/23/89)
I like using M-p and M-n to skim through gnuemacs' command history. What I'm looking for is some way to do the same thing in the switch-to-buffer command. Specifically, the user types C-x b, and is presented with Switch to Buffer: (default *scratch*) Then the user can either type the name of the buffer, or type return as usual. Or the user can use M-p and M-n to change the default to the next/previous buffer in the buffer list. Is there elisp code or a patch out there that does this? Is there something like this slated for a future version? While am asking about future versions, what's in line for version 19 and is there an estimate of when it will be released? Thanks for any answers/help. Scott - - - - - - - - - - Scott Draves | Space... The Final Frontier wsd@cs.brown.edu | uunet!brunix!wsd wsd@browncs.bitnet Box 2555 Brown U Prov RI 02912
mly@wheaties.ai.mit.edu (Richard Mlynarik) (03/24/89)
I like using M-p and M-n to skim through gnuemacs' command history. What I'm looking for is some way to do the same thing in the switch-to-buffer command. Specifically, the user types C-x b, and is presented with Switch to Buffer: (default *scratch*) [...] (global-set-key "\C-x\C-b" 'electric-buffer-list) isn't exactly what you were asking for, but it may be what you want.
jr@bbn.com (John Robinson) (03/24/89)
In article <WSD.89Mar23004323@cslab1c.cs.brown.edu>, wsd@cs (Wm. Scott `Spot' Draves) writes: >I like using M-p and M-n to skim through gnuemacs' command history. >What I'm looking for is some way to do the same thing in the >switch-to-buffer command. Specifically, the user types C-x b, and is >presented with > >Switch to Buffer: (default *scratch*) > >Then the user can either type the name of the buffer, or type return >as usual. Or the user can use M-p and M-n to change the default to >the next/previous buffer in the buffer list. > >Is there elisp code or a patch out there that does this? Is there >something like this slated for a future version? I know of no such package, but it is a nice idea. The minibuffer completing reader is handed a list of alternatives when it is invoked, which is the buffer list in the case of ^X b. The completing reader has its own keymap, and M-p and M-n could be bound to fns which move around through the provided list. This approach would make it pretty general for any function using the completing reader. The mechanism in simple.el that supports the command-history recall might be a model for how to do this. Anyone got the time for this? -- /jr jr@bbn.com or bbn!jr C'mon big money!
tom@hcx2.SSD.HARRIS.COM (03/30/89)
This is a package that a friend of mine (Bill Leonard) here at Harris wrote. I am posting it instead of him merely because I get in earlier in the morning... We have gotten to where we use this technique for several of the packages we have written where something prompts for input, each command keeps its own history list so you can quickly cycle through the previous input to just that command. It is very handy to rebind the keys where next line is, so you can continue to use any cursor keys. I have the following lines in my .emacs to use this: (autoload 'select-another-buffer "select-buf" nil t) (define-key global-map "\C-x\C-b" 'select-another-buffer) ;; redef default ---cut here------------------------select-buf.el------------------------------ ;; This file provides an interactive buffer-list capability. ;; When the function select-another-buffer is invoked, the minibuffer ;; prompts you for another buffer to select. The default is the second ;; buffer on the buffer-list. Also, all the keys that are normally ;; bound to next-line and previous-line are bound to functions that ;; navigate through the buffer list. Any keys bound to kill-buffer ;; are rebound to a function that will kill the buffer currently ;; named in the minibuffer, then move to the next buffer on the list. ;; This is a faster means of selecting another buffer than buffer-menu ;; is, but with most of the power. (defvar buffer-select-list-index 0 "Index into buffer-list") (defvar buffer-select-local-list nil "Local copy of buffer-list") (defvar buffer-select-minibuffer-map (copy-keymap minibuffer-local-map) "This is a copy of the minibuffer keymap with all the keys that were bound to next-line now bound to buffer-select-next and all the keys that were bound to previous-line now bound to buffer-select-prev.") (mapcar (function (lambda (keyseq) (define-key buffer-select-minibuffer-map keyseq 'buffer-select-prev) ) ) (where-is-internal 'previous-line nil nil) ) (mapcar (function (lambda (keyseq) (define-key buffer-select-minibuffer-map keyseq 'buffer-select-next) ) ) (where-is-internal 'next-line nil nil) ) (mapcar (function (lambda (keyseq) (define-key buffer-select-minibuffer-map keyseq 'buffer-select-killit) ) ) (where-is-internal 'kill-buffer nil nil) ) (defun make-buffer-list (buffl) "Constructs a list of buffers from BUFFL excluding all the buffers whose names begin with space." (if buffl (if (equal (substring (buffer-name (car buffl)) 0 1) " ") (make-buffer-list (cdr buffl)) (cons (car buffl) (make-buffer-list (cdr buffl))) ) buffl ) ) (defun select-another-buffer () "Select another buffer to display in the current window. The minibuffer is used to prompt for the buffer name. The default is the second buffer on the buffer-list; other buffers can be selected either explicitly, or by using buffer-select-next and buffer-select-prev. Keys normally bound to next-line are bound to buffer-select-next and keys normally bound to previous-line are bound to buffer-select-prev." (interactive) (let ( (save-minibuffer-map minibuffer-local-map) inpt ) (setq minibuffer-local-map buffer-select-minibuffer-map) (setq buffer-select-list-index 1) (setq buffer-select-local-list (make-buffer-list (buffer-list))) (setq inpt (unwind-protect (progn (read-input "Select another buffer: " (buffer-name (car (cdr buffer-select-local-list)))) ) (progn (setq minibuffer-local-map save-minibuffer-map) ) ) ) (switch-to-buffer inpt) ) ) (defun buffer-select-next () "Move to the next buffer on the buffer-list." (interactive) (erase-buffer) (setq buffer-select-list-index (1+ buffer-select-list-index)) (if (>= buffer-select-list-index (length buffer-select-local-list)) (setq buffer-select-list-index 0) ) (insert (buffer-name (nth buffer-select-list-index buffer-select-local-list))) ) (defun buffer-select-prev () "Move to the previous buffer on the buffer-list." (interactive) (erase-buffer) (setq buffer-select-list-index (1- buffer-select-list-index)) (if (< buffer-select-list-index 0) (setq buffer-select-list-index (1- (length buffer-select-local-list))) ) (insert (buffer-name (nth buffer-select-list-index buffer-select-local-list))) ) (defun buffer-select-killit () "Kill the buffer currently appearing in the minibuffer, then move to the next buffer on the buffer-list." (interactive) (let ( (mbuf (current-buffer)) ;; Save the minibuffer because ;; kill-buffer selects a buffer (kbuf (nth buffer-select-list-index buffer-select-local-list)) ) (message "Killing buffer %s." (buffer-name kbuf)) (kill-buffer kbuf) (set-buffer mbuf) ) ;; Rebuild the buffer list, so that the killed buffer doesn't appear ;; in it. Under certain circumstances, the buffer might not have ;; gone away, such as killing "*scratch*" when it is the last buffer. (setq buffer-select-local-list (make-buffer-list (buffer-list))) ;; Fix buffer-select-list-index, in case it went off the end of ;; the list (in either direction, just to be absolutely safe). (if (< buffer-select-list-index 0) (setq buffer-select-list-index (1- (length buffer-select-local-list))) ) (if (>= buffer-select-list-index (length buffer-select-local-list)) (setq buffer-select-list-index 0) ) (erase-buffer) (insert (buffer-name (nth buffer-select-list-index buffer-select-local-list))) ) ----------------------cut here---------------------------------------------- ===================================================================== usenet: tahorsley@ssd.harris.com USMail: Tom Horsley compuserve: 76505,364 511 Kingbird Circle genie: T.HORSLEY Delray Beach, FL 33444 ======================== Aging: Just say no! ========================
weiner@novavax.UUCP (Bob Weiner) (03/31/89)
In article <37704@bbn.COM> jr@bbn.com (John Robinson) writes: >I like using M-p and M-n to skim through gnuemacs' command history. >What I'm looking for is some way to do the same thing in the >switch-to-buffer command. jr@bbn.com writes: I know of no such package, but it is a nice idea. The minibuffer completing reader is handed a list of alternatives when it is invoked, which is the buffer list in the case of ^X b. The completing reader has its own keymap, and M-p and M-n could be bound to fns which move around through the provided list. This approach would make it pretty general for any function using the completing reader. The mechanism in simple.el that supports the command-history recall might be a model for how to do this. Anyone got the time for this? You can get around much faster with a knowlege of buffer-menu mode. It works decently in its vanilla flavored distribution form, but even better with some basic modifications that I have saved. With these mods you get almost all the advantages of electric-buffer-menu (buffer menu pops up and restores previous window configuration before displaying selected buffers) but none of the disadvantages (limited command set, can't switch windows). I also have a mouse interface that lets you mark, save, delete, and select buffers in this mode with one mouse button. I will get around to posting this stuff, but it is not easy for me to since I don't have a direct net connection at work. Be patient and you'll see this code and probably a generalization on my 'Info-mouse' package that gives you context sensitive (based on current buffer and location) functionality from one mouse button. Cheers, Bob -- Bob Weiner, Motorola, Inc., USENET: ...!gatech!uflorida!novavax!weiner (407) 738-2087