Subject: Re: bug#32777: 27.0.50; window-buffer gets wrong point

From: Eli Zaretskii <[email-masked]>
Date: Tue, 02 Oct 2018 06:21:30 +0300

> From: Federico Tedin <[email-masked]>
> Date: Mon, 1 Oct 2018 23:07:41 -0300
> Cc: [email-masked]
> 
> --- 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.

Can you explain the change?  The minibuffer window is already the
selected window at this point (look at the implementation of
minibuffer-selected-window), so using with-selected-window, which
seems to be the only real change in the above, should be redundant.
Also, with-selected-window makes the window's buffer current, so why
did you need with-current-buffer in addition?  What am I missing?

Thanks.