From 6cb506a1f021888b5faf78090a4ab524fd8bb526 Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Mon, 1 Oct 2018 23:03:36 -0300 Subject: [PATCH] Fix M-n command completion for read-extended-command * lisp/simple.el (read-extended-command): Ensure the function uses the apropiate window when looking for a command to suggest when user enters M-n after initial prompt. (Bug#32777) --- lisp/simple.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index e41630d4ed..1d129c3c99 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1710,9 +1710,10 @@ read-extended-command (lambda () ;; Get a command name at point in the original buffer ;; to propose it after M-n. - (with-current-buffer (window-buffer (minibuffer-selected-window)) - (and (commandp (function-called-at-point)) - (format "%S" (function-called-at-point))))))) + (with-selected-window (minibuffer-selected-window) + (with-current-buffer (window-buffer (selected-window)) + (and (commandp (function-called-at-point)) + (format "%S" (function-called-at-point)))))))) ;; Read a string, completing from and restricting to the set of ;; all defined commands. Don't provide any initial input. ;; Save the command read on the extended-command history list. -- 2.17.1