GNU bug report logs - #50552
28.0.50; Add context-menu-occur

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Sun, 12 Sep 2021 16:55:01 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: Philip Kaludercic <philipk <at> posteo.net>
Cc: 50552 <at> debbugs.gnu.org
Subject: bug#50552: 28.0.50; Add context-menu-occur
Date: Mon, 13 Sep 2021 11:28:24 +0300
>>> 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'.




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

Previous Next


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