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

From: martin rudalics <[email-masked]>
Date: Sat, 13 Oct 2018 15:08:08 +0200

> Martin, any comments?

+	       (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))))))))

The

+                 (with-current-buffer (window-buffer (selected-window))

should be superfluous by all our rules but we know too well how valid
these rules sometimes are.  Any other patch (for example, using an
idiom like (window-point (minibuffer-selected-window))) would be likely
longer than Federico's solution.

It would be interesting to find out why the patch works.  Federico's
earlier remark

   The problem is that when "with-current-buffer" is called with the
   resulting buffer, it that buffer has been opened on more than one
   window, the active window will be set according to a criteria which I
   haven't figured out yet, but not necessarily to the same exact window
   "minibuffer-selected-window" returned.

can't be the cause IMO because 'with-current-buffer' does not set the
"active window" and the value of point of the buffer made current
remains the previous value of point in that buffer and that should be
the value assigned by this step

4.3. put point on "next-error", type M-x M-n,

of Juri's scenario.  So far I'm clueless.

martin