emacs-31 9ebc5b9d933: Ensure the correct current buffer in completions--background-update
Juri Linkov <[email protected]> Fri, 10 Jul 2026 11:57:58 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: emacs-31 commit 9ebc5b9d93363b750431167f0bc4524391e5ed19 Author: Juri Linkov <[email protected]> Commit: Juri Linkov <[email protected]> Ensure the correct current buffer in completions--background-update * lisp/minibuffer.el (completions--background-update): Add new arg 'buffer' and compare it with 'current-buffer'. (completions--start-background-update): Run an idle timer for 'completions--background-update' with a new arg set to 'current-buffer' that ensures that the timer function is run in the same buffer (bug#81349). --- lisp/minibuffer.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 5b1486d2af4..f16001dc1d0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2764,22 +2764,24 @@ is always true." (defvar completions--background-update-timer nil) -(defun completions--background-update (force-eager-update) +(defun completions--background-update (force-eager-update buffer) "Try to update *Completions* without blocking input. This function uses `while-no-input' and sets `non-essential' to t so that the update is less likely to interfere with user typing." (setq completions--background-update-timer nil) - (when (while-no-input - (let ((non-essential t)) - (redisplay) - (cond - (completion-in-region-mode (completion-help-at-point t)) - ((completions--should-show-p - (completion--field-metadata (minibuffer-prompt-end)) - force-eager-update) - (minibuffer-completion-help)))) - nil) + (when (and + (eq buffer (current-buffer)) + (while-no-input + (let ((non-essential t)) + (redisplay) + (cond + (completion-in-region-mode (completion-help-at-point t)) + ((completions--should-show-p + (completion--field-metadata (minibuffer-prompt-end)) + force-eager-update) + (minibuffer-completion-help)))) + nil)) ;; If we got interrupted, try again the next time the user is idle. (completions--start-background-update force-eager-update))) @@ -2797,7 +2799,8 @@ If FORCE-EAGER-UPDATE is non-nil, we only check eager-display." (unless completions--background-update-timer (setq completions--background-update-timer (run-with-idle-timer - 0 nil #'completions--background-update force-eager-update)))) + 0 nil #'completions--background-update + force-eager-update (current-buffer))))) (defun completions--start-eager-display () "Maybe display the *Completions* buffer when the user is next idle.