Subject: Re: bug#50256: thing-at-mouse

From: Eli Zaretskii <[email-masked]>
Date: Wed, 01 Sep 2021 15:02:04 +0300

> From: Juri Linkov <[email-masked]>
> Date: Wed, 01 Sep 2021 10:17:56 +0300
> Cc: [email-masked]
> 
> > So maybe the check for current-buffer above should be added
> > to mouse-set-point.
> 
> Now I found the real root of the problems.  All reported problems
> can be solved by this short patch:
> 
> diff --git a/lisp/subr.el b/lisp/subr.el
> index 0a31ef2b29..0b3b8d0e0f 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -1510,8 +1510,8 @@ event-start
>  
>  For more information, see Info node `(elisp)Click Events'."
>    (if (consp event) (nth 1 event)
> -    (or (posn-at-point)
> -        (list (selected-window) (point) '(0 . 0) 0))))
> +    (or (posn-at-point (window-point))
> +        (list (selected-window) (window-point) '(0 . 0) 0))))

I don't understand this: are you saying that in a selected window you
see point different from window-point?  How does that happen?

> Both 'event-start' and 'event-end' created an event
> with the window equal to the selected window,
> but point from some random buffer,
> not from selected window's buffer.

Can you show the recipe that produces this strange result?  (I looked
at bug#9923, which you say is where this was reported, but couldn't
find a recipe there for which you described the sequence of calls.)

> One question still remains: maybe this fix should be implemented
> at a deeper level in posn-at-point when its arg POS is nil?
> 
> But actually, posn-at-point just uses this line:
> 
>   tem = Fpos_visible_in_window_p (pos, window, Qt);
> 
> So maybe this fix should be implemented in Fpos_visible_in_window_p,
> i.e. at the end of this code
> 
>   if (EQ (pos, Qt))
>     posint = -1;
>   else if (!NILP (pos))
>     posint = fix_position (pos);
>   else if (w == XWINDOW (selected_window))
>     posint = PT;
>   else
>     posint = marker_position (w->pointm);
> 
> it should get position from the selected window's buffer?

Once again, in a selected window, point (a.k.a. "PT" in C) should be
identical to the window-point of that window.  So I don't think I
understand why this would need any change.  Please tell more.