[Top][All Lists]
[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: |
Thu, 27 Mar 2008 02:44:08 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
> There seem to be some typo or something missing from your sentence, but
> IIUC you have implemented what I suggested so that M-n only computes the
> completion table after having consumed the normal defaults? Can you
> send the new code?
Yep, this was already implemented in my previous patch. If there exist
a default value, then the first M-n just inserts this default value to
the minibuffer without any computation, and only next M-n (that would
otherwise signal an error) computes the completion table.
Below is a new patch with a small improvement: it introduces a new
variable `minibuffer-default-add-p' useful to add more elements to the
list of defaults several times in chunks when needed (it can keep the
current state of added elements to the list of defaults):
Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.912
diff -c -r1.912 simple.el
*** lisp/simple.el 26 Mar 2008 03:40:40 -0000 1.912
--- lisp/simple.el 27 Mar 2008 00:42:03 -0000
***************
*** 1304,1313 ****
--- 1305,1352 ----
(defvar minibuffer-temporary-goal-position nil)
+ (defvar minibuffer-default-add-function 'minibuffer-default-add-completions
+ "Function run by `goto-history-element' before consuming
`minibuffer-default'.
+ This is useful to dynamically set the value of `minibuffer-default'
+ before `goto-history-element' reads it when it moves into the future.")
+
+ (make-variable-buffer-local 'minibuffer-default-add-function)
+
+ (defvar minibuffer-default-add-p t
+ "When non-nil, add more elements to the end of the list of default values.
+ Any non-nil value causes `goto-history-element' to add more elements
+ to a list of defaults by calling a function defined by
+ `minibuffer-default-add-function'. When this function
+ doesn't need to add more elements after its call, it should
+ set this variable to nil.")
+
+ (make-variable-buffer-local 'minibuffer-default-add-p)
+
+ (defun minibuffer-default-add-completions ()
+ "Return a list of all completions without the default value.
+ This function is used to add all elements of the completion table to
+ the end of the list of defaults after the default value."
+ (interactive)
+ (let ((def minibuffer-default)
+ (all (all-completions ""
+ minibuffer-completion-table
+ minibuffer-completion-predicate
+ t)))
+ (setq minibuffer-default-add-p nil)
+ (if (listp def)
+ (append def all)
+ (cons def (delete def all)))))
+
(defun goto-history-element (nabs)
"Puts element of the minibuffer history in the minibuffer.
The argument NABS specifies the absolute history position."
(interactive "p")
+ (when (and minibuffer-default-add-p
+ (functionp minibuffer-default-add-function)
+ (< nabs (- (if (listp minibuffer-default)
+ (length minibuffer-default)
+ 1))))
+ (setq minibuffer-default (funcall minibuffer-default-add-function)))
(let ((minimum (if minibuffer-default
(- (if (listp minibuffer-default)
(length minibuffer-default)
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: C-r and C-s in minibuffer should search completion, (continued)
RE: C-r and C-s in minibuffer should search completion, Drew Adams, 2008/03/20
Re: C-r and C-s in minibuffer should search completion, Juri Linkov, 2008/03/25
Re: C-r and C-s in minibuffer should search completion, Juri Linkov, 2008/03/26
Re: C-r and C-s in minibuffer should search completion, Stefan Monnier, 2008/03/26
Re: C-r and C-s in minibuffer should search completion,
Juri Linkov <=
Re: C-r and C-s in minibuffer should search completion, Stefan Monnier, 2008/03/26
Re: C-r and C-s in minibuffer should search completion, Juri Linkov, 2008/03/27
Re: C-r and C-s in minibuffer should search completion, Stefan Monnier, 2008/03/29
minibuffer-default-add-shell-commands (was: C-r and C-s in minibuffer should search completion), Juri Linkov, 2008/03/29
Re: minibuffer-default-add-shell-commands, Stefan Monnier, 2008/03/30
Re: minibuffer-default-add-shell-commands, Juri Linkov, 2008/03/30
Re: minibuffer-default-add-shell-commands, Reiner Steib, 2008/03/30
Re: minibuffer-default-add-shell-commands, Juri Linkov, 2008/03/30
Re: minibuffer-default-add-shell-commands, Reiner Steib, 2008/03/30
Re: C-r and C-s in minibuffer should search completion, Juri Linkov, 2008/03/29