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#50067: Context menus Date: Sat, 28 Aug 2021 21:50:15 +0300 Organization: LINKOV.NET Message-ID: <87eeado13s.fsf@mail.linkov.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20906"; 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: 50067@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp To: Naoya Yamashita Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 28 21:18:23 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 1mK3qP-0005GM-Ek for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 21:18:21 +0200 Original-Received: from localhost ([::1]:37438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mK3qO-0008FA-8w for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 15:18:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mK3q6-0007tQ-Mi for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 15:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mK3q6-00064F-Ey for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mK3q6-00069D-9B for bug-gnu-emacs@gnu.org; Sat, 28 Aug 2021 15:18: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: Sat, 28 Aug 2021 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50067 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 50067-submit@debbugs.gnu.org id=B50067.163017824423578 (code B ref 50067); Sat, 28 Aug 2021 19:18:02 +0000 Original-Received: (at 50067) by debbugs.gnu.org; 28 Aug 2021 19:17:24 +0000 Original-Received: from localhost ([127.0.0.1]:55019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK3pR-00068B-Hm for submit@debbugs.gnu.org; Sat, 28 Aug 2021 15:17:24 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mK3pN-00067u-Kg for 50067@debbugs.gnu.org; Sat, 28 Aug 2021 15:17:19 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 15422E0004; Sat, 28 Aug 2021 19:17:08 +0000 (UTC) In-Reply-To: (Naoya Yamashita's message of "Sat, 28 Aug 2021 18:08:39 +0900") 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:212893 Archived-At: --=-=-= Content-Type: text/plain > Hi. I'm one of the users of Emacs-jp. Tak introduced us to this > thread and it got me interested, I'm sending this Email. This > mail thread is huge and I haven't read all of it, so I'm sorry if > I misread the context. > > I've created a context menu for ispell (referencing `context-menu-ffap`). > You may find some inspiration from this. > > (defun context-menu-ispell (menu) > "Ispell at point menu." > (when t ;; (ffap-guess-file-name-at-point) > (define-key menu [ispell-separator] menu-bar-separator) > (define-key menu [ispell-at-mouse] > '(menu-item "Check spelling of word" ispell-word > :help "Check spelling of word under or before the cursor."))) > menu) Thanks for the suggestion. I think such menus should be added to their respective packages. context-menu-ispell could be added to ispell.el (when flyspell is unavailable). Then dictionary.el could provide own context menu too: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=context-menu-dictionary.patch diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index f33cbaf112..7a84f9978f 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1368,5 +1368,27 @@ global-dictionary-tooltip-mode (if on #'dictionary-tooltip-track-mouse #'ignore)) on)) +(defun dictionary-search-word-at-mouse (event) + (interactive "e") + (let ((word (save-window-excursion + (save-excursion + (mouse-set-point event) + (current-word))))) + (selected-window) + (dictionary-search word))) + +(defun context-menu-dictionary (menu) + "Dictionary word at point menu." + (save-excursion + (mouse-set-point last-input-event) + (when (thing-at-point '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) + +(add-hook 'context-menu-functions 'context-menu-dictionary 15) + (provide 'dictionary) ;;; dictionary.el ends here --=-=-=--