GNU bug report logs - #50256
thing-at-mouse

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 29 Aug 2021 17:44:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50256 <at> debbugs.gnu.org
Subject: bug#50256: thing-at-mouse
Date: Wed, 01 Sep 2021 10:17:56 +0300
> 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))))
 
 (defun event-end (event)
   "Return the ending position of EVENT.
@@ -1519,8 +1519,8 @@ event-end
 
 See `event-start' for a description of the value returned."
   (if (consp event) (nth (if (consp (nth 2 event)) 2 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))))

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.

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?




This bug report was last modified 3 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.