Subject: bug#50256: thing-at-mouse

From: Juri Linkov <[email-masked]>
Date: Tue, 31 Aug 2021 20:52:43 +0300

> 3. mouse-set-point calls (posn-set-point (event-end event))
>
> 4. in posn-set-point:
> 4.1. (select-window (posn-window position))
>      switches back to the original *info* buffer
>      that was selected in the window;
>
> 4.2. (goto-char (posn-point position))
>      goes to the position that event-end got from the *Help* buffer,
>      so in the *info* buffer moves to the position from the *Help* buffer.
>
> So maybe need to add the same condition that I already added to 2 places:
>
>     (eq (window-buffer (posn-window (event-start event)))
>                        (current-buffer))
>
> but I have no idea at what level to add it: in mouse-set-point?
> Or deeper in posn-set-point?  Both are quite low-level,
> and I don't know if this might break something.

There are more context-menu-functions that use mouse-set-point
that fails with 'C-h m', e.g.:

  (defun context-menu-ffap (menu)
    "File at point menu."
    (save-excursion
      (mouse-set-point last-input-event)
      (when (ffap-guess-file-name-at-point)

So maybe the check for current-buffer above should be added
to mouse-set-point.  Or maybe it's not backward-compatible,
I'm not sure.