[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature suggestion for switch-buffer

From: Roland Winkler
Subject: Re: Feature suggestion for switch-buffer
Date: 28 Jan 2002 10:52:25 +0100

address@hidden (Tom Tromey) writes:

> I have a feature suggestion for switch-buffer.
> Suppose I have two buffers, "foo-one" and "foo-two".
> If I'm looking at foo-one, and type:
>     C-x b foo TAB
> it would be convenient if "foo-two" appeared in the minibuffer.  That
> is, I think it would make sense for switch-buffer to assume that I
> don't want to switch to the buffer I'm currently viewing; the current
> buffer could be removed from the list of completions unless it is the
> last completion item -- "foo-o TAB" should still complete correctly.

I agree it would be neat if this was the default.

On the other hand, it is fairly simple to fix this problem by
yourself. I have the following in my .emacs which gives the desired
behavior to all functions that switch buffers.

(setq read-buffer-function 'read-buffer-different)
(defun read-buffer-different (prompt &optional default require-match)
  "Read buffer with minibuffer completion not including current-buffer."
  (let ((bl (buffer-list))
        (cb (current-buffer))
        buf dbl)
    (while (setq buf (car bl))
      (unless (eq buf cb)
        (setq dbl (cons (list (buffer-name buf)) dbl)))
      (setq bl (cdr bl)))
    (completing-read (if default
                         (concat prompt "(default " default ") ")
                     dbl nil require-match nil 'buffer-name-history default)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]