aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-05-01 15:30:57 -0400
committerStefan Monnier2021-05-01 15:30:57 -0400
commit0ce2f591ff9acd8cfb0944d0de95723e7db0d6f0 (patch)
tree68e39f8875d8ba88e806e78e21cc7ab70510d539
parent6b2d017ead856c244a0b5c5a162254094877bc54 (diff)
downloademacs-0ce2f591ff9acd8cfb0944d0de95723e7db0d6f0.tar.gz
emacs-0ce2f591ff9acd8cfb0944d0de95723e7db0d6f0.zip
* lisp/minibuffer.el (completing-read-default): Fix bug#45474
Set `minibuffer-completion-*` variables buffer-locally instead of using a global let-binding. This should also help make completion work correctly when multiple minibuffers are simultaneously active.
-rw-r--r--doc/lispref/minibuf.texi6
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/minibuffer.el21
3 files changed, 20 insertions, 12 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index bc8868b58d2..145eee8f060 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -1188,9 +1188,9 @@ in the minibuffer to do completion.
1188@defvar minibuffer-completion-table 1188@defvar minibuffer-completion-table
1189The value of this variable is the completion table (@pxref{Basic 1189The value of this variable is the completion table (@pxref{Basic
1190Completion}) used for completion in the minibuffer. This is the 1190Completion}) used for completion in the minibuffer. This is the
1191global variable that contains what @code{completing-read} passes to 1191buffer-local variable that contains what @code{completing-read} passes to
1192@code{try-completion}. It is used by minibuffer completion commands 1192@code{try-completion}. It is used by minibuffer completion commands
1193such as @code{minibuffer-complete-word}. 1193such as @code{minibuffer-complete}.
1194@end defvar 1194@end defvar
1195 1195
1196@defvar minibuffer-completion-predicate 1196@defvar minibuffer-completion-predicate
@@ -1201,7 +1201,7 @@ minibuffer completion functions.
1201 1201
1202@defvar minibuffer-completion-confirm 1202@defvar minibuffer-completion-confirm
1203This variable determines whether Emacs asks for confirmation before 1203This variable determines whether Emacs asks for confirmation before
1204exiting the minibuffer; @code{completing-read} binds this variable, 1204exiting the minibuffer; @code{completing-read} sets this variable,
1205and the function @code{minibuffer-complete-and-exit} checks the value 1205and the function @code{minibuffer-complete-and-exit} checks the value
1206before exiting. If the value is @code{nil}, confirmation is not 1206before exiting. If the value is @code{nil}, confirmation is not
1207required. If the value is @code{confirm}, the user may exit with an 1207required. If the value is @code{confirm}, the user may exit with an
diff --git a/etc/NEWS b/etc/NEWS
index 9bf232ac028..4b5f20db58a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2450,6 +2450,11 @@ This is to keep the same behavior as Eshell.
2450* Incompatible Lisp Changes in Emacs 28.1 2450* Incompatible Lisp Changes in Emacs 28.1
2451 2451
2452+++ 2452+++
2453** 'completing-read-default' sets completion variables buffer-locally.
2454'minibuffer-completion-table' and related variables are now set buffer-locally
2455in the minibuffer instead of being set via a global let-binding.
2456
2457+++
2453** The use of positional arguments in 'define-minor-mode' is obsolete. 2458** The use of positional arguments in 'define-minor-mode' is obsolete.
2454These were actually rendered obsolete in Emacs-21 but were never 2459These were actually rendered obsolete in Emacs-21 but were never
2455marked as such. 2460marked as such.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 24006249530..caf06ec7104 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3900,13 +3900,7 @@ See `completing-read' for the meaning of the arguments."
3900 ;; `read-from-minibuffer' uses 1-based index. 3900 ;; `read-from-minibuffer' uses 1-based index.
3901 (1+ (cdr initial-input))))) 3901 (1+ (cdr initial-input)))))
3902 3902
3903 (let* ((minibuffer-completion-table collection) 3903 (let* ((base-keymap (if require-match
3904 (minibuffer-completion-predicate predicate)
3905 ;; FIXME: Remove/rename this var, see the next one.
3906 (minibuffer-completion-confirm (unless (eq require-match t)
3907 require-match))
3908 (minibuffer--require-match require-match)
3909 (base-keymap (if require-match
3910 minibuffer-local-must-match-map 3904 minibuffer-local-must-match-map
3911 minibuffer-local-completion-map)) 3905 minibuffer-local-completion-map))
3912 (keymap (if (memq minibuffer-completing-file-name '(nil lambda)) 3906 (keymap (if (memq minibuffer-completing-file-name '(nil lambda))
@@ -3919,8 +3913,17 @@ See `completing-read' for the meaning of the arguments."
3919 ;; in minibuffer-local-filename-completion-map can 3913 ;; in minibuffer-local-filename-completion-map can
3920 ;; override bindings in base-keymap. 3914 ;; override bindings in base-keymap.
3921 base-keymap))) 3915 base-keymap)))
3922 (result (read-from-minibuffer prompt initial-input keymap 3916 (result
3923 nil hist def inherit-input-method))) 3917 (minibuffer-with-setup-hook
3918 (lambda ()
3919 (setq-local minibuffer-completion-table collection)
3920 (setq-local minibuffer-completion-predicate predicate)
3921 ;; FIXME: Remove/rename this var, see the next one.
3922 (setq-local minibuffer-completion-confirm
3923 (unless (eq require-match t) require-match))
3924 (setq-local minibuffer--require-match require-match))
3925 (read-from-minibuffer prompt initial-input keymap
3926 nil hist def inherit-input-method))))
3924 (when (and (equal result "") def) 3927 (when (and (equal result "") def)
3925 (setq result (if (consp def) (car def) def))) 3928 (setq result (if (consp def) (car def) def)))
3926 result)) 3929 result))