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#50552: 28.0.50; Add context-menu-occur Date: Mon, 13 Sep 2021 11:28:24 +0300 Organization: LINKOV.NET Message-ID: <8735q8g9dj.fsf@mail.linkov.net> References: <87ilz5d9a1.fsf@posteo.net> <87o88xu13p.fsf@mail.linkov.net> <87a6khd316.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15233"; 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: 50552@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 13 10:39:18 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 1mPhUj-0003jO-8y for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 10:39:17 +0200 Original-Received: from localhost ([::1]:47438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPhUg-0006zi-Li for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 04:39:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPhUV-0006xy-3E for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:39:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPhUU-00051B-S5 for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mPhUU-0006JQ-QF for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:39: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: Mon, 13 Sep 2021 08:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50552 X-GNU-PR-Package: emacs Original-Received: via spool by 50552-submit@debbugs.gnu.org id=B50552.163152229424191 (code B ref 50552); Mon, 13 Sep 2021 08:39:02 +0000 Original-Received: (at 50552) by debbugs.gnu.org; 13 Sep 2021 08:38:14 +0000 Original-Received: from localhost ([127.0.0.1]:44291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPhTi-0006I7-35 for submit@debbugs.gnu.org; Mon, 13 Sep 2021 04:38:14 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:42935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPhTe-0006Hf-Iq for 50552@debbugs.gnu.org; Mon, 13 Sep 2021 04:38:11 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A60B1C0006; Mon, 13 Sep 2021 08:38:03 +0000 (UTC) In-Reply-To: <87a6khd316.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 12 Sep 2021 19:09:25 +0000") 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:214199 Archived-At: >>> the below patch adds the commands occur-word-at-mouse and >>> occur-symbol-at-mouse, and a function for context-menu-mode to occur >>> words or symbols where the context menu was invoked. >>> >>> Would there be any interest in adding such a functionality? >> >> Thanks. There is a new function 'thing-at-mouse' with a new arg 'click' >> added today that you can use instead of 'thing-at-point'. >> You can see an example in lisp/net/dictionary.el. > > I see, but I wonder why dictionary.el directly manipulates > context-menu-functions with add-hook. The reasoning was the following: by default, dictionary.el is not loaded, so its context menu item is not used. But when the user wants to use dictionary.el and explicitly loads it, then automatically provide also its context menu item. This reasoning can't be applied to occur, because occur in replace.el is pre-loaded. > +(defun occur-word-at-mouse (event) > + "Display an occur buffer for the word at EVENT." > + (interactive "e") > + (occur (thing-at-mouse event 'word t))) > + > +(defun occur-symbol-at-mouse (event) > + "Display an occur buffer for the symbol at EVENT." > + (interactive "e") > + (occur (thing-at-mouse event 'symbol t))) Thanks, this is almost perfect. What remains to do is to create a regexp that matches only words/symbols. You can see how 'isearch-occur' converts a string to a word/symbol regexp by using '(funcall isearch-regexp-function isearch-string)' before calling 'occur'. > To keep in line with prog-context-menu and context-menu-dictionary, I > also removed the modification of context-menu-functions's :type. I guess this is the right thing since the user still can add 'occur-context-menu' as a function name to 'context-menu-functions'.