emacs-devel
[Top][All Lists]
Advanced

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

Re: C-r and C-s in minibuffer should search completion


From: Juri Linkov
Subject: Re: C-r and C-s in minibuffer should search completion
Date: Sun, 30 Mar 2008 21:32:19 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

>> However, there is one problem now: `C-x b M-n M-n' puts in the minibuffer
>> the name of the current buffer because the current buffer is in the front
>> of the buffer list acquired from the completion table in read-buffer.
>
> This is a very minor problem.

This is a usability problem for users who will prefer using `C-x b M-n M-n'
to switch buffers by recency.  And the current buffer will be annoying
in this list.

>> But it makes no sense to switch to the current buffer, so the case 'B'
>
> Then switch-to-buffer should use a completion predicate that rules out
> the current-buffer.  And the history functions should pay attention to it.

The completion list still should contain the current buffer for other
commands that read a buffer name and whose semantics may require
the presence of the current buffer in the completion list.

Since removing the current buffer from the list of defaults is necessary
only for three commands `C-x b', `C-x 4 b' and `C-x 5 b', I propose just
to check for their names before removing the current buffer from the list:

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.913
diff -c -r1.913 simple.el
*** lisp/simple.el      29 Mar 2008 22:56:17 -0000      1.913
--- lisp/simple.el      30 Mar 2008 18:32:11 -0000
***************
*** 1304,1309 ****
--- 1305,1318 ----
  
  (defvar minibuffer-temporary-goal-position nil)
  
+ (defvar minibuffer-original-command nil
+   "Name of the command that invoked this minibuffer.")
+ 
+ (add-hook 'minibuffer-setup-hook 'minibuffer-initialize)
+ 
+ (defun minibuffer-initialize ()
+   (set (make-local-variable 'minibuffer-original-command) this-command))
+ 
  (defvar minibuffer-default-add-function 'minibuffer-default-add-completions
    "Function run by `goto-history-element' before consuming 
`minibuffer-default'.
  This is useful to dynamically add more elements to the list 
`minibuffer-default'
***************
*** 1332,1337 ****
--- 1341,1354 ----
                              minibuffer-completion-table
                              minibuffer-completion-predicate
                              t)))
+ 
+     ;; Remove the current buffer from the list of buffer completions
+     (when (member minibuffer-original-command
+                 '(switch-to-buffer
+                   switch-to-buffer-other-window
+                   switch-to-buffer-other-frame))
+       (setq all (cdr all)))
+ 
      (if (listp def)
        (append def all)
        (cons def (delete def all)))))

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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