aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFederico Tedin2019-12-05 10:30:17 +0100
committerLars Ingebrigtsen2019-12-05 10:30:28 +0100
commit3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d (patch)
tree9afa19b840fbef8fc61a3efbc4e148904195596c /lisp
parent9027084793831031926c12d3bdfa132ec6ac4e60 (diff)
downloademacs-3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d.tar.gz
emacs-3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d.zip
Make HIST arg of read-from-minibuffer work with buffer-local vars
* lisp/simple.el (minibuffer-history-values): New function, should be used to access the minibuffer input history variable when the minibuffer might be active. If the variable is buffer-local, the previous buffer's value will be used. (goto-history-element): Use the new function to access the minibuffer history. (minibuffer-history-isearch-wrap): Use the new function to access the minibuffer history. * src/minibuf.c (read_minibuf): Switch to previous buffer temporarily before updating history list (Bug#38317). (read-from-minibuffer): Extend documentation to mention that the result of using the command will be added to the history list by default. * doc/lispref/minibuf.texi (Minibuffer History): Mention the possibility of using a buffer-local variable as history. * etc/NEWS: Announce changes.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 47ce0364d14..5e4cd8f5bc0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2041,7 +2041,7 @@ See also `minibuffer-history-case-insensitive-variables'."
2041 (null minibuffer-text-before-history)) 2041 (null minibuffer-text-before-history))
2042 (setq minibuffer-text-before-history 2042 (setq minibuffer-text-before-history
2043 (minibuffer-contents-no-properties))) 2043 (minibuffer-contents-no-properties)))
2044 (let ((history (symbol-value minibuffer-history-variable)) 2044 (let ((history (minibuffer-history-value))
2045 (case-fold-search 2045 (case-fold-search
2046 (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped 2046 (if (isearch-no-upper-case-p regexp t) ; assume isearch.el is dumped
2047 ;; On some systems, ignore case for file names. 2047 ;; On some systems, ignore case for file names.
@@ -2141,6 +2141,14 @@ the end of the list of defaults just after the default value."
2141 (append def all) 2141 (append def all)
2142 (cons def (delete def all))))) 2142 (cons def (delete def all)))))
2143 2143
2144(defun minibuffer-history-value ()
2145 "Return the value of the minibuffer input history list.
2146If `minibuffer-history-variable' points to a buffer-local variable and
2147the minibuffer is active, return the buffer-local value for the buffer
2148that was current when the minibuffer was activated."
2149 (buffer-local-value minibuffer-history-variable
2150 (window-buffer (minibuffer-selected-window))))
2151
2144(defun goto-history-element (nabs) 2152(defun goto-history-element (nabs)
2145 "Puts element of the minibuffer history in the minibuffer. 2153 "Puts element of the minibuffer history in the minibuffer.
2146The argument NABS specifies the absolute history position in 2154The argument NABS specifies the absolute history position in
@@ -2169,8 +2177,8 @@ negative number -N means the Nth entry of \"future history.\""
2169 (user-error (if minibuffer-default 2177 (user-error (if minibuffer-default
2170 "End of defaults; no next item" 2178 "End of defaults; no next item"
2171 "End of history; no default available"))) 2179 "End of history; no default available")))
2172 (if (> nabs (if (listp (symbol-value minibuffer-history-variable)) 2180 (if (> nabs (if (listp (minibuffer-history-value))
2173 (length (symbol-value minibuffer-history-variable)) 2181 (length (minibuffer-history-value))
2174 0)) 2182 0))
2175 (user-error "Beginning of history; no preceding item")) 2183 (user-error "Beginning of history; no preceding item"))
2176 (unless (memq last-command '(next-history-element 2184 (unless (memq last-command '(next-history-element
@@ -2192,7 +2200,7 @@ negative number -N means the Nth entry of \"future history.\""
2192 (setq minibuffer-returned-to-present t) 2200 (setq minibuffer-returned-to-present t)
2193 (setq minibuffer-text-before-history nil)) 2201 (setq minibuffer-text-before-history nil))
2194 (t (setq elt (nth (1- minibuffer-history-position) 2202 (t (setq elt (nth (1- minibuffer-history-position)
2195 (symbol-value minibuffer-history-variable))))) 2203 (minibuffer-history-value)))))
2196 (insert 2204 (insert
2197 (if (and (eq minibuffer-history-sexp-flag (minibuffer-depth)) 2205 (if (and (eq minibuffer-history-sexp-flag (minibuffer-depth))
2198 (not minibuffer-returned-to-present)) 2206 (not minibuffer-returned-to-present))
@@ -2445,7 +2453,7 @@ or to the last history element for a backward search."
2445 ;; beginning/end of the history, wrap the search to the first/last 2453 ;; beginning/end of the history, wrap the search to the first/last
2446 ;; minibuffer history element. 2454 ;; minibuffer history element.
2447 (if isearch-forward 2455 (if isearch-forward
2448 (goto-history-element (length (symbol-value minibuffer-history-variable))) 2456 (goto-history-element (length (minibuffer-history-value)))
2449 (goto-history-element 0)) 2457 (goto-history-element 0))
2450 (setq isearch-success t) 2458 (setq isearch-success t)
2451 (goto-char (if isearch-forward (minibuffer-prompt-end) (point-max)))) 2459 (goto-char (if isearch-forward (minibuffer-prompt-end) (point-max))))