summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2008-03-29 22:56:17 +0000
committerJuri Linkov <juri@jurta.org>2008-03-29 22:56:17 +0000
commit7f914bbedf4cd61710ec40cba163a5364890b55f (patch)
tree65039e7f6cb6f3bb2c6fd4187bb540923b119914 /lisp/simple.el
parent4a5e18325acc15d065ccff1a70552161cfd6c7b2 (diff)
downloademacs-7f914bbedf4cd61710ec40cba163a5364890b55f.tar.gz
(minibuffer-default-add-function): New variable with
the default to minibuffer-default-add-completions. (minibuffer-default-add-done): New variable. Make it buffer-local. (minibuffer-default-add-completions): New function. (goto-history-element): Set minibuffer-default-add-done to t and call a function in minibuffer-default-add-function when the specified absolute history position is greater than the length of the minibuffer-default list and minibuffer-default-add-done is nil. Change "^End of history; no next item$" to "^End of defaults; no next item$".
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el41
1 files changed, 40 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 8b9ab8c0622..f7abd7260a6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1304,10 +1304,49 @@ makes the search case-sensitive."
(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 add more elements to the list `minibuffer-default'
+when `goto-history-element' reaches the end of this list.
+Before calling this function `goto-history-element' sets the variable
+`minibuffer-default-add-done' to t, so it will call this function only
+once. In special cases, when this function needs to be called more
+than once, it can set `minibuffer-default-add-done' to nil explicitly,
+overriding the setting of this variable to t in `goto-history-element'.")
+
+(defvar minibuffer-default-add-done nil
+ "When nil, add more elements to the end of the list of default values.
+The value nil causes `goto-history-element' to add more elements to
+the list of defaults when it reaches the end of this list. It does
+this by calling a function defined by `minibuffer-default-add-function'.")
+
+(make-variable-buffer-local 'minibuffer-default-add-done)
+
+(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 just after the default value."
+ (interactive)
+ (let ((def minibuffer-default)
+ (all (all-completions ""
+ minibuffer-completion-table
+ minibuffer-completion-predicate
+ t)))
+ (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 (not minibuffer-default-add-done)
+ (functionp minibuffer-default-add-function)
+ (< nabs (- (if (listp minibuffer-default)
+ (length minibuffer-default)
+ 1))))
+ (setq minibuffer-default-add-done t
+ minibuffer-default (funcall minibuffer-default-add-function)))
(let ((minimum (if minibuffer-default
(- (if (listp minibuffer-default)
(length minibuffer-default)
@@ -1320,7 +1359,7 @@ The argument NABS specifies the absolute history position."
(minibuffer-contents-no-properties)))
(if (< nabs minimum)
(if minibuffer-default
- (error "End of history; no next item")
+ (error "End of defaults; no next item")
(error "End of history; no default available")))
(if (> nabs (length (symbol-value minibuffer-history-variable)))
(error "Beginning of history; no preceding item"))