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 02:38:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

>> Maybe we should avoid this inconsistency by using
>> another key for switch-to-completions?
>
> FWIW, Icicles uses `C-insert' for this. And hitting it again takes you back to
> the minibuffer (and copies the completion at point in *Completions* to the
> minibuffer` for editing). That key won't work for emacs -nw, but `M-insert'
> presumably would (in the form of `ESC insert').

I agree that `M-insert' makes sense for inserting the completion from
the *Completions* buffer to the minibuffer.

> There is little connection between the idea of having `down' and `up' move to
> the next and previous items in a series and the idea of switching
> windows/buffers.

<M-down> and <M-up> are used by many other programs that open a pop-up
list of history/completion items.  So they are natural key for most users
and especially for newbies.

I also suggest using <M-down> for IDE-like autocompletion that opens
a pop-up window with completion in a program buffer.  This is usually
bound to C-SPC in IDE like Eclipse, but C-SPC is already taken for
set-mark-command in Emacs.

> Finally, why use a separate window for history items? Why not simply use
> *Completions* and let users complete against history items? IOW, use the 
> normal
> completion mechanism, with everything that it provides.

As there exists already a key that open the *Completions* buffer,
it makes sense to do the same for the history list.

Below is a patch that implements these ideas.

> That is what I suggested when I mentioned `M-o', which is the key that Icicles
> uses for this. You can use `M-o' from any minibuffer, not just during
> completion. It uses a recursive minibuffer to let you choose from the current
> input history (using completion) - your choice is inserted in the minibuffer,
> where you can edit it for the original minibuffer reading.

You earlier objected to using the same keys that have different
bindings in the minibuffer and outside it (cf. using `TAB' in the
minibuffer).  Since by default M-o is a prefix key for font-lock-fontify
function, I think we should find another key.  One candidate I propose
is C-M-TAB.

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 00:38:48 -0000
***************
*** 5520,5525 ****
--- 5574,5604 ----
        (goto-char (point-min))
        (search-forward "\n\n" nil t)
        (forward-line 1))))
+ 
+ (defun switch-to-history-completions ()
+   "Select the completion list window for elements of the minibuffer history."
+   (interactive)
+   (let ((minibuffer-completion-table
+          (symbol-value minibuffer-history-variable))
+       (minibuffer-completion-predicate nil))
+     (switch-to-completions)))
+ 
+ (define-key minibuffer-local-completion-map [(meta down)] 
'switch-to-completions)
+ (define-key minibuffer-local-completion-map [(meta up)] 
'switch-to-history-completions)
+ 
+ (defun minibuffer-history-complete ()
+   "Complete the minibuffer input against the history list.
+ Locally bind the current value of `minibuffer-history-variable'
+ to the completion table `minibuffer-completion-table' before
+ calling `minibuffer-complete'."
+   (interactive)
+   (let ((minibuffer-completion-table
+          (symbol-value minibuffer-history-variable))
+         (minibuffer-completion-predicate nil))
+     (minibuffer-complete)))
+ 
+ (define-key minibuffer-local-map [(meta control tab)] 
'minibuffer-history-complete)
+ 
  
  ;;; Support keyboard commands to turn on various modifiers.

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




reply via email to

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