]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/minibuffer.el (completing-read-default): Fix bug#45474
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 1 May 2021 19:30:57 +0000 (15:30 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 1 May 2021 19:30:57 +0000 (15:30 -0400)
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.

doc/lispref/minibuf.texi
etc/NEWS
lisp/minibuffer.el

index bc8868b58d24178cc8db0686ba4748702bab0a21..145eee8f0609893b39ede2b12bcf300465e3d22c 100644 (file)
@@ -1188,9 +1188,9 @@ in the minibuffer to do completion.
 @defvar minibuffer-completion-table
 The value of this variable is the completion table (@pxref{Basic
 Completion}) used for completion in the minibuffer.  This is the
-global variable that contains what @code{completing-read} passes to
+buffer-local variable that contains what @code{completing-read} passes to
 @code{try-completion}.  It is used by minibuffer completion commands
-such as @code{minibuffer-complete-word}.
+such as @code{minibuffer-complete}.
 @end defvar
 
 @defvar minibuffer-completion-predicate
@@ -1201,7 +1201,7 @@ minibuffer completion functions.
 
 @defvar minibuffer-completion-confirm
 This variable determines whether Emacs asks for confirmation before
-exiting the minibuffer; @code{completing-read} binds this variable,
+exiting the minibuffer; @code{completing-read} sets this variable,
 and the function @code{minibuffer-complete-and-exit} checks the value
 before exiting.  If the value is @code{nil}, confirmation is not
 required.  If the value is @code{confirm}, the user may exit with an
index 9bf232ac028a51cdb71611d5309424bb7c60e95f..4b5f20db58a65e124c15251313bf48c6b538776d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2449,6 +2449,11 @@ This is to keep the same behavior as Eshell.
 \f
 * Incompatible Lisp Changes in Emacs 28.1
 
++++
+** 'completing-read-default' sets completion variables buffer-locally.
+'minibuffer-completion-table' and related variables are now set buffer-locally
+in the minibuffer instead of being set via a global let-binding.
+
 +++
 ** The use of positional arguments in 'define-minor-mode' is obsolete.
 These were actually rendered obsolete in Emacs-21 but were never
index 240062495304b0157e104d937749c7184e5caded..caf06ec71042d52a7a3fa7308cd4a2be5946cae1 100644 (file)
@@ -3900,13 +3900,7 @@ See `completing-read' for the meaning of the arguments."
                 ;; `read-from-minibuffer' uses 1-based index.
                 (1+ (cdr initial-input)))))
 
-  (let* ((minibuffer-completion-table collection)
-         (minibuffer-completion-predicate predicate)
-         ;; FIXME: Remove/rename this var, see the next one.
-         (minibuffer-completion-confirm (unless (eq require-match t)
-                                          require-match))
-         (minibuffer--require-match require-match)
-         (base-keymap (if require-match
+  (let* ((base-keymap (if require-match
                          minibuffer-local-must-match-map
                         minibuffer-local-completion-map))
          (keymap (if (memq minibuffer-completing-file-name '(nil lambda))
@@ -3919,8 +3913,17 @@ See `completing-read' for the meaning of the arguments."
                     ;; in minibuffer-local-filename-completion-map can
                     ;; override bindings in base-keymap.
                     base-keymap)))
-         (result (read-from-minibuffer prompt initial-input keymap
-                                       nil hist def inherit-input-method)))
+         (result
+          (minibuffer-with-setup-hook
+              (lambda ()
+                (setq-local minibuffer-completion-table collection)
+                (setq-local minibuffer-completion-predicate predicate)
+                ;; FIXME: Remove/rename this var, see the next one.
+                (setq-local minibuffer-completion-confirm
+                            (unless (eq require-match t) require-match))
+                (setq-local minibuffer--require-match require-match))
+            (read-from-minibuffer prompt initial-input keymap
+                                  nil hist def inherit-input-method))))
     (when (and (equal result "") def)
       (setq result (if (consp def) (car def) def)))
     result))