diff options
| author | Stefan Monnier | 2021-05-01 15:30:57 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2021-05-01 15:30:57 -0400 |
| commit | 0ce2f591ff9acd8cfb0944d0de95723e7db0d6f0 (patch) | |
| tree | 68e39f8875d8ba88e806e78e21cc7ab70510d539 | |
| parent | 6b2d017ead856c244a0b5c5a162254094877bc54 (diff) | |
| download | emacs-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.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 21 |
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 |
| 1189 | The value of this variable is the completion table (@pxref{Basic | 1189 | The value of this variable is the completion table (@pxref{Basic |
| 1190 | Completion}) used for completion in the minibuffer. This is the | 1190 | Completion}) used for completion in the minibuffer. This is the |
| 1191 | global variable that contains what @code{completing-read} passes to | 1191 | buffer-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 |
| 1193 | such as @code{minibuffer-complete-word}. | 1193 | such 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 |
| 1203 | This variable determines whether Emacs asks for confirmation before | 1203 | This variable determines whether Emacs asks for confirmation before |
| 1204 | exiting the minibuffer; @code{completing-read} binds this variable, | 1204 | exiting the minibuffer; @code{completing-read} sets this variable, |
| 1205 | and the function @code{minibuffer-complete-and-exit} checks the value | 1205 | and the function @code{minibuffer-complete-and-exit} checks the value |
| 1206 | before exiting. If the value is @code{nil}, confirmation is not | 1206 | before exiting. If the value is @code{nil}, confirmation is not |
| 1207 | required. If the value is @code{confirm}, the user may exit with an | 1207 | required. If the value is @code{confirm}, the user may exit with an |
| @@ -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 | ||
| 2455 | in 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. |
| 2454 | These were actually rendered obsolete in Emacs-21 but were never | 2459 | These were actually rendered obsolete in Emacs-21 but were never |
| 2455 | marked as such. | 2460 | marked 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)) |