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


Message #17 received at 50256 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50256 <at> debbugs.gnu.org
Subject: Re: bug#50256: thing-at-mouse
Date: Tue, 31 Aug 2021 09:49:29 +0300
>> This looks like the right signature.  Then the implementation
>> and an example of usage could look like this:
>
> [...]
>
>> +(defun context-menu-dictionary (menu)
>> +  "Dictionary context menu."
>> +  (when (thing-at-mouse last-input-event 'word)
>> +    (define-key menu [dictionary-separator] menu-bar-separator)
>> +    (define-key menu [dictionary-search-word-at-mouse]
>> +      '(menu-item "Dictionary Search" dictionary-search-word-at-mouse
>> +                  :help "Search the word at mouse click in dictionary")))
>> +  menu)
>
> Ah, I see.  Yes, that makes perfect sense to me -- go ahead and push
> (perhaps with some documentation).

In bug#50067 you suggested to add a new arg with the click event
to all context menu functions.  This will make code more readable:

  (defun context-menu-dictionary (menu click)
    (when (thing-at-mouse click 'word)

so I will change the call to provide the arg from last-input-event,
and maybe later it will be possible to acquire the same event
more directly, not from last-input-event, and all callers will get it.

Now the problem found in bug#9923:

1. 'C-h m' temporarily switches from the original *info* buffer
   to the *Help* buffer;

2. thing-at-mouse (called from context-menu-dictionary)
   uses (save-excursion (mouse-set-point event))

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.




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.