From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#50256: thing-at-mouse Date: Tue, 31 Aug 2021 09:49:29 +0300 Organization: LINKOV.NET Message-ID: <87y28i85xi.fsf@mail.linkov.net> References: <87sfys6ubm.fsf@mail.linkov.net> <87eeacdnmg.fsf@gnus.org> <87h7f7z8ui.fsf@mail.linkov.net> <871r6a8ooe.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29243"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 50256@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 31 09:12:46 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mKxws-0007Lx-Jo for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Aug 2021 09:12:46 +0200 Original-Received: from localhost ([::1]:54324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKxwr-0000MI-4Q for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Aug 2021 03:12:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKxwB-0007lN-Bd for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 03:12:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKxwB-0001Xy-3J for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 03:12:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKxwA-0004r8-Vf for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 03:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 31 Aug 2021 07:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50256 X-GNU-PR-Package: emacs Original-Received: via spool by 50256-submit@debbugs.gnu.org id=B50256.163039386818563 (code B ref 50256); Tue, 31 Aug 2021 07:12:02 +0000 Original-Received: (at 50256) by debbugs.gnu.org; 31 Aug 2021 07:11:08 +0000 Original-Received: from localhost ([127.0.0.1]:32783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxvH-0004pL-VR for submit@debbugs.gnu.org; Tue, 31 Aug 2021 03:11:08 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:53749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxvC-0004oT-7O for 50256@debbugs.gnu.org; Tue, 31 Aug 2021 03:11:03 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 476DDC000C; Tue, 31 Aug 2021 07:10:54 +0000 (UTC) In-Reply-To: <871r6a8ooe.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 31 Aug 2021 02:04:33 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:213083 Archived-At: >> 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.