GNU bug report logs - #50067
Context menus

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 15 Aug 2021 08:52: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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50067 in the body.
You can then email your comments to 50067 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 15 Aug 2021 08:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 15 Aug 2021 08:52:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Context menus
Date: Sun, 15 Aug 2021 11:48:55 +0300
The branch 'feature/context-menu' is ready for merging to master.

It was created after the discussion in
https://lists.gnu.org/archive/html/emacs-devel/2021-07/msg00300.html
as a proof-of-concept.

And after testing with different modes, it proved to be flexible enough
to support various needs.

After merging it could be improved further with more development in master.

The branch contains a NEWS entry and changes in the documentation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 15 Aug 2021 11:57:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 15 Aug 2021 13:56:01 +0200
Juri Linkov <juri <at> linkov.net> writes:

> The branch 'feature/context-menu' is ready for merging to master.
>
> It was created after the discussion in
> https://lists.gnu.org/archive/html/emacs-devel/2021-07/msg00300.html
> as a proof-of-concept.
>
> And after testing with different modes, it proved to be flexible enough
> to support various needs.
>
> After merging it could be improved further with more development in master.

I haven't tested the branch, but reading the diff, it looks like an
excellent feature to me.  Looking at the implementation of the stuff in
various modes, I'm wondering whether the interface should perhaps be
tweaked a bit:

+(defun eww-context-menu (menu)
[...]
+  (when (or (mouse-posn-property (event-start last-input-event) 'shr-url)
+            (mouse-posn-property (event-start last-input-event) 'image-url))
+    (define-key menu [shr-mouse-browse-url-new-window]

Perhaps the signature of the context menu functions should be:

+(defun eww-context-menu (menu event)

?

I'm also wondering whether we should add a `context-menu' text property.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 15 Aug 2021 16:22:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 15 Aug 2021 19:12:57 +0300
> I haven't tested the branch, but reading the diff, it looks like an
> excellent feature to me.  Looking at the implementation of the stuff in
> various modes, I'm wondering whether the interface should perhaps be
> tweaked a bit:
>
> +(defun eww-context-menu (menu)
> [...]
> +  (when (or (mouse-posn-property (event-start last-input-event) 'shr-url)
> +            (mouse-posn-property (event-start last-input-event) 'image-url))
> +    (define-key menu [shr-mouse-browse-url-new-window]
>
> Perhaps the signature of the context menu functions should be:
>
> +(defun eww-context-menu (menu event)
>
> ?

To get an event would be nice, but I see no way to do this.
The top function 'context-menu-map' is called by:

  `(menu-item ,(purecopy "Context Menu") ignore
              :filter (lambda (_) (context-menu-map))))

that has no access to the event - an unused argument of lambda above
is just the binding that is 'ignore' in this case.

> I'm also wondering whether we should add a `context-menu' text property.

As soon as such a need arises, a text property could be added as well.
But it seems currently much cleaner is to use a single context-menu
function for every mode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 16 Aug 2021 11:33:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 16 Aug 2021 13:31:58 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> +(defun eww-context-menu (menu)
>> [...]
>> +  (when (or (mouse-posn-property (event-start last-input-event) 'shr-url)
>> +            (mouse-posn-property (event-start last-input-event) 'image-url))
>> +    (define-key menu [shr-mouse-browse-url-new-window]

[...]

> To get an event would be nice, but I see no way to do this.
> The top function 'context-menu-map' is called by:
>
>   `(menu-item ,(purecopy "Context Menu") ignore
>               :filter (lambda (_) (context-menu-map))))
>
> that has no access to the event - an unused argument of lambda above
> is just the binding that is 'ignore' in this case.

Could just use `last-input-event', I guess?  But that doesn't really
give us anything better than what we have, so there's probably no point.

>> I'm also wondering whether we should add a `context-menu' text property.
>
> As soon as such a need arises, a text property could be added as well.
> But it seems currently much cleaner is to use a single context-menu
> function for every mode.

Right.  I was thinking that it's pretty likely that all button-like
things are going to grow a context menu, but we can add `context-menu'
later if that turns out to be the case.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 17 Aug 2021 08:14:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 17 Aug 2021 11:12:41 +0300
tags 50067 fixed
close 50067 28.0.50
quit

>>> I'm also wondering whether we should add a `context-menu' text property.
>>
>> As soon as such a need arises, a text property could be added as well.
>> But it seems currently much cleaner is to use a single context-menu
>> function for every mode.
>
> Right.  I was thinking that it's pretty likely that all button-like
> things are going to grow a context menu, but we can add `context-menu'
> later if that turns out to be the case.

It would be easier to make more experiments with code in master,
so now merged the branch to master.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 17 Aug 2021 08:14:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 50067 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 17 Aug 2021 08:14:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 04:39:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <homeros.misasa <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org,
 tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 13:38:04 +0900
> It would be easier to make more experiments with code in master,
> so now merged the branch to master.

I see the context menu after M-x context-menu-mode.  Thank you for
working on this.

I will see how it works and try to give feedback soon.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 08:11:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <homeros.misasa <at> gmail.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org,
 tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 10:47:34 +0300
>> It would be easier to make more experiments with code in master,
>> so now merged the branch to master.
>
> I see the context menu after M-x context-menu-mode.  Thank you for
> working on this.

Thank you for the great idea of using a list of functions.

> I will see how it works and try to give feedback soon.

Waiting for your feedback.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 16:46:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: tkk <at> misasa.okayama-u.ac.jp, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 50067 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 19:42:12 +0300
> 1. Mac users expect C-mouse-1 to be equivalent to mouse-3 because Macs
> traditionally only have one mouse button; this is especially true of laptop
> users (probably the majority today). Simply speaking, control-mouse-1 is
> expected to invoke the context menu; this is the platform convention and we
> should try to find a way to make it so.
>
> We could add a mac-only setting that remaps control-mouse-1 to mouse-3
> (preserving all other modifiers like shift, alt and super). (I don't think
> there already is such a translation but could be mistaken). I'm attaching
> a tentative patch as a proof of concept.
>
> It is also possible to just do it in Lisp, but then we'd probably need
> to do it specially for the context menu. (I tried using event
> translation but that didn't work right.)

The raison d'être for the special mode context-menu-mode is to
rebind the default keys optionally.  So it would make sense to bind
context-menu-entry conditionally:

1. to [C-mouse-1] on macOS depending on ‘(featurep 'ns)’;
2. to [down-mouse-3] everywhere else.

in the function body of context-menu-mode.

> Currently, C-mouse-1 pops up the buffer menu but it's unclear if
> that's used by a sizeable part of the population, and in any case Macs
> have a Buffer menu easily accessible in the menu bar.

Additionally, a Buffer menu is accessible from the context menu
when context-menu-functions is customized to contain ‘context-menu-global’.

> 2. The context menu contains the disabled entry "Context Menu" as some kind
> of title – that is very alien on macOS where context menus never have
> titles. I believe the same is true at least on Windows, and frankly, there
> should be no need to explicitly tell the user that what he or she is
> looking at is a context menu. I suggest we just drop the title on
> all platforms.
>
> Replacing (purecopy "Context Menu") by "" in `context-menu-entry` makes it
> go away, but then we get the new title "Select" from heavens knows where
> (menu.c, from the look of it). Apparently the Emacs menu system just wants
> a title; we should find a way to disable it in popup menus.

After trying to remove it altogether, there is no title at all,
but maybe it's platform-dependent (I tested on GTK):

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 9b7d4c240f..5193994231 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -304,7 +304,7 @@ context-menu-filter-function
 (defun context-menu-map ()
   "Return composite menu map."
-  (let ((menu (make-sparse-keymap "Context Menu")))
+  (let ((menu (make-sparse-keymap)))
     (run-hook-wrapped 'context-menu-functions
                       (lambda (fun)
                         (setq menu (funcall fun menu))

> 3. Not Mac-specific (really about xref): in some modes, Find Definition
> applies to point instead of where the click occurred. Apparently the xref
> backend ignores the symbol discovered by xref-find-definition-at-mouse
> because that tokenisation isn't appropriate for the language and it does
> a more thorough job that is based on point instead. What we really should
> do is to set point temporarily for the whole duration of the
> xref-find-definitions call.

Could you please provide a test case?  Because I've thoroughly tested
“Find Definition” to apply where the click occurred, and it works as expected.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 17:47:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: tkk <at> misasa.okayama-u.ac.jp, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 50067 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 19:46:45 +0200
18 aug. 2021 kl. 18.42 skrev Juri Linkov <juri <at> linkov.net>:

> The raison d'être for the special mode context-menu-mode is to
> rebind the default keys optionally.  So it would make sense to bind
> context-menu-entry conditionally:
> 
> 1. to [C-mouse-1] on macOS depending on ‘(featurep 'ns)’;
> 2. to [down-mouse-3] everywhere else.
> 
> in the function body of context-menu-mode.

We'd like both bindings to work on macOS (the user could have a mouse with a right button) but that should be doable.

> After trying to remove it altogether, there is no title at all,
> but maybe it's platform-dependent (I tested on GTK):

After your suggested change I still get the "Select" title; needs to be investigated further.

> Could you please provide a test case?  Because I've thoroughly tested
> “Find Definition” to apply where the click occurred, and it works as expected.

Yes it works for elisp, because its xref backend is simplistic enough to just accept the symbol given as argument. An example of a package where it doesn't work is merlin which is rather more sophisticated and wants to find the exact context so that it can find the right definition, so it ignores the argument.

It would be useful to do this for elisp as well, so that it would work for local variables etc.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 17:48:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 20:46:53 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Date: Wed, 18 Aug 2021 19:42:12 +0300
> Cc: 50067 <at> debbugs.gnu.org, Tak Kunihiro <homeros.misasa <at> gmail.com>,
>  tkk <at> misasa.okayama-u.ac.jp, Lars Ingebrigtsen <larsi <at> gnus.org>,
>  Alan Third <alan <at> idiocy.org>
> 
> > 2. The context menu contains the disabled entry "Context Menu" as some kind
> > of title – that is very alien on macOS where context menus never have
> > titles. I believe the same is true at least on Windows, and frankly, there
> > should be no need to explicitly tell the user that what he or she is
> > looking at is a context menu. I suggest we just drop the title on
> > all platforms.
> >
> > Replacing (purecopy "Context Menu") by "" in `context-menu-entry` makes it
> > go away, but then we get the new title "Select" from heavens knows where
> > (menu.c, from the look of it). Apparently the Emacs menu system just wants
> > a title; we should find a way to disable it in popup menus.
> 
> After trying to remove it altogether, there is no title at all,
> but maybe it's platform-dependent (I tested on GTK):
> 
> diff --git a/lisp/mouse.el b/lisp/mouse.el
> index 9b7d4c240f..5193994231 100644
> --- a/lisp/mouse.el
> +++ b/lisp/mouse.el
> @@ -304,7 +304,7 @@ context-menu-filter-function
>  (defun context-menu-map ()
>    "Return composite menu map."
> -  (let ((menu (make-sparse-keymap "Context Menu")))
> +  (let ((menu (make-sparse-keymap)))
>      (run-hook-wrapped 'context-menu-functions
>                        (lambda (fun)
>                          (setq menu (funcall fun menu))

I see you already pushed this, but it's a bad idea: it makes ugly
context menus on TTYs (and AFAIU also on non-toolkit X builds): these
_require_ the menu name because they display a caption which looks bad
with an empty name.

I don't really understand the original complaint: we have similar
captions on the menu shown by C-mouse-3 in the default configuration:
do macOS users want those to be removed as well?  If not, what is the
difference?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 17:54:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 20:53:12 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Wed, 18 Aug 2021 19:46:45 +0200
> Cc: 50067 <at> debbugs.gnu.org, Tak Kunihiro <homeros.misasa <at> gmail.com>,
>  tkk <at> misasa.okayama-u.ac.jp, Lars Ingebrigtsen <larsi <at> gnus.org>,
>  Alan Third <alan <at> idiocy.org>
> 
> > After trying to remove it altogether, there is no title at all,
> > but maybe it's platform-dependent (I tested on GTK):
> 
> After your suggested change I still get the "Select" title; needs to be investigated further.

That "Select" is probably macOS specific, I don't see it here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:02:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, Juri Linkov <juri <at> linkov.net>, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 20:01:17 +0200
18 aug. 2021 kl. 19.46 skrev Eli Zaretskii <eliz <at> gnu.org>:

> I don't really understand the original complaint: we have similar
> captions on the menu shown by C-mouse-3 in the default configuration:
> do macOS users want those to be removed as well?

We definitely do but few people use that (rather useless) menu so its appearance doesn't matter much.
If the goal here is to make a genuinely useful context menu that people actually want to use, then it should look like one.

I'm probably wrong, but Windows context menus haven't titles either as I remember it and they would look quite out of place on that platform as well.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:03:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:07:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:06:11 +0300
>> diff --git a/lisp/mouse.el b/lisp/mouse.el
>> index 9b7d4c240f..5193994231 100644
>> --- a/lisp/mouse.el
>> +++ b/lisp/mouse.el
>> @@ -304,7 +304,7 @@ context-menu-filter-function
>>  (defun context-menu-map ()
>>    "Return composite menu map."
>> -  (let ((menu (make-sparse-keymap "Context Menu")))
>> +  (let ((menu (make-sparse-keymap)))
>>      (run-hook-wrapped 'context-menu-functions
>>                        (lambda (fun)
>>                          (setq menu (funcall fun menu))
>
> I see you already pushed this, but it's a bad idea: it makes ugly
> context menus on TTYs (and AFAIU also on non-toolkit X builds): these
> _require_ the menu name because they display a caption which looks bad
> with an empty name.

I guess the presence of the title should be platform-dependent.
For example, without a title it looks great on the GTK build.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:12:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:11:16 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Wed, 18 Aug 2021 20:01:17 +0200
> Cc: Juri Linkov <juri <at> linkov.net>, 50067 <at> debbugs.gnu.org,
>         homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>         alan <at> idiocy.org
> 
> 18 aug. 2021 kl. 19.46 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> > I don't really understand the original complaint: we have similar
> > captions on the menu shown by C-mouse-3 in the default configuration:
> > do macOS users want those to be removed as well?
> 
> We definitely do but few people use that (rather useless) menu so its appearance doesn't matter much.

OK, so I guess this change should be done only on macOS (but not on
TTY frames displayed on macOS).

> I'm probably wrong, but Windows context menus haven't titles either as I remember it and they would look quite out of place on that platform as well.

Well, C-mouse-3 shows the caption of a menu on MS-Windows, so I see no
problem with showing "Context menu" there (or any other string, if we
find a better one, actually).  That serves as a small description of
what this menu is about.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:14:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:12:58 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: mattiase <at> acm.org,  50067 <at> debbugs.gnu.org,  homeros.misasa <at> gmail.com,
>   tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,  alan <at> idiocy.org
> Date: Wed, 18 Aug 2021 21:06:11 +0300
> 
> > I see you already pushed this, but it's a bad idea: it makes ugly
> > context menus on TTYs (and AFAIU also on non-toolkit X builds): these
> > _require_ the menu name because they display a caption which looks bad
> > with an empty name.
> 
> I guess the presence of the title should be platform-dependent.
> For example, without a title it looks great on the GTK build.

What happens if the GTK build displays a TTY frame?  Isn't the menu
definition global, and thus doesn't distinguish between frame types?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:41:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: juri <at> linkov.net, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:39:55 +0300
> Date: Wed, 18 Aug 2021 21:12:58 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
>  tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
> 
> > > I see you already pushed this, but it's a bad idea: it makes ugly
> > > context menus on TTYs (and AFAIU also on non-toolkit X builds): these
> > > _require_ the menu name because they display a caption which looks bad
> > > with an empty name.
> > 
> > I guess the presence of the title should be platform-dependent.
> > For example, without a title it looks great on the GTK build.
> 
> What happens if the GTK build displays a TTY frame?  Isn't the menu
> definition global, and thus doesn't distinguish between frame types?

Come to think about it: aren't menu keymaps _required_ to have this
string?  The ELisp manual says:

   -- Function: make-sparse-keymap &optional prompt
       This function creates and returns a new sparse keymap with no
       entries.  (A sparse keymap is the kind of keymap you usually want.)
       The new keymap does not contain a char-table, unlike ‘make-keymap’,
       and does not bind any events.

	    (make-sparse-keymap)
		⇒ (keymap)

       If you specify PROMPT, that becomes the overall prompt string for
       the keymap.  You should specify this only for menu keymaps (*note
       Defining Menus::).  A keymap with an overall prompt string will
       always present a mouse menu or a keyboard menu if it is active for
       looking up the next input event.

Stefan, did we remove this requirement at some point, or is it still a
requirement?

If this is still needed (and it seems to be, at least on some frame
types), I guess it's the code which produces native menus that wants
not to have this caption (e.g., on macOS and GTK) -- that code should
ignore this string and not stuff it into the native menu widget.  But
internally the menu name should still be present in the Lisp data
structure.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 18:46:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:40:19 +0300
>> I guess the presence of the title should be platform-dependent.
>> For example, without a title it looks great on the GTK build.
>
> What happens if the GTK build displays a TTY frame?  Isn't the menu
> definition global, and thus doesn't distinguish between frame types?

The menu definition is constructed dynamically, so it possible
to set the title when (framep (selected-frame)) returns t on tty.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 18 Aug 2021 19:00:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:59:10 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: mattiase <at> acm.org,  50067 <at> debbugs.gnu.org,  homeros.misasa <at> gmail.com,
>   tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,  alan <at> idiocy.org
> Date: Wed, 18 Aug 2021 21:40:19 +0300
> 
> >> I guess the presence of the title should be platform-dependent.
> >> For example, without a title it looks great on the GTK build.
> >
> > What happens if the GTK build displays a TTY frame?  Isn't the menu
> > definition global, and thus doesn't distinguish between frame types?
> 
> The menu definition is constructed dynamically, so it possible
> to set the title when (framep (selected-frame)) returns t on tty.

OK, but as I wrote elsewhere, I think the string should always be
present, and if some GUI toolkit wants to ignore it, it should avoid
putting it into the native menu structure when it creates the menu
widget(s).  The Lisp data should remain the same, IMO.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 19 Aug 2021 01:32:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 18 Aug 2021 21:31:37 -0400
> Stefan, did we remove this requirement at some point, or is it still a
> requirement?

If memory serves it's used (as the title) for the non-toolkit menus and
it's not used for the toolkit menus, but the reality is probably less
clear cut than that.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 19 Aug 2021 06:46:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 19 Aug 2021 09:44:48 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: juri <at> linkov.net,  alan <at> idiocy.org,  mattiase <at> acm.org,
>   homeros.misasa <at> gmail.com,  tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,
>   50067 <at> debbugs.gnu.org
> Date: Wed, 18 Aug 2021 21:31:37 -0400
> 
> > Stefan, did we remove this requirement at some point, or is it still a
> > requirement?
> 
> If memory serves it's used (as the title) for the non-toolkit menus and
> it's not used for the toolkit menus, but the reality is probably less
> clear cut than that.

That's also my recollection.  In particular TTY menus actually
_expect_ to find a meaningful string there.

So I think we need to reinstate the name in the context menus (though
perhaps we could come up with a better name than "Context menu"), and
if some toolkit wants to ignore it, they should do it when they create
the menu widgets to show the menu on the screen.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 19 Aug 2021 07:23:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 19 Aug 2021 10:12:54 +0300
>> >> I guess the presence of the title should be platform-dependent.
>> >> For example, without a title it looks great on the GTK build.
>> >
>> > What happens if the GTK build displays a TTY frame?  Isn't the menu
>> > definition global, and thus doesn't distinguish between frame types?
>> 
>> The menu definition is constructed dynamically, so it possible
>> to set the title when (framep (selected-frame)) returns t on tty.
>
> OK, but as I wrote elsewhere, I think the string should always be
> present, and if some GUI toolkit wants to ignore it, it should avoid
> putting it into the native menu structure when it creates the menu
> widget(s).  The Lisp data should remain the same, IMO.

GUI toolkits can't ignore titles for all menus.  Some menus should be
displayed with a title for all toolkits.  The context menu is special.
Nowadays everyone is accustomed to down-mouse-3 popping up a context menu
without title.  But other Emacs-specific menus that are not familiar to users
such as mouse-buffer-menu bound C-<down-mouse-1> should display a title
for all toolkits to explain to the user what choice the menu presents.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 19 Aug 2021 07:59:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 19 Aug 2021 10:57:43 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: mattiase <at> acm.org,  50067 <at> debbugs.gnu.org,  homeros.misasa <at> gmail.com,
>   tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,  alan <at> idiocy.org
> Date: Thu, 19 Aug 2021 10:12:54 +0300
> 
> > OK, but as I wrote elsewhere, I think the string should always be
> > present, and if some GUI toolkit wants to ignore it, it should avoid
> > putting it into the native menu structure when it creates the menu
> > widget(s).  The Lisp data should remain the same, IMO.
> 
> GUI toolkits can't ignore titles for all menus.  Some menus should be
> displayed with a title for all toolkits.

Which popup menus have titles that cannot be ignored, and why?

> The context menu is special.  Nowadays everyone is accustomed to
> down-mouse-3 popping up a context menu without title.  But other
> Emacs-specific menus that are not familiar to users such as
> mouse-buffer-menu bound C-<down-mouse-1> should display a title for
> all toolkits to explain to the user what choice the menu presents.

If we want some titles to behave in special ways, we could put a text
property on the title string to mark those titles that should get
special treatment.  That is better than removing the title, and
certainly better than removing it based on the frame type, because
then Lisp code which handles the menu keymaps will need to be prepared
to handle both kinds of menu keymaps, the ones with a title and ones
without it.  It is also against the documented practice.

So let's please reinstate the title, and use properties or some other
mechanism to mark the title strings that need special handling in some
circumstances.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 19 Aug 2021 14:23:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: tkk <at> misasa.okayama-u.ac.jp, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 50067 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Thu, 19 Aug 2021 16:22:39 +0200
18 aug. 2021 kl. 19.46 skrev Mattias Engdegård <mattiase <at> acm.org>:

> Yes it works for elisp, because its xref backend is simplistic enough to just accept the symbol given as argument. An example of a package where it doesn't work is merlin which is rather more sophisticated and wants to find the exact context so that it can find the right definition, so it ignores the argument.

Having actually read the doc strings I see that xref backends are supposed to define `xref-backend-identifier-at-point` which can stuff any information it needs in a property of the string it returns, as sort of a semi-covert channel to `xref-backend-definitions` etc. Sorry about the unfounded complaint.

Would adding `xref-find-references-at-mouse` be handy for use in the context menu?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 07:33:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 10:29:47 +0300
>> GUI toolkits can't ignore titles for all menus.  Some menus should be
>> displayed with a title for all toolkits.
>
> Which popup menus have titles that cannot be ignored, and why?

An example of such menu is mouse-buffer-menu bound to C-<down-mouse-1>
where the user might wonder what do these menu items with mode names mean?

>> The context menu is special.  Nowadays everyone is accustomed to
>> down-mouse-3 popping up a context menu without title.  But other
>> Emacs-specific menus that are not familiar to users such as
>> mouse-buffer-menu bound C-<down-mouse-1> should display a title for
>> all toolkits to explain to the user what choice the menu presents.
>
> If we want some titles to behave in special ways, we could put a text
> property on the title string to mark those titles that should get
> special treatment.  That is better than removing the title, and
> certainly better than removing it based on the frame type, because
> then Lisp code which handles the menu keymaps will need to be prepared
> to handle both kinds of menu keymaps, the ones with a title and ones
> without it.  It is also against the documented practice.

Using a text property would be a good solution.  Should then
the NS-specific "Select" title be removed in menu.c
when the title has a special text property?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 07:34:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: tkk <at> misasa.okayama-u.ac.jp, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 50067 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 10:31:07 +0300
>> Yes it works for elisp, because its xref backend is simplistic enough to
>> just accept the symbol given as argument. An example of a package where
>> it doesn't work is merlin which is rather more sophisticated and wants to
>> find the exact context so that it can find the right definition, so it
>> ignores the argument.
>
> Having actually read the doc strings I see that xref backends are supposed
> to define `xref-backend-identifier-at-point` which can stuff any
> information it needs in a property of the string it returns, as sort of
> a semi-covert channel to `xref-backend-definitions` etc. Sorry about the
> unfounded complaint.
>
> Would adding `xref-find-references-at-mouse` be handy for use in the context menu?

If the existing `xref-backend-identifier-at-point` can't be reused
by adding a new optional arg `click`, then a cleaner solution
would be to add `xref-backend-identifier-at-mouse` indeed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 10:31:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp,
 larsi <at> gnus.org, 50067 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 12:29:46 +0200
[Message part 1 (text/plain, inline)]
20 aug. 2021 kl. 09.29 skrev Juri Linkov <juri <at> linkov.net>:

> An example of such menu is mouse-buffer-menu bound to C-<down-mouse-1>
> where the user might wonder what do these menu items with mode names mean?

That's moot for macOS since C-mouse-1 will be used for the context menu. (Proposed patch attached.)

In macOS/NS, "titles" as disabled menu entries simply do not exist in the GUI vocabulary and look alien, amateurish, confusing or wrong. The menu is expected to be understood in its context of activation.

Where menus have titles, it's the corresponding entry in the parent menu (or menu bar). They are never named "something Menu" because that would be silly; typically it's a verb, or a noun setting a context for the entries in the sub-menu. For a menu of buffers to switch to, the title (if any) might be "Switch to buffer", "Buffer", "Switch to" or similar.

[0001-Use-C-mouse-1-for-context-menu-on-NS.patch (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 10:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 13:53:33 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Fri, 20 Aug 2021 12:29:46 +0200
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 50067 <at> debbugs.gnu.org,
>         homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>         alan <at> idiocy.org
> 
> In macOS/NS, "titles" as disabled menu entries simply do not exist in the GUI vocabulary and look alien, amateurish, confusing or wrong. The menu is expected to be understood in its context of activation.

Then please propose macOS-specific changes that ignore the menu names
instead of displaying them.  Platform-specific conventions should not
leak into general Lisp data structures.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 11:33:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 13:32:28 +0200
20 aug. 2021 kl. 12.53 skrev Eli Zaretskii <eliz <at> gnu.org>:

> Then please propose macOS-specific changes that ignore the menu names
> instead of displaying them.  Platform-specific conventions should not
> leak into general Lisp data structures.

I fully agree. I'll see what I can do.

Meanwhile I'm pushing the C-mouse-1 change since it seems to be in line with the intent of context-menu-mode.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 11:34:04 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 14:32:27 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: mattiase <at> acm.org,  50067 <at> debbugs.gnu.org,  homeros.misasa <at> gmail.com,
>   tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,  alan <at> idiocy.org
> Date: Fri, 20 Aug 2021 10:29:47 +0300
> 
> >> GUI toolkits can't ignore titles for all menus.  Some menus should be
> >> displayed with a title for all toolkits.
> >
> > Which popup menus have titles that cannot be ignored, and why?
> 
> An example of such menu is mouse-buffer-menu bound to C-<down-mouse-1>
> where the user might wonder what do these menu items with mode names mean?

OK, but I still don't think I fully understand how context menus are
different.  Are we sure the user will immediately understand the
purpose of the context menus, but not of a buffer-menu?

> > If we want some titles to behave in special ways, we could put a text
> > property on the title string to mark those titles that should get
> > special treatment.  That is better than removing the title, and
> > certainly better than removing it based on the frame type, because
> > then Lisp code which handles the menu keymaps will need to be prepared
> > to handle both kinds of menu keymaps, the ones with a title and ones
> > without it.  It is also against the documented practice.
> 
> Using a text property would be a good solution.  Should then
> the NS-specific "Select" title be removed in menu.c
> when the title has a special text property?

I'm not sure I understand what is the NS-specific "Select" title.  Can
you point me to the relevant code?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 16:53:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 19:36:58 +0300
[Message part 1 (text/plain, inline)]
>> An example of such menu is mouse-buffer-menu bound to C-<down-mouse-1>
>> where the user might wonder what do these menu items with mode names mean?
>
> OK, but I still don't think I fully understand how context menus are
> different.  Are we sure the user will immediately understand the
> purpose of the context menus, but not of a buffer-menu?

Context menus displayed up by down-mouse-3 are ubiquitous nowadays,
they are everywhere, and the users expect them without a title,
unlike Emacs-specific menus unfamiliar to most users.

>> Using a text property would be a good solution.  Should then
>> the NS-specific "Select" title be removed in menu.c
>> when the title has a special text property?
>
> I'm not sure I understand what is the NS-specific "Select" title.  Can
> you point me to the relevant code?

I meant such patch:

[context-menu-title.patch (text/x-diff, inline)]
diff --git a/lisp/mouse.el b/lisp/mouse.el
index d2a5200d8d..f9355b4f73 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -304,7 +304,7 @@ context-menu-filter-function
 
 (defun context-menu-map ()
   "Return composite menu map."
-  (let ((menu (make-sparse-keymap)))
+  (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))))
     (run-hook-wrapped 'context-menu-functions
                       (lambda (fun)
                         (setq menu (funcall fun menu))
diff --git a/src/menu.c b/src/menu.c
index 3b1d740257..6654c47c93 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1284,6 +1284,14 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
       /* Search for a string appearing directly as an element of the keymap.
 	 That string is the title of the menu.  */
       prompt = Fkeymap_prompt (keymap);
+
+#if defined (USE_GTK) || defined (HAVE_NS)
+      if (STRINGP (prompt)
+	  && SCHARS (prompt) > 0
+	  && !NILP (Fget_text_property (make_fixnum (0), Qhide, prompt)))
+	title = Qnil;
+      else
+#endif
       if (!NILP (prompt))
 	title = prompt;
 #ifdef HAVE_NS		/* Is that needed and NS-specific?  --Stef  */

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 16:53:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp,
 larsi <at> gnus.org, 50067 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 19:50:36 +0300
> Meanwhile I'm pushing the C-mouse-1 change since it seems to be
> in line with the intent of context-menu-mode.

On emacs-devel Ergus proposed to add such bindings to a new
context-menu-mode-map.  Do you think this is feasible?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 17:07:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Alan Third <alan <at> idiocy.org>, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 tkk <at> misasa.okayama-u.ac.jp, Dmitry Gutov <dgutov <at> yandex.ru>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 19:06:20 +0200
[Message part 1 (text/plain, inline)]
20 aug. 2021 kl. 09.31 skrev Juri Linkov <juri <at> linkov.net>:

> If the existing `xref-backend-identifier-at-point` can't be reused
> by adding a new optional arg `click`, then a cleaner solution
> would be to add `xref-backend-identifier-at-mouse` indeed.

`xref-backend-identifier-at-point` is a generic function implemented by each backend; a new function appears cleaner. Suggested patch attached!

More discoveries and questions:

* If I start emacs -Q and enable context-menu-mode, right-clicking on an identifier in an elisp buffer still doesn't produce the Find Definition entry, presumably because xref hasn't been loaded. Shouldn't it be arranged to be autoloaded somehow, which is how xref works when invoked by keystrokes?

* `xref-make-match` requires (contrary to its doc string) its LOCATION argument to be of type `xref-file-location`, but some backends may only be able to make an `xref-buffer-location`. Would anyone object to changing the :location slot of `xref-match-item` to have type `xref-location`? I don't see how it could hurt.

[0001-Add-Find-References-to-context-menu.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 17:13:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp,
 larsi <at> gnus.org, 50067 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 19:11:50 +0200
20 aug. 2021 kl. 18.50 skrev Juri Linkov <juri <at> linkov.net>:

> On emacs-devel Ergus proposed to add such bindings to a new
> context-menu-mode-map.  Do you think this is feasible?

Quite possibly, but the proof is in the pudding.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 17:14:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 18:01:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 20:59:47 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: mattiase <at> acm.org,  50067 <at> debbugs.gnu.org,  homeros.misasa <at> gmail.com,
>   tkk <at> misasa.okayama-u.ac.jp,  larsi <at> gnus.org,  alan <at> idiocy.org
> Date: Fri, 20 Aug 2021 19:36:58 +0300
> 
> > OK, but I still don't think I fully understand how context menus are
> > different.  Are we sure the user will immediately understand the
> > purpose of the context menus, but not of a buffer-menu?
> 
> Context menus displayed up by down-mouse-3 are ubiquitous nowadays,
> they are everywhere, and the users expect them without a title,
> unlike Emacs-specific menus unfamiliar to most users.

So if some menu is popped up by mouse-3, it is automatically
considered ubiquitous and expected?  I really doubt that, but I won't
argue any further.

> >> Using a text property would be a good solution.  Should then
> >> the NS-specific "Select" title be removed in menu.c
> >> when the title has a special text property?
> >
> > I'm not sure I understand what is the NS-specific "Select" title.  Can
> > you point me to the relevant code?
> 
> I meant such patch:

OK, but where in that patch is the NS-specific "Select" title that
should be removed?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 19:31:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, Juri Linkov <juri <at> linkov.net>, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 20 Aug 2021 21:29:47 +0200
[Message part 1 (text/plain, inline)]
20 aug. 2021 kl. 19.59 skrev Eli Zaretskii <eliz <at> gnu.org>:

> OK, but where in that patch is the NS-specific "Select" title that
> should be removed?

I'm not Juri, but the following patch removes the default "Select" title used by the NS port. Not sure why it was ever added -- perhaps something Gnustep-specific? Works well with Cocoa in any case.

[0001-Remove-default-Select-title-from-NS-popup-menus.patch (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 20 Aug 2021 23:33:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Mattias Engdegård <mattiase <at> acm.org>,
 Juri Linkov <juri <at> linkov.net>
Cc: tkk <at> misasa.okayama-u.ac.jp, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 50067 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 02:31:53 +0300
Hi Mattias!

On 20.08.2021 20:06, Mattias Engdegård wrote:
> * If I start emacs -Q and enable context-menu-mode, right-clicking on an identifier in an elisp buffer still doesn't produce the Find Definition entry, presumably because xref hasn't been loaded. Shouldn't it be arranged to be autoloaded somehow, which is how xref works when invoked by keystrokes?

I wonder what could be the reason for that. It would seem the menu 
should handle autoloaded commands fine. Even the visibility predicate 
should work: xref-find-backend is autoloaded as well.

Try rewriting it with a let, to ensure that xref-find-backend is called 
first:

(let ((backend (xref-find-backend)))
  (xref-backend-identifier-at-point backend))

> * `xref-make-match` requires (contrary to its doc string) its LOCATION argument to be of type `xref-file-location`, but some backends may only be able to make an `xref-buffer-location`. Would anyone object to changing the :location slot of `xref-match-item` to have type `xref-location`? I don't see how it could hurt.

Makes sense to me, seems like an accident. I've done this change 
locally, no obvious bugs fell out.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 04:45:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: Juri Linkov <juri <at> linkov.net>
Cc: Alan Third <alan <at> idiocy.org>,
 Mattias Engdegård <mattiase <at> acm.org>,
 Tak Kunihiro <homeros.misasa <at> gmail.com>,
 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 13:43:53 +0900
I’m new to 28 and it will take a while to adopt to it.
I’m sending comments so far.

* Binding

I suggest to assign [drag-mouse-3] as well, as shown below.

(define-key map [mouse-3] context-menu-entry)
(define-key map [drag-mouse-3] context-menu-entry)
 
On Mac, I suggest to assign [C-double-mouse-1] as well as shown below.

(define-key map [C-down-mouse-1] #'ignore)
(define-key map [C-mouse-1] context-menu-entry)
(define-key map [C-double-mouse-1] context-menu-entry)
(define-key map [C-triple-mouse-1] context-menu-entry)
(define-key map [C-drag-mouse-1] context-menu-entry)

* Error detection system

It is good if the context-menu system is ready for
an error that occurs on one of context-menu-functions.
For now, when there is error, Emacs only tells
`<mouse-3> is undefined'.

* Long click system

It’s time to discuss long-left-click also as trigger to
show context menu.

https://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00267.html
https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01277.html

* Open by other frame

File would be opened by this window. Sometimes I want to open it by
other frame.  It is good if which window to open, is selectable after
showing context-menu. I do not know how to do so.

* Details

It is handy to have buffer menu when right click mode bar.

(define-key map [remap buffer-menu-open] context-menu-entry)

Also it is handy to have frame menu when right click title bar.
I do not know how to do so.

Also it is nice to show word candidates by ispell when click a word.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 06:34:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <homeros.misasa <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Alan Third <alan <at> idiocy.org>,
 Mattias Engdegård <mattiase <at> acm.org>,
 Tak Kunihiro <homeros.misasa <at> gmail.com>, tkk <at> misasa.okayama-u.ac.jp,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 15:33:36 +0900
** context-menu-region

All commands belong to `Edit' in menu bar.
I think `context-menu-edit' sounds better.

Isn't it better to use `menu-bar-edit-menu' as a source rather than
create a menu from scratch?

On paste when there is a region and delete-selection-mode is t, the
region should be replaced by the text.

** no multiple horizontal lines

Sometimes I see double lines on the context menu.  I think that there is
no useful case to have double lines.  To allow only one horizontal line
would look cool.

** reuse existing menu

I cannot figure out how to include pre-existing menu such for
(mouse-buffer-menu-map).  To lean how to manipulate menu is not easy.
It's nice to have an example something like below (does not work).

  (defun context-menu-buffer (menu)
  "Add a buffer menu entry to MENU."
    (let ((map (mouse-buffer-menu-map)))
      (define-key-after menu [buffer] map))
    menu)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 09:44:02 GMT) Full text and rfc822 format available.

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

From: Alan Third <alan <at> idiocy.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Juri Linkov <juri <at> linkov.net>, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 10:42:44 +0100
On Fri, Aug 20, 2021 at 09:29:47PM +0200, Mattias Engdegård wrote:
> 20 aug. 2021 kl. 19.59 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> > OK, but where in that patch is the NS-specific "Select" title that
> > should be removed?
> 
> I'm not Juri, but the following patch removes the default "Select"
> title used by the NS port. Not sure why it was ever added -- perhaps
> something Gnustep-specific? Works well with Cocoa in any case.

GNUstep, and I believe NEXTstep and old school macOS, allows you to
"tear off" menus and leave them on screen as sort of custom toolbars.
Hence the title on each menu.

Emacs doesn't support this with the main menus (it was the source of a
crash, so I removed it), but I don't know if it's something we should
support. I suspect not because once Emacs updates the menus it
probably can't handle clicks on old ones.
-- 
Alan Third




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 10:58:01 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Alan Third <alan <at> idiocy.org>
Cc: Juri Linkov <juri <at> linkov.net>, Tak Kunihiro <homeros.misasa <at> gmail.com>,
 tkk <at> misasa.okayama-u.ac.jp, Lars Ingebrigtsen <larsi <at> gnus.org>,
 50067 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 12:57:23 +0200
(Reply to multiple messages)

21 aug. 2021 kl. 11.42 skrev Alan Third <alan <at> idiocy.org>:

> GNUstep, and I believe NEXTstep and old school macOS, allows you to
> "tear off" menus and leave them on screen as sort of custom toolbars.
> Hence the title on each menu.
> 
> Emacs doesn't support this with the main menus (it was the source of a
> crash, so I removed it), but I don't know if it's something we should
> support. I suspect not because once Emacs updates the menus it
> probably can't handle clicks on old ones.

Thank you, I pushed the removal of the default "Select" title: titles will still be there if given explicitly. If this causes trouble for Gnustep, then we'll reinsert the default title for that platform only.

21 aug. 2021 kl. 01.31 skrev Dmitry Gutov <dgutov <at> yandex.ru>:

>> * If I start emacs -Q and enable context-menu-mode, right-clicking on an identifier in an elisp buffer still doesn't produce the Find Definition entry, presumably because xref hasn't been loaded. Shouldn't it be arranged to be autoloaded somehow, which is how xref works when invoked by keystrokes?
> 
> I wonder what could be the reason for that. It would seem the menu should handle autoloaded commands fine. Even the visibility predicate should work: xref-find-backend is autoloaded as well.

It was just a (featurep 'xref) test which didn't seem to be needed; as you say, all the functions involved are autoloaded and I have verified that xref will indeed be loaded when the menu is used the first time. Pushed to master.

>> * `xref-make-match` requires (contrary to its doc string) its LOCATION argument to be of type `xref-file-location`, but some backends may only be able to make an `xref-buffer-location`. Would anyone object to changing the :location slot of `xref-match-item` to have type `xref-location`? I don't see how it could hurt.
> 
> Makes sense to me, seems like an accident. I've done this change locally, no obvious bugs fell out.

Thank you, fixed on master.

Also pushed:

* Previous patch that adds "Find References" to the menu; it seemed to be the right thing to do.
* A fringe arrow is now used to indicate the current position in the *xref* buffer
* Messages added to assuage the boredom of users while searching for references. Could be moved, rephrased, made optional or removed altogether, but it did look a lot better than freezing for a long time.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 11:18:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 14:17:06 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Sat, 21 Aug 2021 12:57:23 +0200
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>,
>         50067 <at> debbugs.gnu.org, Tak Kunihiro <homeros.misasa <at> gmail.com>,
>         tkk <at> misasa.okayama-u.ac.jp, Lars Ingebrigtsen <larsi <at> gnus.org>
> 
> (Reply to multiple messages)
> 
> * A fringe arrow is now used to indicate the current position in the *xref* buffer

I think it may be confusing that the arrow doesn't appear immediately
after M-., only when you switch from the XREF buffer.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 11:46:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 13:45:08 +0200
21 aug. 2021 kl. 13.17 skrev Eli Zaretskii <eliz <at> gnu.org>:

> I think it may be confusing that the arrow doesn't appear immediately
> after M-., only when you switch from the XREF buffer.

I don't quite follow -- M-. typically doesn't create an *xref* buffer at all; when it does, it does not follow any of the matches found therein.

The arrow indicates the latest match reference that has been followed to its target, in the same way as in compile, grep and occur buffers. In neither of these buffers the arrow appears immediately.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 21 Aug 2021 12:18:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sat, 21 Aug 2021 15:16:59 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Sat, 21 Aug 2021 13:45:08 +0200
> Cc: alan <at> idiocy.org, juri <at> linkov.net, 50067 <at> debbugs.gnu.org,
>         homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org
> 
> 21 aug. 2021 kl. 13.17 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> > I think it may be confusing that the arrow doesn't appear immediately
> > after M-., only when you switch from the XREF buffer.
> 
> I don't quite follow -- M-. typically doesn't create an *xref* buffer at all; when it does, it does not follow any of the matches found therein.

Oh, so it's only appearing when the tag is shown?  Confusing... but I
guess we will have to live with that.

> The arrow indicates the latest match reference that has been followed to its target, in the same way as in compile, grep and occur buffers. In neither of these buffers the arrow appears immediately.

Got it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 22 Aug 2021 08:40:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 Tak Kunihiro <homeros.misasa <at> gmail.com>, 50067 <at> debbugs.gnu.org,
 Lars Ingebrigtsen <larsi <at> gnus.org>, Alan Third <alan <at> idiocy.org>
Subject: Re: bug#50067: Context menus
Date: Sun, 22 Aug 2021 11:28:02 +0300
> I’m new to 28 and it will take a while to adopt to it.
> I’m sending comments so far.

Thanks for the comments.

> * Binding
>
> I suggest to assign [drag-mouse-3] as well, as shown below.
>
> (define-key map [mouse-3] context-menu-entry)
> (define-key map [drag-mouse-3] context-menu-entry)

There is no need to bind [drag-mouse-3] because [down-mouse-3] is bound.

> On Mac, I suggest to assign [C-double-mouse-1] as well as shown below.
>
> (define-key map [C-down-mouse-1] #'ignore)
> (define-key map [C-mouse-1] context-menu-entry)
> (define-key map [C-double-mouse-1] context-menu-entry)
> (define-key map [C-triple-mouse-1] context-menu-entry)
> (define-key map [C-drag-mouse-1] context-menu-entry)

I leave this for the users of Mac to decide what would be better on Mac.

> * Error detection system
>
> It is good if the context-menu system is ready for
> an error that occurs on one of context-menu-functions.
> For now, when there is error, Emacs only tells
> `<mouse-3> is undefined'.

I agree, a better error reporting would be nice.  Patches welcome.

> * Long click system
>
> It’s time to discuss long-left-click also as trigger to
> show context menu.
>
> https://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00267.html
> https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01277.html

I tried to implement this, but soon found that long-left-click is unusable,
because such artificial delay is a hassle - no one would have
patience to wait even half a second until the menu finally appears.
But this could be implemented anyway when users will demand this.

> * Open by other frame
>
> File would be opened by this window. Sometimes I want to open it by
> other frame.  It is good if which window to open, is selectable after
> showing context-menu. I do not know how to do so.

Sorry, I don't understand what menu do you mean, maybe in Dired mode?

> * Details
>
> It is handy to have buffer menu when right click mode bar.

I don't see where buffer-menu-open currently is used on the mode-line.

> (define-key map [remap buffer-menu-open] context-menu-entry)

This gives the error "void-variable map".

> Also it is handy to have frame menu when right click title bar.

I think this is a good idea.

> I do not know how to do so.

I do not know how to do this for the frame title bar.
But currently I'm doing this for the tab bar.

> Also it is nice to show word candidates by ispell when click a word.

Maybe like flyspell-mode?

> ** context-menu-region
>
> All commands belong to `Edit' in menu bar.
> I think `context-menu-edit' sounds better.

I already tried to use your idea to name it `context-menu-edit'.
But the problem is that other functions like context-menu-undo are also
related to editing.  OTOH, some items in context-menu-region don't do
editing such as "Select All" is not editing, "Copy" is not editing, etc.

> Isn't it better to use `menu-bar-edit-menu' as a source rather than
> create a menu from scratch?

I already tried this idea but this menu is already available
in the global menu that already can be enabled by adding
context-menu-global to context-menu-functions.
But maybe `context-menu-edit' could be added as well
from `menu-bar-edit-menu'.

> On paste when there is a region and delete-selection-mode is t, the
> region should be replaced by the text.

Please explain how the region should be replaced by the text,
when mouse-yank-at-click or mouse-yank-primary is used
to paste where the mouse is clicked.  Should it delete the region
and paste where mouse is clicked on another part of the buffer?
What if the mouse is clicked in another window?

> ** no multiple horizontal lines
>
> Sometimes I see double lines on the context menu.  I think that there is
> no useful case to have double lines.  To allow only one horizontal line
> would look cool.

Right, double separators should be removed.

> ** reuse existing menu
>
> I cannot figure out how to include pre-existing menu such for
> (mouse-buffer-menu-map).  To lean how to manipulate menu is not easy.
> It's nice to have an example something like below (does not work).
>
>   (defun context-menu-buffer (menu)
>   "Add a buffer menu entry to MENU."
>     (let ((map (mouse-buffer-menu-map)))
>       (define-key-after menu [buffer] map))
>     menu)

Adding the existing menu is not easy.  There are some examples in
context-menu-global, context-menu-local, context-menu-minor.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 22 Aug 2021 08:48:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 22 Aug 2021 11:46:53 +0300
>> >> Using a text property would be a good solution.  Should then
>> >> the NS-specific "Select" title be removed in menu.c
>> >> when the title has a special text property?
>> >
>> > I'm not sure I understand what is the NS-specific "Select" title.  Can
>> > you point me to the relevant code?
>> 
>> I meant such patch:
>
> OK, but where in that patch is the NS-specific "Select" title that
> should be removed?

Mattias pushed the NS-specific patch, and I pushed the text property handling.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 22 Aug 2021 19:12:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>, Mattias Engdegård
 <mattiase <at> acm.org>
Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 22 Aug 2021 22:11:03 +0300
On 21.08.2021 15:16, Eli Zaretskii wrote:
>>> I think it may be confusing that the arrow doesn't appear immediately
>>> after M-., only when you switch from the XREF buffer.
>> I don't quite follow -- M-. typically doesn't create an*xref*  buffer at all; when it does, it does not follow any of the matches found therein.
> Oh, so it's only appearing when the tag is shown?  Confusing... but I
> guess we will have to live with that.
> 

What is confusing? We do the same in Grep and Compilation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 22 Aug 2021 19:23:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 22 Aug 2021 22:22:01 +0300
> Cc: alan <at> idiocy.org, juri <at> linkov.net, homeros.misasa <at> gmail.com,
>  tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Sun, 22 Aug 2021 22:11:03 +0300
> 
> On 21.08.2021 15:16, Eli Zaretskii wrote:
> >>> I think it may be confusing that the arrow doesn't appear immediately
> >>> after M-., only when you switch from the XREF buffer.
> >> I don't quite follow -- M-. typically doesn't create an*xref*  buffer at all; when it does, it does not follow any of the matches found therein.
> > Oh, so it's only appearing when the tag is shown?  Confusing... but I
> > guess we will have to live with that.
> > 
> 
> What is confusing?

What I described.

> We do the same in Grep and Compilation.

That's not exactly the same, because with M-. I already asked to show
me a definition.  Anyway, not worth an argument.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 22 Aug 2021 19:56:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 22 Aug 2021 22:54:57 +0300
On 22.08.2021 22:22, Eli Zaretskii wrote:
> That's not exactly the same, because with M-. I already asked to show
> me a definition.  Anyway, not worth an argument.

Perhaps your complaint is instead about no definition being shown, even 
though you feel like you already asked Emacs to show one (which the 
fileloop UI does).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 02:22:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 05:21:05 +0300
> Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
>  homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>  50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Sun, 22 Aug 2021 22:54:57 +0300
> 
> On 22.08.2021 22:22, Eli Zaretskii wrote:
> > That's not exactly the same, because with M-. I already asked to show
> > me a definition.  Anyway, not worth an argument.
> 
> Perhaps your complaint is instead about no definition being shown, even 
> though you feel like you already asked Emacs to show one (which the 
> fileloop UI does).

Yes.  But that ship has sailed long ago.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 03:12:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: Juri Linkov <juri <at> linkov.net>
Cc: Alan Third <alan <at> idiocy.org>,
 Mattias Engdegård <mattiase <at> acm.org>,
 国広卓也 <tkk <at> misasa.okayama-u.ac.jp>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 50067 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 12:11:27 +0900
>> I suggest to assign [drag-mouse-3] as well, as shown below.
>> 
>> (define-key map [mouse-3] context-menu-entry)
>> (define-key map [drag-mouse-3] context-menu-entry)
> 
> There is no need to bind [drag-mouse-3] because [down-mouse-3] is bound.

I confirmed. I took the suggestion back.

>> On Mac, I suggest to assign [C-double-mouse-1] as well as shown below.
>> 
>> (define-key map [C-down-mouse-1] #'ignore)
>> (define-key map [C-mouse-1] context-menu-entry)
>> (define-key map [C-double-mouse-1] context-menu-entry)
>> (define-key map [C-triple-mouse-1] context-menu-entry)
>> (define-key map [C-drag-mouse-1] context-menu-entry)
> 
> I leave this for the users of Mac to decide what would be better on Mac.

I agree.  User can bind it later too.

>> * Error detection system
>> 
>> It is good if the context-menu system is ready for
>> an error that occurs on one of context-menu-functions.
>> For now, when there is error, Emacs only tells
>> `<mouse-3> is undefined'.
> 
> I agree, a better error reporting would be nice.  Patches welcome.

This is something I wanted to have for a long time.  I do not have
idea where to start. I hope someone works on this using this opportunity.

>> * Long click system
>> 
>> It’s time to discuss long-left-click also as trigger to
>> show context menu.
>> 
>> https://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00267.html
>> https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg01277.html
> 
> I tried to implement this, but soon found that long-left-click is unusable,
> because such artificial delay is a hassle - no one would have
> patience to wait even half a second until the menu finally appears.
> But this could be implemented anyway when users will demand this.

I think this is useful especially on laptop computer with Mac.
As inferred on other posts laptop computer with Mac does not have
mouse-3.  However, it is possible that I’m the only one.

>> * Open by other frame
>> 
>> File would be opened by this window. Sometimes I want to open it by
>> other frame.  It is good if which window to open, is selectable after
>> showing context-menu. I do not know how to do so.
> 
> Sorry, I don't understand what menu do you mean, maybe in Dired mode?

`ffap-at-mouse’ will open a file under pointer on `this window’.
Randomly I want to open it by `other frame’.
It’s good if I can choose open the file on `this window’ or `other frame’.
Is there a way to detect meta key pressed when select one of menu items?

>> * Details
>> 
>> It is handy to have buffer menu when right click mode bar.
> 
> I don't see where buffer-menu-open currently is used on the mode-line.
>> (define-key map [remap buffer-menu-open] context-menu-entry)
> 
> This gives the error "void-variable map".


This suggestion may be unrelated to context-menu.
On mode bar, both mouse-1 and mouse-3 switches buffer. 
I think mouse-3 should show something like (mouse-buffer-menu-map).

>> Also it is handy to have frame menu when right click title bar.
> 
> I think this is a good idea.
> 
>> I do not know how to do so.
> 
> I do not know how to do this for the frame title bar.
> But currently I'm doing this for the tab bar.

OK.

>> Also it is nice to show word candidates by ispell when click a word.
> 
> Maybe like flyspell-mode?

I have an idea. Possibly, send patch in the future.

>> ** context-menu-region
>> 
>> All commands belong to `Edit' in menu bar.
>> I think `context-menu-edit' sounds better.
> 
> I already tried to use your idea to name it `context-menu-edit'.
> But the problem is that other functions like context-menu-undo are also
> related to editing.  OTOH, some items in context-menu-region don't do
> editing such as "Select All" is not editing, "Copy" is not editing, etc.
> 

>> Isn't it better to use `menu-bar-edit-menu' as a source rather than
>> create a menu from scratch?
> 
> I already tried this idea but this menu is already available
> in the global menu that already can be enabled by adding
> context-menu-global to context-menu-functions.
> But maybe `context-menu-edit' could be added as well
> from `menu-bar-edit-menu'.


OK.  I only wanted to suggest reducing maintenance cost.

> 
>> On paste when there is a region and delete-selection-mode is t, the
>> region should be replaced by the text.
> 
> Please explain how the region should be replaced by the text,
> when mouse-yank-at-click or mouse-yank-primary is used
> to paste where the mouse is clicked.  Should it delete the region
> and paste where mouse is clicked on another part of the buffer?
> What if the mouse is clicked in another window?

When there is a region and yank text by `C-y’, the text would
be replaced.

I think when there is a region and point in on region, region
should be replaced by text.  No?

>> ** no multiple horizontal lines
>> 
>> Sometimes I see double lines on the context menu.  I think that there is
>> no useful case to have double lines.  To allow only one horizontal line
>> would look cool.
> 
> Right, double separators should be removed.

OK.

>> ** reuse existing menu
>> 
>> I cannot figure out how to include pre-existing menu such for
>> (mouse-buffer-menu-map).  To lean how to manipulate menu is not easy.
>> It's nice to have an example something like below (does not work).
>> 
>>  (defun context-menu-buffer (menu)
>>  "Add a buffer menu entry to MENU."
>>    (let ((map (mouse-buffer-menu-map)))
>>      (define-key-after menu [buffer] map))
>>    menu)
> 
> Adding the existing menu is not easy.  There are some examples in
> context-menu-global, context-menu-local, context-menu-minor.

OK.  I did not know it is not easy.
I cannot find guid line how the menu should be created.
Do you know where to look?







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 07:39:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 Alan Third <alan <at> idiocy.org>, 50067 <at> debbugs.gnu.org,
 Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 10:24:22 +0300
>> I tried to implement this, but soon found that long-left-click is unusable,
>> because such artificial delay is a hassle - no one would have
>> patience to wait even half a second until the menu finally appears.
>> But this could be implemented anyway when users will demand this.
>
> I think this is useful especially on laptop computer with Mac.
> As inferred on other posts laptop computer with Mac does not have
> mouse-3.  However, it is possible that I’m the only one.

Recently Mattias bound C-mouse-1 to use instead of mouse-3 on Mac.

> `ffap-at-mouse’ will open a file under pointer on `this window’.
> Randomly I want to open it by `other frame’.
> It’s good if I can choose open the file on `this window’ or `other frame’.
> Is there a way to detect meta key pressed when select one of menu items?

There is no way to detect meta key.  But you can create a new command
to open in a new frame, and add this command to the menu.  Or use
the existing `ffap-other-frame'.

>>> It is handy to have buffer menu when right click mode bar.
>
> This suggestion may be unrelated to context-menu.
> On mode bar, both mouse-1 and mouse-3 switches buffer. 
> I think mouse-3 should show something like (mouse-buffer-menu-map).

Yes, this would be useful.

>>> On paste when there is a region and delete-selection-mode is t, the
>>> region should be replaced by the text.
>> 
>> Please explain how the region should be replaced by the text,
>> when mouse-yank-at-click or mouse-yank-primary is used
>> to paste where the mouse is clicked.  Should it delete the region
>> and paste where mouse is clicked on another part of the buffer?
>> What if the mouse is clicked in another window?
>
> When there is a region and yank text by `C-y’, the text would
> be replaced.
>
> I think when there is a region and point in on region, region
> should be replaced by text.  No?

mouse-yank-at-click is intended to paste where you click.
So when there is a region, and you click mouse-3 at some other position
where you want to paste, and select "Paste" from the context-menu,
it's unclear what to do with the region.  It makes no sense
to delete the region, when you paste at the clicked position
outside of the region, but not on the region.

Please see more in mouse-yank-at-click and mouse-yank-primary
that contain such comment about the need to deactivate the region:

  ;; Without this, confusing things happen upon e.g. inserting into
  ;; the middle of an active region.
  (when select-active-regions
    (let (select-active-regions)
      (deactivate-mark)))

>>> I cannot figure out how to include pre-existing menu such for
>>> (mouse-buffer-menu-map).

Actually, the right function to use is (mouse-buffer-menu-keymap)
instead of (mouse-buffer-menu-map).

> I cannot find guid line how the menu should be created.
> Do you know where to look?

Good documentation is in (info "(elisp) Defining Menus").




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 11:20:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 14:18:56 +0300
On 23.08.2021 05:21, Eli Zaretskii wrote:
> Yes.  But that ship has sailed long ago.

Only if the chief maintainer thinks that the UI must be frozen in time.

We could add an option, at the very least.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 11:42:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 14:40:38 +0300
> Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
>  homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>  50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Mon, 23 Aug 2021 14:18:56 +0300
> 
> On 23.08.2021 05:21, Eli Zaretskii wrote:
> > Yes.  But that ship has sailed long ago.
> 
> Only if the chief maintainer thinks that the UI must be frozen in time.
> 
> We could add an option, at the very least.

An option to display the first match right away will be most
appreciated, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 23 Aug 2021 16:08:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, Dmitry Gutov <dgutov <at> yandex.ru>, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 23 Aug 2021 19:02:19 +0300
>> We could add an option, at the very least.
>
> An option to display the first match right away will be most
> appreciated, thanks.

Like compilation-auto-jump-to-first-error.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 24 Aug 2021 10:14:02 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: juri <at> linkov.net
Cc: mattiase <at> acm.org, alan <at> idiocy.org, 50067 <at> debbugs.gnu.org, larsi <at> gnus.org,
 tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Tue, 24 Aug 2021 19:12:59 +0900 (JST)
I started to understand the system.
A plug-in to list frames would be something like this.
I think it is good to have interface to basic utilities such for
recentf and bookmarks.

(defun context-menu-frame (menu)
  "Add MENU a list of frames."
  (let (frame-map)
    (dolist (frame (visible-frame-list))
      (let ((nickname (cdr (assoc 'name (frame-parameters frame))))
            (cmd `(lambda nil (interactive) (funcall 'menu-bar-select-frame ,frame))))
        (push (vector nickname cmd :active (not (equal frame (selected-frame)))) frame-map)))
    (push ["--" ignore] frame-map)
    (push ["New" make-frame-command] frame-map)
    (setq frame-map (reverse frame-map))
    (push "Frames" frame-map)
    (easy-menu-add-item menu nil frame-map)
    menu))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 24 Aug 2021 17:26:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: mattiase <at> acm.org, alan <at> idiocy.org, 50067 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#50067: Context menus
Date: Tue, 24 Aug 2021 20:23:48 +0300
> I started to understand the system.
> A plug-in to list frames would be something like this.
> I think it is good to have interface to basic utilities such for
> recentf and bookmarks.
>
> (defun context-menu-frame (menu)

There are endless possibilities in creating various submenus.
So the default set of submenus is limited only to already existing menus:

context-menu-toolbar copied from the tool-bar
context-menu-global copied from the global menu-bar
context-menu-local copied from the local menu-bar
context-menu-minor copied from the minor-modes menu-bar
context-menu-vc copied from the vc menu
context-menu-undo copied from the Edit menu
context-menu-region copied from the Edit menu

So if you can find an existing menu, it could be added.
But I can't find the existing menu with a list of frames.
There are only the existing menu with a list of buffers
like you proposed (mouse-buffer-menu-map) from [C-down-mouse-1],
but better to use (mouse-buffer-menu-keymap),
so now context-menu-buffers is added to the default list.

The remaining existing menu is 'mouse-appearance-menu' bound to
[S-down-mouse-1].  I don't know if it's significant enough
to be added to the default list?

Also you proposed a good idea to have a frame menu when
right clicking on the title bar.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 24 Aug 2021 18:00:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 24 Aug 2021 20:59:40 +0300
[Message part 1 (text/plain, inline)]
On 23.08.2021 19:02, Juri Linkov wrote:
>>> We could add an option, at the very least.
>> An option to display the first match right away will be most
>> appreciated, thanks.
> Like compilation-auto-jump-to-first-error.

So we even have a precedent, very good.

Could you both check out the attached patch?

Together with (setq xref-auto-jump-to-first-definition t)

Questions for feedback:

1. Does the new behavior work okay window management-wise (it does 
occupy +1 window, after all)?

2. Should this setting also extend to other commands like 
xref-find-references? Asking for personal preferences here.
[xref-auto-jump-to-first-definition.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 24 Aug 2021 23:44:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
To: juri <at> linkov.net
Cc: mattiase <at> acm.org, alan <at> idiocy.org, 50067 <at> debbugs.gnu.org, larsi <at> gnus.org,
 tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Wed, 25 Aug 2021 08:43:29 +0900 (JST)
* flyspell menu

It is handy to show 'flyspell-correct-word when click on typo word.
However, menu is embedded inside of pre existing
'flyspell-correct-word and it is hard to collect menu.  Since
popup-menu interface can accept both menu and function with `e', it's
good to utilize 'flyspell-correct-word.

How about something like below to interrupt evaluation of
context-menu-functions in the middle when one of
context-menu-functions returns symbol instead of menu?

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 6332d9fcec..23f0dda3e8 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -308,7 +308,7 @@ context-menu-map
     (run-hook-wrapped 'context-menu-functions
                       (lambda (fun)
                         (setq menu (funcall fun menu))
-                        nil))
+                        (not (keymapp menu))))
     (when (functionp context-menu-filter-function)
       (setq menu (funcall context-menu-filter-function menu)))
     menu))

Then function something below will pop word choices.

(defun context-menu-spell (menu)
  "Return 'flyspell-correct-word when word under mouse click is incorrect."
  (let ((faces-at-point (mapcar (lambda (xxx) (overlay-get xxx 'face))
                                (overlays-at (posn-point (event-start last-input-event))))))
    (if (or (member 'flyspell-incorrect faces-at-point)
            (member 'flyspell-duplicate faces-at-point))
        #'flyspell-correct-word
      menu)))

(setq context-menu-functions '(context-menu-spell ;; flyspell
                               context-menu-undo
                               context-menu-region
                               context-menu-local
                               context-menu-minor))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 25 Aug 2021 14:16:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 25 Aug 2021 17:15:28 +0300
On 24.08.2021 20:59, Dmitry Gutov wrote:
> 
> Together with (setq xref-auto-jump-to-first-definition t)
> 
> Questions for feedback:
> 
> 1. Does the new behavior work okay window management-wise (it does 
> occupy +1 window, after all)?
> 
> 2. Should this setting also extend to other commands like 
> xref-find-references? Asking for personal preferences here.

Eli?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 25 Aug 2021 16:01:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 25 Aug 2021 18:59:59 +0300
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
>  tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
> Date: Wed, 25 Aug 2021 17:15:28 +0300
> 
> On 24.08.2021 20:59, Dmitry Gutov wrote:
> > 
> > Together with (setq xref-auto-jump-to-first-definition t)
> > 
> > Questions for feedback:
> > 
> > 1. Does the new behavior work okay window management-wise (it does 
> > occupy +1 window, after all)?
> > 
> > 2. Should this setting also extend to other commands like 
> > xref-find-references? Asking for personal preferences here.
> 
> Eli?

Sorry, I didn't yet have time to try this; will do tomorrow.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 25 Aug 2021 17:49:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 25 Aug 2021 20:45:20 +0300
> * flyspell menu
>
> It is handy to show 'flyspell-correct-word when click on typo word.
> However, menu is embedded inside of pre existing
> 'flyspell-correct-word and it is hard to collect menu.  Since
> popup-menu interface can accept both menu and function with `e', it's
> good to utilize 'flyspell-correct-word.
>
> How about something like below to interrupt evaluation of
> context-menu-functions in the middle when one of
> context-menu-functions returns symbol instead of menu?

Thanks, adapting flyspell to use the context menu is our next priority.
But it seems interrupting evaluation is too hackish solution, and it still
uses x-popup-menu.  Would it be possible for flyspell to put its context
function to the end of context-menu-functions, and then replace all
previously added menus with own menu that contains word corrections?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 26 Aug 2021 06:19:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 26 Aug 2021 09:13:10 +0300
[Message part 1 (text/plain, inline)]
>> * flyspell menu
>>
>> It is handy to show 'flyspell-correct-word when click on typo word.
>> However, menu is embedded inside of pre existing
>> 'flyspell-correct-word and it is hard to collect menu.  Since
>> popup-menu interface can accept both menu and function with `e', it's
>> good to utilize 'flyspell-correct-word.
>>
>> How about something like below to interrupt evaluation of
>> context-menu-functions in the middle when one of
>> context-menu-functions returns symbol instead of menu?
>
> Thanks, adapting flyspell to use the context menu is our next priority.
> But it seems interrupting evaluation is too hackish solution, and it still
> uses x-popup-menu.  Would it be possible for flyspell to put its context
> function to the end of context-menu-functions, and then replace all
> previously added menus with own menu that contains word corrections?

Here is the first step that adds support for overlay-local context-menu,
and removes the recently added 'flyspell-use-mouse-3-for-menu'.
But 'flyspell-context-menu' still returns 'flyspell-correct-word'.

I invite you or anyone else to refactor 'flyspell-correct-word' and
related functions to return a keymap menu where every menu item
is bound to a function that calls flyspell-do-correct with an argument
that is a correct word.

[flyspell-context-menu.patch (text/x-diff, inline)]
diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi
index b558ebc3fd..85cdbff5fa 100644
--- a/doc/emacs/fixit.texi
+++ b/doc/emacs/fixit.texi
@@ -462,10 +462,9 @@ Spelling
   When Flyspell mode highlights a word as misspelled, you can click on
 it with @kbd{mouse-2} (@code{flyspell-correct-word}) to display a menu
 of possible corrections and actions.  If you want this menu on
-@kbd{mouse-3} instead, customize the variable
-@code{flyspell-use-mouse-3-for-menu}.  In addition, @kbd{C-.} or
-@kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word}) will
-propose various successive corrections for the word at point, and
+@kbd{mouse-3} instead, enable @code{context-menu-mode}.  In addition,
+@kbd{C-.} or @kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word})
+will propose various successive corrections for the word at point, and
 @w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop
 up a menu of possible corrections.  Of course, you can always correct
 the misspelled word by editing it manually in any way you like.
diff --git a/etc/NEWS b/etc/NEWS
index 04e482364a..a6d9b3a8b8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2889,8 +2893,7 @@ like 'flymake-mode-line-error-counter',
 When Flyspell mode highlights a word as misspelled, you can click on
 it to display a menu of possible corrections and actions.  You can now
 easily bind this menu to 'down-mouse-3' (usually the right mouse button)
-instead of 'mouse-2' (the default) by customizing the new user option
-'flyspell-use-mouse-3-for-menu'.
+instead of 'mouse-2' (the default) by enabling 'context-menu-mode'.
 
 ---
 *** The current dictionary is now displayed in the minor mode lighter.
diff --git a/lisp/mouse.el b/lisp/mouse.el
index d137419e02..f52fb3f6ba 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -307,10 +307,15 @@ context-menu-filter-function
 (defun context-menu-map ()
   "Return composite menu map."
   (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))))
-    (run-hook-wrapped 'context-menu-functions
-                      (lambda (fun)
-                        (setq menu (funcall fun menu))
-                        nil))
+    (let ((fun (mouse-posn-property (event-start last-input-event)
+                                    'context-menu-function)))
+      (if (functionp fun)
+          (setq menu (funcall fun menu))
+        (run-hook-wrapped 'context-menu-functions
+                          (lambda (fun)
+                            (setq menu (funcall fun menu))
+                            nil))))
+    ;; TODO: remove double separators
     (when (functionp context-menu-filter-function)
       (setq menu (funcall context-menu-filter-function menu)))
     menu))
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 836d889a1c..c05be9655f 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -442,22 +442,6 @@ flyspell-mode-map
     map)
   "Minor mode keymap for Flyspell mode--for the whole buffer.")
 
-;; correct on mouse 3
-(defun flyspell--set-use-mouse-3-for-menu (var value)
-  (set-default var value)
-  (if value
-      (progn (define-key flyspell-mouse-map [mouse-2] nil)
-             (define-key flyspell-mouse-map [down-mouse-3] 'flyspell-correct-word))
-    (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word)
-    (define-key flyspell-mouse-map [down-mouse-3] nil)))
-
-(defcustom flyspell-use-mouse-3-for-menu nil
-  "Non-nil means to bind `mouse-3' to `flyspell-correct-word'.
-If this is set, also unbind `mouse-2'."
-  :type 'boolean
-  :set 'flyspell--set-use-mouse-3-for-menu
-  :version "28.1")
-
 ;; dash character machinery
 (defvar-local flyspell-consider-dash-as-word-delimiter-flag nil
   "Non-nil means that the `-' char is considered as a word delimiter.")
@@ -486,6 +470,10 @@ flyspell-duplicate
 
 (defvar flyspell-overlay nil)
 
+(defun flyspell-context-menu (_menu)
+  "Context menu for `context-menu-mode'."
+  'flyspell-correct-word)
+
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-mode ...                                                */
 ;;*---------------------------------------------------------------------*/
@@ -537,10 +525,7 @@ flyspell-mode
   :group 'flyspell
   (if flyspell-mode
       (condition-case err
-          (progn
-            (when flyspell-use-mouse-3-for-menu
-              (flyspell--set-use-mouse-3-for-menu 'flyspell-use-mouse-3-for-menu t))
-            (flyspell-mode-on (called-interactively-p 'interactive)))
+	  (flyspell-mode-on (called-interactively-p 'interactive))
 	(error (message "Error enabling Flyspell mode:\n%s" (cdr err))
 	       (flyspell-mode -1)))
     (flyspell-mode-off)))
@@ -656,8 +641,7 @@ flyspell-mode-on
            show-msg)
       (let* ((binding (where-is-internal 'flyspell-auto-correct-word
                                          nil 'non-ascii))
-             (mouse-button (if flyspell-use-mouse-3-for-menu
-                               "Mouse-3" "Mouse-2")))
+             (mouse-button (if context-menu-mode "Mouse-3" "Mouse-2")))
         (message (format-message
                   "Welcome to Flyspell. Use %s to correct words."
                   (if binding
@@ -1820,13 +1804,15 @@ make-flyspell-overlay
     (overlay-put overlay 'mouse-face mouse-face)
     (overlay-put overlay 'flyspell-overlay t)
     (overlay-put overlay 'evaporate t)
-    (overlay-put overlay 'help-echo (concat (if flyspell-use-mouse-3-for-menu
-                                                "mouse-3"
-                                              "mouse-2") ": correct word at point"))
-    ;; If misspelled text has a 'keymap' property, let that remain in
-    ;; effect for the bindings that flyspell-mouse-map doesn't override.
-    (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap))
-    (overlay-put overlay 'keymap flyspell-mouse-map)
+    (overlay-put overlay 'help-echo
+                 (concat (if context-menu-mode "mouse-3" "mouse-2")
+                         ": correct word at point"))
+    (if context-menu-mode
+        (overlay-put overlay 'context-menu-function 'flyspell-context-menu)
+      ;; If misspelled text has a 'keymap' property, let that remain in
+      ;; effect for the bindings that flyspell-mouse-map doesn't override.
+      (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap))
+      (overlay-put overlay 'keymap flyspell-mouse-map))
     (when (eq face 'flyspell-incorrect)
       (and (stringp flyspell-before-incorrect-word-string)
            (overlay-put overlay 'before-string

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 26 Aug 2021 13:02:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 26 Aug 2021 16:01:00 +0300
> Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
>  tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Tue, 24 Aug 2021 20:59:40 +0300
> 
> >> An option to display the first match right away will be most
> >> appreciated, thanks.
> > Like compilation-auto-jump-to-first-error.
> 
> So we even have a precedent, very good.
> 
> Could you both check out the attached patch?
> 
> Together with (setq xref-auto-jump-to-first-definition t)

Thanks, this looks very handy, I will definitely use it.

> Questions for feedback:
> 
> 1. Does the new behavior work okay window management-wise (it does 
> occupy +1 window, after all)?

Not sure I understand the question: we pop up an additional window
when there are more than one candidate even without this option, so
why do you say "+1 window"?  Maybe you had some recipe in mind that I
didn't try?

> 2. Should this setting also extend to other commands like 
> xref-find-references?

Not necessarily.  Perhaps xref-auto-jump-to-first-definition should be
tri-state, to allow users to request the same with
xref-find-references as well?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 26 Aug 2021 21:06:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 27 Aug 2021 00:05:39 +0300
On 26.08.2021 16:01, Eli Zaretskii wrote:
>> Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
>>   tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
>> From: Dmitry Gutov <dgutov <at> yandex.ru>
>> Date: Tue, 24 Aug 2021 20:59:40 +0300
>>
>>>> An option to display the first match right away will be most
>>>> appreciated, thanks.
>>> Like compilation-auto-jump-to-first-error.
>>
>> So we even have a precedent, very good.
>>
>> Could you both check out the attached patch?
>>
>> Together with (setq xref-auto-jump-to-first-definition t)
> 
> Thanks, this looks very handy, I will definitely use it.

Very good. Let's now discuss a couple of minor alterations. We can 
always go back to this patch if we don't decide on anything better.

I think I remember now why it didn't make sense to me to have this 
behavior OOTB: I think the main goal of the user who calls 
xref-find-definitions is, usually, to pick one definition they wanted to 
visit. Which also means having the xref buffer dismissed at the end.

With the patch under discussion we automatically jump to the first 
location. We can even iterate through locations with 
next-error/previous-error (M-g M-n/M-g M-p). But to close 
(quit/kill/etc) the list of locations, you have to switch back to its 
window and press 'q'. Didn't that look like a bother to you?

Here's how it could look instead:

1. When you press M-., the first location is "shown", but not jumped to. 
The focus remains on the Xref window, with point on its first item (the 
arrow beside it is visible, like you wanted). Location is visible in the 
other window, and we can either visit it and dismiss the Xref buffer 
(with 'C-u RET'), simply visit it with 'RET', or look at the other 
locations with 'n'/'p'.

For this to work, the patch will need to change xref--auto-jump-first, 
swapping

+  (xref-next-line-no-show)
+  (xref-goto-xref))

for

+  (xref-next-line)

The new option's name would probably be different too.

And you could also use a "transient" show-definitions-function like:

(setq xref-show-definitions-function
      #'xref-show-definitions-buffer-at-bottom)

Then you'd only need to press RET in the results buffer to jump and 
dismiss the results buffer.

2. Simply have point move to the first location in the list (rather than 
remain on the group name). From there, the user can press 'C-o' to show 
the location without visiting, or 'RET', or 'C-u RET' like described 
above. I understand this does not fit your prior workflows, but it does 
require the least number of button presses in the scenario "go to the 
first location and dismiss the Xref buffer", especially in combination 
with the (setq xref-show-definitions-function ...) form above.

>> Questions for feedback:
>>
>> 1. Does the new behavior work okay window management-wise (it does
>> occupy +1 window, after all)?
> 
> Not sure I understand the question: we pop up an additional window
> when there are more than one candidate even without this option, so
> why do you say "+1 window"?  Maybe you had some recipe in mind that I
> didn't try?

It's "+1 window" compared to how 'find-tag' worked/works, which I assume 
is the target.

So it's still not the same behavior.

>> 2. Should this setting also extend to other commands like
>> xref-find-references?
> 
> Not necessarily.  Perhaps xref-auto-jump-to-first-definition should be
> tri-state, to allow users to request the same with
> xref-find-references as well?

Sure. Or we can have two variables, especially if we end up cramming 
different variations of behavior into them.

We can do a lot of things. What would help, is better knowledge about 
what people *want* to do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 26 Aug 2021 21:08:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 27 Aug 2021 00:07:37 +0300
On 27.08.2021 00:05, Dmitry Gutov wrote:
> +  (xref-next-line-no-show)
> +  (xref-goto-xref))
> 
> for
> 
> +  (xref-next-line)

Sorry, missed extra paren:

+  (xref-next-line))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 27 Aug 2021 06:25:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 27 Aug 2021 09:13:42 +0300
I clicked mouse-3 on the Flymake mode-line indicator expecting a context menu,
but mouse-3 abruptly closed the current buffer.  This can be fixed by such patch:

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 77a807f21a..cc12fce04a 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1256,6 +1256,8 @@ flymake--mode-line-title
     ,(let ((map (make-sparse-keymap)))
        (define-key map [mode-line down-mouse-1]
          flymake-menu)
+       (define-key map [mode-line down-mouse-3]
+         flymake-menu)
        (define-key map [mode-line mouse-2]
          (lambda ()
            (interactive)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 27 Aug 2021 06:26:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 27 Aug 2021 09:24:43 +0300
> Here is the first step that adds support for overlay-local context-menu,
> and removes the recently added 'flyspell-use-mouse-3-for-menu'.
> But 'flyspell-context-menu' still returns 'flyspell-correct-word'.

Now pushed.

> I invite you or anyone else to refactor 'flyspell-correct-word' and
> related functions to return a keymap menu where every menu item
> is bound to a function that calls flyspell-do-correct with an argument
> that is a correct word.

Any help is appreciated to create a menu keymap from misspelled words.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Fri, 27 Aug 2021 06:28:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Fri, 27 Aug 2021 09:26:45 +0300
> Cc: juri <at> linkov.net, alan <at> idiocy.org, mattiase <at> acm.org,
>  homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>  50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Fri, 27 Aug 2021 00:05:39 +0300
> 
> I think I remember now why it didn't make sense to me to have this 
> behavior OOTB: I think the main goal of the user who calls 
> xref-find-definitions is, usually, to pick one definition they wanted to 
> visit. Which also means having the xref buffer dismissed at the end.

That's one use case.  Another use case is when the candidates are all
related to some issue the user is working on, and therefore leaving
the xref buffer displayed for a long time is what they want.

> With the patch under discussion we automatically jump to the first 
> location. We can even iterate through locations with 
> next-error/previous-error (M-g M-n/M-g M-p). But to close 
> (quit/kill/etc) the list of locations, you have to switch back to its 
> window and press 'q'. Didn't that look like a bother to you?

No.  In my case, I just never bother to dismiss the xref buffer.  The
window showing it is a small one, and sooner or later the xref buffer
gets replaced by *Help* or ChangeLog or one of the other buffers I
display at the bottom of the frame.

> Here's how it could look instead:
> 
> 1. When you press M-., the first location is "shown", but not jumped to. 
> The focus remains on the Xref window, with point on its first item (the 
> arrow beside it is visible, like you wanted). Location is visible in the 
> other window, and we can either visit it and dismiss the Xref buffer 
> (with 'C-u RET'), simply visit it with 'RET', or look at the other 
> locations with 'n'/'p'.

This AFAIU corresponds to the situation where the user is not certain
which of the candidates is the one he/she wants.  I don't see how it
fundamentally differs from the original patch, since "M-g M-n" (or
"C-x `", which is what I use) isn't less convenient than 'n' followed
by "C-x o".  It might be more convenient to those who like to dismiss
the xref buffer, but (a) I'm not one of them, and (b) one can dismiss
it without going into it with "C-x 4 C-o".

> And you could also use a "transient" show-definitions-function like:
> 
> (setq xref-show-definitions-function
>        #'xref-show-definitions-buffer-at-bottom)
> 
> Then you'd only need to press RET in the results buffer to jump and 
> dismiss the results buffer.

Do a lot of people really like to dismiss the xref buffer?

In any case, I think questions about this aspect are better answered
by someone who does like to dismiss the buffer, because the issue
simply doesn't bother me enough to give you any useful input.

> 2. Simply have point move to the first location in the list (rather than 
> remain on the group name). From there, the user can press 'C-o' to show 
> the location without visiting, or 'RET', or 'C-u RET' like described 
> above. I understand this does not fit your prior workflows, but it does 
> require the least number of button presses in the scenario "go to the 
> first location and dismiss the Xref buffer", especially in combination 
> with the (setq xref-show-definitions-function ...) form above.

That's just a minor change in what we have now.  I don't object to
such a change, not even by default, but it isn't what we were
discussing until now.

> >> 1. Does the new behavior work okay window management-wise (it does
> >> occupy +1 window, after all)?
> > 
> > Not sure I understand the question: we pop up an additional window
> > when there are more than one candidate even without this option, so
> > why do you say "+1 window"?  Maybe you had some recipe in mind that I
> > didn't try?
> 
> It's "+1 window" compared to how 'find-tag' worked/works, which I assume 
> is the target.

No, I think xref is actually an improvement in this department,
because it shows the list of candidates instead of letting the user
guess how many are there.

> >> 2. Should this setting also extend to other commands like
> >> xref-find-references?
> > 
> > Not necessarily.  Perhaps xref-auto-jump-to-first-definition should be
> > tri-state, to allow users to request the same with
> > xref-find-references as well?
> 
> Sure. Or we can have two variables, especially if we end up cramming 
> different variations of behavior into them.
> 
> We can do a lot of things. What would help, is better knowledge about 
> what people *want* to do.

If we don't want to take a guess, I'd suggest leaving the option as it
is, affecting only xref-find-definitions, and extend it to other
commands as user requests arrive.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 28 Aug 2021 05:19:01 GMT) Full text and rfc822 format available.

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

From: Tak Kunihiro <homeros.misasa <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Sat, 28 Aug 2021 14:18:24 +0900
>> I invite you or anyone else to refactor 'flyspell-correct-word' and
>> related functions to return a keymap menu where every menu item
>> is bound to a function that calls flyspell-do-correct with an argument
>> that is a correct word.
>
> Any help is appreciated to create a menu keymap from misspelled words.

OK.  I understand the task.  I will try.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 28 Aug 2021 09:09:01 GMT) Full text and rfc822 format available.

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

From: Naoya Yamashita <conao3 <at> gmail.com>
To: tkk <at> misasa.okayama-u.ac.jp
Cc: 50067 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#50067: Context menus
Date: Sat, 28 Aug 2021 18:08:39 +0900
[Message part 1 (text/plain, inline)]
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)

Regards,
Naoya.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sat, 28 Aug 2021 19:18:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Naoya Yamashita <conao3 <at> gmail.com>
Cc: 50067 <at> debbugs.gnu.org, tkk <at> misasa.okayama-u.ac.jp
Subject: Re: bug#50067: Context menus
Date: Sat, 28 Aug 2021 21:50:15 +0300
[Message part 1 (text/plain, inline)]
> 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:

[context-menu-dictionary.patch (text/x-diff, inline)]
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

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 30 Aug 2021 02:46:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 30 Aug 2021 05:45:07 +0300
On 27.08.2021 09:26, Eli Zaretskii wrote:
>> Cc: juri <at> linkov.net, alan <at> idiocy.org, mattiase <at> acm.org,
>>   homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>>   50067 <at> debbugs.gnu.org
>> From: Dmitry Gutov <dgutov <at> yandex.ru>
>> Date: Fri, 27 Aug 2021 00:05:39 +0300
>>
>> I think I remember now why it didn't make sense to me to have this
>> behavior OOTB: I think the main goal of the user who calls
>> xref-find-definitions is, usually, to pick one definition they wanted to
>> visit. Which also means having the xref buffer dismissed at the end.
> 
> That's one use case.  Another use case is when the candidates are all
> related to some issue the user is working on, and therefore leaving
> the xref buffer displayed for a long time is what they want.

Fair enough.

>> With the patch under discussion we automatically jump to the first
>> location. We can even iterate through locations with
>> next-error/previous-error (M-g M-n/M-g M-p). But to close
>> (quit/kill/etc) the list of locations, you have to switch back to its
>> window and press 'q'. Didn't that look like a bother to you?
> 
> No.  In my case, I just never bother to dismiss the xref buffer.  The
> window showing it is a small one, and sooner or later the xref buffer
> gets replaced by *Help* or ChangeLog or one of the other buffers I
> display at the bottom of the frame.

I see.

This does not correspond to my usage and expectations, but, fingers 
crossed, this addition will satisfy the needs of other former users of 
'find-tag' as well.

>> Here's how it could look instead:
>>
>> 1. When you press M-., the first location is "shown", but not jumped to.
>> The focus remains on the Xref window, with point on its first item (the
>> arrow beside it is visible, like you wanted). Location is visible in the
>> other window, and we can either visit it and dismiss the Xref buffer
>> (with 'C-u RET'), simply visit it with 'RET', or look at the other
>> locations with 'n'/'p'.
> 
> This AFAIU corresponds to the situation where the user is not certain
> which of the candidates is the one he/she wants.  I don't see how it
> fundamentally differs from the original patch, since "M-g M-n" (or
> "C-x `", which is what I use) isn't less convenient than 'n' followed
> by "C-x o".  It might be more convenient to those who like to dismiss
> the xref buffer, but (a) I'm not one of them, and (b) one can dismiss
> it without going into it with "C-x 4 C-o".

All right. You still prefer the original patch, then?

>>>> 1. Does the new behavior work okay window management-wise (it does
>>>> occupy +1 window, after all)?
>>>
>>> Not sure I understand the question: we pop up an additional window
>>> when there are more than one candidate even without this option, so
>>> why do you say "+1 window"?  Maybe you had some recipe in mind that I
>>> didn't try?
>>
>> It's "+1 window" compared to how 'find-tag' worked/works, which I assume
>> is the target.
> 
> No, I think xref is actually an improvement in this department,
> because it shows the list of candidates instead of letting the user
> guess how many are there.

Cool.

>>>> 2. Should this setting also extend to other commands like
>>>> xref-find-references?
>>>
>>> Not necessarily.  Perhaps xref-auto-jump-to-first-definition should be
>>> tri-state, to allow users to request the same with
>>> xref-find-references as well?
>>
>> Sure. Or we can have two variables, especially if we end up cramming
>> different variations of behavior into them.
>>
>> We can do a lot of things. What would help, is better knowledge about
>> what people *want* to do.
> 
> If we don't want to take a guess, I'd suggest leaving the option as it
> is, affecting only xref-find-definitions, and extend it to other
> commands as user requests arrive.

All right.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 30 Aug 2021 11:58:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, juri <at> linkov.net,
 homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 30 Aug 2021 14:57:08 +0300
> Cc: juri <at> linkov.net, alan <at> idiocy.org, mattiase <at> acm.org,
>  homeros.misasa <at> gmail.com, tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org,
>  50067 <at> debbugs.gnu.org
> From: Dmitry Gutov <dgutov <at> yandex.ru>
> Date: Mon, 30 Aug 2021 05:45:07 +0300
> 
> All right. You still prefer the original patch, then?

Yes, the original patch satisfies my needs, AFAICT.  It would be good
to hear from Juri as well, though.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 07:12:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, Dmitry Gutov <dgutov <at> yandex.ru>, larsi <at> gnus.org,
 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 10:05:55 +0300
>> All right. You still prefer the original patch, then?
>
> Yes, the original patch satisfies my needs, AFAICT.  It would be good
> to hear from Juri as well, though.

Sorry, I can't find the original patch.  This bug#50067 collected
so many different things, so it's now hard to find anything.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 12:26:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 15:24:50 +0300
On 31.08.2021 10:05, Juri Linkov wrote:
>>> All right. You still prefer the original patch, then?
>> Yes, the original patch satisfies my needs, AFAICT.  It would be good
>> to hear from Juri as well, though.
> Sorry, I can't find the original patch.  This bug#50067 collected
> so many different things, so it's now hard to find anything.

Here it is: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50067#183




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 17:00:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 19:56:36 +0300
>>>> All right. You still prefer the original patch, then?
>>> Yes, the original patch satisfies my needs, AFAICT.  It would be good
>>> to hear from Juri as well, though.
>> Sorry, I can't find the original patch.  This bug#50067 collected
>> so many different things, so it's now hard to find anything.
>
> Here it is: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50067#183

Oh, I thought there were two patches: the patch above and also
the original patch.  But it the above is the original patch,
then I'd recommend to add more already discussed additions,
so the new option could provide at least these choices:

1. 'jump': Jump to the first location by selecting its window;
2. 'show': Show the first item, but keep focus in the Xref window;
3. 'move': Move point to the first item in the Xref window
   without showing it (maybe this should be the default behavior).

To be able to add later a similar variable for xref-find-references,
the new variable for xref-find-definitions could be named accordingly
with a name that refers to xref-find-definitions, for example,
xref-find-definitions-auto-jump.  Then later xref-find-references-auto-jump.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 18:06:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 20:37:54 +0300
>>>> On paste when there is a region and delete-selection-mode is t, the
>>>> region should be replaced by the text.
>>>
>>> Please explain how the region should be replaced by the text,
>>> when mouse-yank-at-click or mouse-yank-primary is used
>>> to paste where the mouse is clicked.  Should it delete the region
>>> and paste where mouse is clicked on another part of the buffer?
>>> What if the mouse is clicked in another window?
>>
>> When there is a region and yank text by `C-y’, the text would
>> be replaced.
>>
>> I think when there is a region and point in on region, region
>> should be replaced by text.  No?
>
> mouse-yank-at-click is intended to paste where you click.
> So when there is a region, and you click mouse-3 at some other position
> where you want to paste, and select "Paste" from the context-menu,
> it's unclear what to do with the region.  It makes no sense
> to delete the region, when you paste at the clicked position
> outside of the region, but not on the region.
>
> Please see more in mouse-yank-at-click and mouse-yank-primary
> that contain such comment about the need to deactivate the region:
>
>   ;; Without this, confusing things happen upon e.g. inserting into
>   ;; the middle of an active region.
>   (when select-active-regions
>     (let (select-active-regions)
>       (deactivate-mark)))

But maybe still it should delete the region before yanking?
I suggest to try these settings:

  (put 'mouse-yank-primary 'delete-selection 'yank)
  (put 'mouse-yank-at-click 'delete-selection 'yank)
  (put 'menu-bar-select-yank 'delete-selection 'yank)

Then maybe they should be added to delsel.el.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 18:06:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Tak Kunihiro <tkk <at> misasa.okayama-u.ac.jp>
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 Alan Third <alan <at> idiocy.org>, 50067 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 20:43:36 +0300
>>> ** no multiple horizontal lines
>>>
>>> Sometimes I see double lines on the context menu.  I think that there is
>>> no useful case to have double lines.  To allow only one horizontal line
>>> would look cool.
>>
>> Right, double separators should be removed.
>
> OK.

This is not easy to do.  Because there are menu-items
that use the filter :visible, e.g.:

  (defun prog-context-menu (menu)
    (require 'xref)
    (define-key-after menu [prog-separator] menu-bar-separator
      'mark-whole-buffer)
    (define-key-after menu [xref-find-def]
      '(menu-item "Find Definition" xref-find-definitions-at-mouse
                  :visible (save-excursion
                             (mouse-set-point last-input-event)
                             (xref-backend-identifier-at-point
                              (xref-find-backend)))
                  :help "Find definition of identifier")
      'prog-separator)

So it's not known whether the menu-item will be displayed
until the menu is displayed.  So there is no way to remove
a stray separator in the context-menu function that creates
the context menu.

Maybe such items should be rewritten to avoid the filter :visible,
e.g.:

  (defun prog-context-menu (menu)
    (require 'xref)
    (define-key-after menu [prog-separator] menu-bar-separator
      'mark-whole-buffer)
    (when (save-excursion
            (mouse-set-point last-input-event)
            (xref-backend-identifier-at-point
             (xref-find-backend)))
      (define-key-after menu [xref-find-def]
        '(menu-item "Find Definition" xref-find-definitions-at-mouse
                    :help "Find definition of identifier")
        'prog-separator))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 19:00:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org, mattiase <at> acm.org, alan <at> idiocy.org,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 21:58:37 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Alan Third <alan <at> idiocy.org>,  Mattias Engdegård
>  <mattiase <at> acm.org>,
>   Lars Ingebrigtsen <larsi <at> gnus.org>,  50067 <at> debbugs.gnu.org,  Eli
>  Zaretskii <eliz <at> gnu.org>
> Date: Tue, 31 Aug 2021 20:43:36 +0300
> 
> >>> ** no multiple horizontal lines
> >>>
> >>> Sometimes I see double lines on the context menu.  I think that there is
> >>> no useful case to have double lines.  To allow only one horizontal line
> >>> would look cool.
> >>
> >> Right, double separators should be removed.
> >
> > OK.
> 
> This is not easy to do.  Because there are menu-items
> that use the filter :visible, e.g.:

Can I ask why do we need the separators in the context menus?  Why not
remove them all, unconditionally?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 31 Aug 2021 20:24:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 31 Aug 2021 23:23:43 +0300
On 31.08.2021 19:56, Juri Linkov wrote:
>>>>> All right. You still prefer the original patch, then?
>>>> Yes, the original patch satisfies my needs, AFAICT.  It would be good
>>>> to hear from Juri as well, though.
>>> Sorry, I can't find the original patch.  This bug#50067 collected
>>> so many different things, so it's now hard to find anything.
>>
>> Here it is: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50067#183
> 
> Oh, I thought there were two patches: the patch above and also
> the original patch.  But it the above is the original patch,
> then I'd recommend to add more already discussed additions,
> so the new option could provide at least these choices:
> 
> 1. 'jump': Jump to the first location by selecting its window;
> 2. 'show': Show the first item, but keep focus in the Xref window;
> 3. 'move': Move point to the first item in the Xref window
>     without showing it (maybe this should be the default behavior).

We can do that. Do you expect to be using more than 1 of these values 
yourself, or is it just for completeness?

Regarding 3 as default, it makes a certain sense, but then you won't be 
able to iterate through all locations with just 'n'. You'd have to press 
'C-o' and then 'n', 'n', 'n'...

> To be able to add later a similar variable for xref-find-references,
> the new variable for xref-find-definitions could be named accordingly
> with a name that refers to xref-find-definitions, for example,
> xref-find-definitions-auto-jump.  Then later xref-find-references-auto-jump.

I think the "other" variable would be called something with the word 
"xrefs", not "references", and apply to other commands as well, such as 
xref-find-apropos and project-find-regexp.

So the proposed scheme would not quite work. Maybe like this instead?

 - xref-auto-jump-to-first-definition
 - xref-auto-jump-to-first-<xref/item/match/result>. Or just 
xref-auto-jump-to-first.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 01 Sep 2021 07:26:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 01 Sep 2021 10:08:38 +0300
>> so the new option could provide at least these choices:
>> 1. 'jump': Jump to the first location by selecting its window;
>> 2. 'show': Show the first item, but keep focus in the Xref window;
>> 3. 'move': Move point to the first item in the Xref window
>>     without showing it (maybe this should be the default behavior).
>
> We can do that. Do you expect to be using more than 1 of these values
> yourself, or is it just for completeness?

A good indication that all values are needed is that I still can't decide
which to use, so it would be possible to switch to another value when
one of them does too much or too little.

> Regarding 3 as default, it makes a certain sense, but then you won't be
> able to iterate through all locations with just 'n'. You'd have to press
> 'C-o' and then 'n', 'n', 'n'...

I agree, it should not be the default.

>> To be able to add later a similar variable for xref-find-references,
>> the new variable for xref-find-definitions could be named accordingly
>> with a name that refers to xref-find-definitions, for example,
>> xref-find-definitions-auto-jump.  Then later xref-find-references-auto-jump.
>
> I think the "other" variable would be called something with the word
> "xrefs", not "references", and apply to other commands as well, such as
> xref-find-apropos and project-find-regexp.
>
> So the proposed scheme would not quite work. Maybe like this instead?
>
>  - xref-auto-jump-to-first-definition
>  - xref-auto-jump-to-first-<xref/item/match/result>. Or just
>    xref-auto-jump-to-first.

grep/compilation already supports the value 'jump' by non-nil
'compilation-auto-jump-to-first-error', and the value 'move' when
'compilation-scroll-output' is customized to 'first-error'.

But I think for xref still two separate options are needed
xref-auto-jump-to-first-definition for xref-find-definitions, and
xref-auto-jump-to-first-xref for other more grep-like xref commands.

BTW, I'm testing compilation errors/warnings on xref context menu,
and it reposts this warning:

  prog-mode.el:60:12: Warning: the function `xref-backend-identifier-at-point'
      is not known to be defined.

on this code:

  (defun prog-context-menu (menu)
    (require 'xref)
    (define-key-after menu [prog-separator] menu-bar-separator
      'mark-whole-buffer)
    (when (save-excursion
            (mouse-set-point last-input-event)
            (xref-backend-identifier-at-point
             (xref-find-backend)))
      (define-key-after menu [xref-find-def]
        '(menu-item "Find Definition" xref-find-definitions-at-mouse
                    :help "Find definition of identifier")
        'prog-separator))

Maybe `xref-backend-identifier-at-point' should be autoloaded?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 01 Sep 2021 07:26:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50067 <at> debbugs.gnu.org, mattiase <at> acm.org, alan <at> idiocy.org,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org
Subject: Re: bug#50067: Context menus
Date: Wed, 01 Sep 2021 10:12:54 +0300
>> >>> ** no multiple horizontal lines
>> >>>
>> >>> Sometimes I see double lines on the context menu.  I think that there is
>> >>> no useful case to have double lines.  To allow only one horizontal line
>> >>> would look cool.
>> >>
>> >> Right, double separators should be removed.
>> >
>> > OK.
>>
>> This is not easy to do.  Because there are menu-items
>> that use the filter :visible, e.g.:
>
> Can I ask why do we need the separators in the context menus?  Why not
> remove them all, unconditionally?

The separators are of great help to provide visual cues for groups
of objects.  All menus on the menu-bar in Emacs use separators.
Anyway, this is implemented now:

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 7d3ed9a0e4..8ac22a07c9 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -315,7 +315,14 @@ context-menu-map
                           (lambda (fun)
                             (setq menu (funcall fun menu))
                             nil))))
-    ;; TODO: remove double separators
+    ;; Remove double separators
+    (let ((l menu))
+      (while l
+        (when (and (equal (cdr-safe (car l)) menu-bar-separator)
+                   (equal (cdr-safe (cadr l)) menu-bar-separator))
+          (setcdr l (cddr l)))
+        (setq l (cdr l))))
+
     (when (functionp context-menu-filter-function)
       (setq menu (funcall context-menu-filter-function menu)))
     menu))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 01 Sep 2021 19:04:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 1 Sep 2021 22:03:13 +0300
On 01.09.2021 10:08, Juri Linkov wrote:
> BTW, I'm testing compilation errors/warnings on xref context menu,
> and it reposts this warning:
> 
>    prog-mode.el:60:12: Warning: the function `xref-backend-identifier-at-point'
>        is not known to be defined.
> 
> on this code:
> 
>    (defun prog-context-menu (menu)
>      (require 'xref)
>      (define-key-after menu [prog-separator] menu-bar-separator
>        'mark-whole-buffer)
>      (when (save-excursion
>              (mouse-set-point last-input-event)
>              (xref-backend-identifier-at-point
>               (xref-find-backend)))
>        (define-key-after menu [xref-find-def]
>          '(menu-item "Find Definition" xref-find-definitions-at-mouse
>                      :help "Find definition of identifier")
>          'prog-separator))
> 
> Maybe `xref-backend-identifier-at-point' should be autoloaded?

I don't know. What are the rules?

There is no risk to call it before xref.el is loaded because 
xref-find-backend itself is autoloaded.

But the lack of autoloading can cause byte-compilation warnings. They 
can be dealt with by other means too, though.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 05 Sep 2021 00:56:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Eli Zaretskii <eliz <at> gnu.org>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 5 Sep 2021 03:55:43 +0300
On 01.09.2021 10:08, Juri Linkov wrote:
>>> so the new option could provide at least these choices:
>>> 1. 'jump': Jump to the first location by selecting its window;
>>> 2. 'show': Show the first item, but keep focus in the Xref window;
>>> 3. 'move': Move point to the first item in the Xref window
>>>      without showing it (maybe this should be the default behavior).
>>
>> We can do that. Do you expect to be using more than 1 of these values
>> yourself, or is it just for completeness?
> 
> A good indication that all values are needed is that I still can't decide
> which to use, so it would be possible to switch to another value when
> one of them does too much or too little.
> 
>> Regarding 3 as default, it makes a certain sense, but then you won't be
>> able to iterate through all locations with just 'n'. You'd have to press
>> 'C-o' and then 'n', 'n', 'n'...
> 
> I agree, it should not be the default.
> 
>>> To be able to add later a similar variable for xref-find-references,
>>> the new variable for xref-find-definitions could be named accordingly
>>> with a name that refers to xref-find-definitions, for example,
>>> xref-find-definitions-auto-jump.  Then later xref-find-references-auto-jump.
>>
>> I think the "other" variable would be called something with the word
>> "xrefs", not "references", and apply to other commands as well, such as
>> xref-find-apropos and project-find-regexp.
>>
>> So the proposed scheme would not quite work. Maybe like this instead?
>>
>>   - xref-auto-jump-to-first-definition
>>   - xref-auto-jump-to-first-<xref/item/match/result>. Or just
>>     xref-auto-jump-to-first.
> 
> grep/compilation already supports the value 'jump' by non-nil
> 'compilation-auto-jump-to-first-error', and the value 'move' when
> 'compilation-scroll-output' is customized to 'first-error'.
> 
> But I think for xref still two separate options are needed
> xref-auto-jump-to-first-definition for xref-find-definitions, and
> xref-auto-jump-to-first-xref for other more grep-like xref commands.

It's now in master: two variables, three methods of behavior for each.

Let me know if you see any problems.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 05 Sep 2021 08:38:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#50067: Context menus
Date: Sun, 05 Sep 2021 11:37:00 +0300
>>>   - xref-auto-jump-to-first-definition
>>>   - xref-auto-jump-to-first-<xref/item/match/result>. Or just
>>>     xref-auto-jump-to-first.
>> grep/compilation already supports the value 'jump' by non-nil
>> 'compilation-auto-jump-to-first-error', and the value 'move' when
>> 'compilation-scroll-output' is customized to 'first-error'.
>> But I think for xref still two separate options are needed
>> xref-auto-jump-to-first-definition for xref-find-definitions, and
>> xref-auto-jump-to-first-xref for other more grep-like xref commands.
>
> It's now in master: two variables, three methods of behavior for each.
>
> Let me know if you see any problems.

Thanks, one problem is that defcustoms have no '(const nil :tag'
for the default value 'nil'.  I don't know what tag to use,
maybe "No auto-jump".  There were other problems so that it was
easier to just push the fix :)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Sun, 05 Sep 2021 19:26:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: alan <at> idiocy.org, mattiase <at> acm.org, homeros.misasa <at> gmail.com,
 tkk <at> misasa.okayama-u.ac.jp, larsi <at> gnus.org, 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Sun, 5 Sep 2021 22:25:29 +0300
On 05.09.2021 11:37, Juri Linkov wrote:
> Thanks, one problem is that defcustoms have no '(const nil :tag'
> for the default value 'nil'.  I don't know what tag to use,
> maybe "No auto-jump".  There were other problems so that it was
> easier to just push the fix:)

Thanks! I really skipped on testing the Customize behavior.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 27 Sep 2021 15:44:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 27 Sep 2021 18:30:23 +0300
[Message part 1 (text/plain, inline)]
Other programs don't show the keys in context menus.
The Human Interface Guidelines say:

  Show keyboard shortcuts in menu bar menus, not contextual menus.
  Contextual menus are already shortcuts to task-specific commands;
  it's redundant to display keyboard shortcuts too.

This patch hides all keys from the context menus:

[inhibit-menu-keys.patch (text/x-diff, inline)]
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5f3db46516..2d9b1c8f0b 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -314,7 +314,9 @@ context-menu-map
 it overrides all functions from `context-menu-functions'.
 At the end, it's possible to modify the final menu by specifying
 the function `context-menu-filter-function'."
-  (let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))
+  (let* ((menu (make-sparse-keymap (propertize "Context Menu"
+                                               'hide t
+                                               'no-keys t)))
          (click (or click last-input-event))
          (fun (mouse-posn-property (event-start click)
                                    'context-menu-function)))
diff --git a/src/keyboard.c b/src/keyboard.c
index 462b415c1d..8c90292137 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7832,16 +7832,20 @@ parse_menu_item (Lisp_Object item, int inmenubar)
 		filter = item;
 	      else if (EQ (tem, QCkey_sequence))
 		{
-		  tem = XCAR (item);
-		  if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem))
-		    /* Be GC protected. Set keyhint to item instead of tem.  */
-		    keyhint = item;
-		}
+		  if (!inhibit_menu_keys)
+		    {
+		      tem = XCAR (item);
+		      if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem))
+			/* Be GC protected. Set keyhint to item instead of tem.  */
+			keyhint = item;
+		    }		}
 	      else if (EQ (tem, QCkeys))
 		{
-		  tem = XCAR (item);
-		  if (CONSP (tem) || STRINGP (tem))
-		    ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem);
+		  if (!inhibit_menu_keys){
+		    tem = XCAR (item);
+		    if (CONSP (tem) || STRINGP (tem))
+		      ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem);
+		  }
 		}
 	      else if (EQ (tem, QCbutton) && CONSP (XCAR (item)))
 		{
@@ -7916,6 +7920,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
   if (inmenubar > 0)
     return 1;
 
+  if (!inhibit_menu_keys)
   { /* This is a command.  See if there is an equivalent key binding.  */
     Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
     AUTO_STRING (space_space, "  ");
@@ -12495,6 +12500,11 @@ syms_of_keyboard (void)
                Vwhile_no_input_ignore_events,
                doc: /* Ignored events from while-no-input.  */);
 
+  DEFVAR_BOOL ("inhibit-menu-keys",
+               inhibit_menu_keys,
+               doc: /* If non-nil, inhibit menu keys.  */);
+  inhibit_menu_keys = false;
+
   pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
 }
 
diff --git a/src/menu.c b/src/menu.c
index 1aafa78c3c..e7e7ecca6a 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1281,13 +1281,18 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
       /* We were given a keymap.  Extract menu info from the keymap.  */
       Lisp_Object prompt;
 
-      /* Extract the detailed info to make one pane.  */
-      keymap_panes (&menu, 1);
-
       /* Search for a string appearing directly as an element of the keymap.
 	 That string is the title of the menu.  */
       prompt = Fkeymap_prompt (keymap);
 
+      if (STRINGP (prompt)
+	  && SCHARS (prompt) > 0
+	  && !NILP (Fget_text_property (make_fixnum (0), Qno_keys, prompt)))
+      specbind (Qinhibit_menu_keys, Qt);
+
+      /* Extract the detailed info to make one pane.  */
+      keymap_panes (&menu, 1);
+
 #if defined (USE_GTK) || defined (HAVE_NS)
       if (STRINGP (prompt)
 	  && SCHARS (prompt) > 0
@@ -1583,6 +1588,8 @@ syms_of_menu (void)
   staticpro (&menu_items);
 
   DEFSYM (Qhide, "hide");
+  DEFSYM (Qno_keys, "no-keys");
+  DEFSYM (Qinhibit_menu_keys, "inhibit-menu-keys");
 
   defsubr (&Sx_popup_menu);
   defsubr (&Sx_popup_dialog);

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 27 Sep 2021 15:44:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 27 Sep 2021 18:33:15 +0300
After typing 'C-h k', clicking mouse-3 on a function name,
then selecting e.g. "Describe Function", the Help buffer says

  <down-mouse-3> <describe-symbol> at that spot is undefined

This can be fixed by this patch:

diff --git a/lisp/help.el b/lisp/help.el
index 8f77167040..b794751eca 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -695,7 +695,7 @@ help--analyze-key
 	 (mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers)
 			    (memq 'drag modifiers))
                         " at that spot" ""))
-	 (defn (key-binding key t)))
+	 (defn (save-excursion (mouse-set-point event) (key-binding key t))))
     ;; Handle the case where we faked an entry in "Select and Paste" menu.
     (when (and (eq defn nil)
 	       (stringp (aref key (1- (length key))))
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 27 Sep 2021 15:51:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 27 Sep 2021 17:50:15 +0200
Juri Linkov <juri <at> linkov.net> writes:

> Other programs don't show the keys in context menus.
> The Human Interface Guidelines say:
>
>   Show keyboard shortcuts in menu bar menus, not contextual menus.
>   Contextual menus are already shortcuts to task-specific commands;
>   it's redundant to display keyboard shortcuts too.

I'm not sure I agree with those guidelines -- displaying the key
bindings increases the discoverability of those key bindings.  (Not
using the mouse is more productive in the long term for most people.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 27 Sep 2021 16:18:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Juri Linkov <juri <at> linkov.net>
Cc: "50067 <at> debbugs.gnu.org" <50067 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#50067: Context menus
Date: Mon, 27 Sep 2021 16:17:11 +0000
> > Other programs don't show the keys in context menus.
> > The Human Interface Guidelines say:
> >
> >   Show keyboard shortcuts in menu bar menus, not contextual menus.
> >   Contextual menus are already shortcuts to task-specific commands;
> >   it's redundant to display keyboard shortcuts too.
> 
> I'm not sure I agree with those guidelines -- displaying the key
> bindings increases the discoverability of those key bindings.  (Not
> using the mouse is more productive in the long term for most people.)

+1.

Provided, that is, that the (context) menu-item
is bound to exactly the same command as the key.
But if the key does something different from what
the item does (e.g. dependent on the context),
then omitting the key name can make sense.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 27 Sep 2021 18:42:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 27 Sep 2021 21:41:52 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Date: Mon, 27 Sep 2021 18:30:23 +0300
> 
> Other programs don't show the keys in context menus.
> The Human Interface Guidelines say:
> 
>   Show keyboard shortcuts in menu bar menus, not contextual menus.
>   Contextual menus are already shortcuts to task-specific commands;
>   it's redundant to display keyboard shortcuts too.
> 
> This patch hides all keys from the context menus:

Unconditionally? why??  Emacs always shows the keyboard bindings in
its menus, so why should we care what other apps do?  And why force
this on everyone?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 28 Sep 2021 19:05:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 28 Sep 2021 21:54:40 +0300
>> Other programs don't show the keys in context menus.
>> The Human Interface Guidelines say:
>>
>>   Show keyboard shortcuts in menu bar menus, not contextual menus.
>>   Contextual menus are already shortcuts to task-specific commands;
>>   it's redundant to display keyboard shortcuts too.
>>
>> This patch hides all keys from the context menus:
>
> Unconditionally? why??  Emacs always shows the keyboard bindings in
> its menus, so why should we care what other apps do?  And why force
> this on everyone?

The patch disables the keys conditionally by adding a new
text property to the menu title.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 28 Sep 2021 19:05:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 28 Sep 2021 21:49:59 +0300
>> Other programs don't show the keys in context menus.
>> The Human Interface Guidelines say:
>>
>>   Show keyboard shortcuts in menu bar menus, not contextual menus.
>>   Contextual menus are already shortcuts to task-specific commands;
>>   it's redundant to display keyboard shortcuts too.
>
> I'm not sure I agree with those guidelines -- displaying the key
> bindings increases the discoverability of those key bindings.

For example, how to explain to the users why a keybinding
is displayed for "Undo", but not for "Redo".

Another question is why currently `C-x u' is displayed
instead of the shorter `C-/' for "Undo".

So maybe simpler just to disable keys only for "Undo"
with ‘:keys ""’.  Or the other way around: to manually
add some suggested keybinding to "Redo".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 28 Sep 2021 19:32:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 28 Sep 2021 22:31:40 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 50067 <at> debbugs.gnu.org
> Date: Tue, 28 Sep 2021 21:54:40 +0300
> 
> >> Other programs don't show the keys in context menus.
> >> The Human Interface Guidelines say:
> >>
> >>   Show keyboard shortcuts in menu bar menus, not contextual menus.
> >>   Contextual menus are already shortcuts to task-specific commands;
> >>   it's redundant to display keyboard shortcuts too.
> >>
> >> This patch hides all keys from the context menus:
> >
> > Unconditionally? why??  Emacs always shows the keyboard bindings in
> > its menus, so why should we care what other apps do?  And why force
> > this on everyone?
> 
> The patch disables the keys conditionally by adding a new
> text property to the menu title.

I meant user's ability to request the display of key bindings in the
menu.  I hope you don't expect users to change text properties on menu
titles as the means to have that control.  There should be an option,
and frankly I don't understand why these menus should behave
differently from any other menu in Emacs that shows commands.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 28 Sep 2021 22:09:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "50067 <at> debbugs.gnu.org" <50067 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#50067: Context menus
Date: Tue, 28 Sep 2021 22:08:42 +0000
> For example, how to explain to the users why a keybinding
> is displayed for "Undo", but not for "Redo".

When & why does that need to be explained?
Is there a missing binding, perhaps?

> Another question is why currently `C-x u' is displayed
> instead of the shorter `C-/' for "Undo".

That's an orthogonal problem, which is not
specific to context menus, right?  That's
a general, longstanding problem, IIUC.

> So maybe simpler just to disable keys only for "Undo"
> with ‘:keys ""’.  Or the other way around: to manually
> add some suggested keybinding to "Redo".

Is there a reason why one has and the other
doesn't have a binding?  Does it matter?

How is this related to the general question
of whether _context menu_ items should be
able to have keys listed?  Doesn't all that
you wrote apply to menus generally?

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 29 Sep 2021 07:21:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 29 Sep 2021 10:00:10 +0300
>> I'm not sure I agree with those guidelines -- displaying the key
>> bindings increases the discoverability of those key bindings.
>
> For example, how to explain to the users why a keybinding
> is displayed for "Undo", but not for "Redo".
>
> Another question is why currently `C-x u' is displayed
> instead of the shorter `C-/' for "Undo".
>
> So maybe simpler just to disable keys only for "Undo"
> with ‘:keys ""’.  Or the other way around: to manually
> add some suggested keybinding to "Redo".

I think it would be better to rebind "Undo" from 'undo'
to 'undo-only'.  Since 'undo-only' has no keybinding,
it will not be displayed in the menu.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Wed, 20 Oct 2021 17:01:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Wed, 20 Oct 2021 19:59:18 +0300
[Message part 1 (text/plain, inline)]
Currently the option context-menu-global of context-menu-functions
doesn't take into account the variable menu-bar-final-items
to properly order the menu items.  This patch makes it possible
to order the items of global-map instead of menu-bar-current-active-maps
used in menu-bar-keymap by default:

[menu-bar-keymap.patch (text/x-diff, inline)]
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 980ba2fcd1..b6cc29720d 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2713,9 +2713,11 @@ menu-bar-open-mouse
                        (cdr menu-bar-item-cons)
                      0))))
 
-(defun menu-bar-keymap ()
+(defun menu-bar-keymap (&optional keymap)
   "Return the current menu-bar keymap.
-
+It's possible to use the KEYMAP argument to override the default keymap
+that is the currently active maps.  For example, the argument KEYMAP
+could provide `global-map' where items are limited to the global map only.
 The ordering of the return value respects `menu-bar-final-items'."
   (let ((menu-bar '())
         (menu-end '()))
@@ -2729,7 +2731,7 @@ menu-bar-keymap
              ;; sorting.
              (push (cons pos menu-item) menu-end)
            (push menu-item menu-bar))))
-     (lookup-key (menu-bar-current-active-maps) [menu-bar]))
+     (lookup-key (or keymap (menu-bar-current-active-maps)) [menu-bar]))
     `(keymap ,@(nreverse menu-bar)
              ,@(mapcar #'cdr (sort menu-end
                                    (lambda (a b)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3e00ca7ce1..6c97cc365f 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -364,7 +364,7 @@ context-menu-global
                 (when (consp binding)
                   (define-key-after menu (vector key)
                     (copy-sequence binding))))
-              (lookup-key global-map [menu-bar]))
+              (menu-bar-keymap global-map))
   menu)
 
 (defun context-menu-local (menu _click)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Mon, 08 Nov 2021 20:08:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Mon, 08 Nov 2021 22:05:12 +0200
[Message part 1 (text/plain, inline)]
> Currently the option context-menu-global of context-menu-functions
> doesn't take into account the variable menu-bar-final-items
> to properly order the menu items.  This patch makes it possible
> to order the items of global-map instead of menu-bar-current-active-maps
> used in menu-bar-keymap by default:

Actually, here is a better patch that will also allow sorting items on
context-menu-local as well.  The same KEYMAP arg of menu-bar-keymap
could be used also in mouse-menu-bar-map to sort items of [C-down-mouse-3]
in the right order (they were unsorted for a long time):

[menu-bar-keymap-2.patch (text/x-diff, inline)]
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1a81f1a3d0..94e75efeeb 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2738,7 +2738,7 @@ menu-bar-keymap
              ;; sorting.
              (push (cons pos menu-item) menu-end)
            (push menu-item menu-bar))))
-     (lookup-key (or keymap (menu-bar-current-active-maps)) [menu-bar]))
+     (or keymap (lookup-key (menu-bar-current-active-maps) [menu-bar])))
     `(keymap ,@(nreverse menu-bar)
              ,@(mapcar #'cdr (sort menu-end
                                    (lambda (a b)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index d6912892ef..5b9ae121d7 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -271,10 +271,10 @@ mouse-menu-bar-map
     ;; FIXME: We have a problem here: we have to use the global/local/minor
     ;; so they're displayed in the expected order, but later on in the command
     ;; loop, they're actually looked up in the opposite order.
-    (apply 'append
-           global-menu
-           local-menu
-           minor-mode-menus)))
+    (menu-bar-keymap (apply 'append
+                            global-menu
+                            local-menu
+                            minor-mode-menus))))
 
 
 ;; Context menus.
@@ -364,7 +364,7 @@ context-menu-global
                 (when (consp binding)
                   (define-key-after menu (vector key)
                     (copy-sequence binding))))
-              (menu-bar-keymap global-map))
+              (menu-bar-keymap (lookup-key global-map [menu-bar])))
   menu)
 
 (defun context-menu-local (menu _click)
@@ -377,7 +377,7 @@ context-menu-local
                     (when (consp binding)
                       (define-key-after menu (vector key)
                         (copy-sequence binding))))
-                  keymap)))
+                  (menu-bar-keymap keymap))))
   menu)
 
 (defun context-menu-minor (menu _click)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 18 Nov 2021 18:40:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 18 Nov 2021 20:38:53 +0200
>> Currently the option context-menu-global of context-menu-functions
>> doesn't take into account the variable menu-bar-final-items
>> to properly order the menu items.  This patch makes it possible
>> to order the items of global-map instead of menu-bar-current-active-maps
>> used in menu-bar-keymap by default:
>
> Actually, here is a better patch that will also allow sorting items on
> context-menu-local as well.  The same KEYMAP arg of menu-bar-keymap
> could be used also in mouse-menu-bar-map to sort items of [C-down-mouse-3]
> in the right order (they were unsorted for a long time):

Only part of the patch that fixes the new feature was pushed to emacs-28.
But the following part that fixes the old function could pushed to master later:

> diff --git a/lisp/mouse.el b/lisp/mouse.el
> index d6912892ef..5b9ae121d7 100644
> --- a/lisp/mouse.el
> +++ b/lisp/mouse.el
> @@ -271,10 +271,10 @@ mouse-menu-bar-map
>      ;; FIXME: We have a problem here: we have to use the global/local/minor
>      ;; so they're displayed in the expected order, but later on in the command
>      ;; loop, they're actually looked up in the opposite order.
> -    (apply 'append
> -           global-menu
> -           local-menu
> -           minor-mode-menus)))
> +    (menu-bar-keymap (apply 'append
> +                            global-menu
> +                            local-menu
> +                            minor-mode-menus))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 25 Nov 2021 08:01:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 25 Nov 2021 09:50:40 +0200
[Message part 1 (text/plain, inline)]
After clicking the right mouse button e.g. on the mode-line's minor-modes,
typing S-F10 on a misspelled word pops up the context menu over the mode-line
instead of the position over the misspelled word.  Because it tries to find
the last event that is a mouse event.  In case of keyboard-based 'context-menu-open'
that let-binds 'inhibit-mouse-event-check' to t, this is not needed:

[inhibit_mouse_event_check.patch (text/x-diff, inline)]
diff --git a/src/callint.c b/src/callint.c
index 44dae361c1..525a18683d 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -367,7 +367,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
      event with parameters.  */
   ptrdiff_t next_event;
   for (next_event = 0; next_event < key_count; next_event++)
-    if (EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
+    if (inhibit_mouse_event_check || EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
       break;
 
   /* Handle special starting chars `*' and `@'.  Also `-'.  */
@@ -618,6 +618,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
 	  do
 	    next_event++;
 	  while (next_event < key_count
+		 && ! inhibit_mouse_event_check
 		 && ! EVENT_HAS_PARAMETERS (AREF (keys, next_event)));
 
 	  break;

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 25 Nov 2021 08:40:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 25 Nov 2021 10:38:44 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Date: Thu, 25 Nov 2021 09:50:40 +0200
> 
> --- a/src/callint.c
> +++ b/src/callint.c
> @@ -367,7 +367,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
>       event with parameters.  */
>    ptrdiff_t next_event;
>    for (next_event = 0; next_event < key_count; next_event++)
> -    if (EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
> +    if (inhibit_mouse_event_check || EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
>        break;
>  
>    /* Handle special starting chars `*' and `@'.  Also `-'.  */
> @@ -618,6 +618,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
>  	  do
>  	    next_event++;
>  	  while (next_event < key_count
> +		 && ! inhibit_mouse_event_check
>  		 && ! EVENT_HAS_PARAMETERS (AREF (keys, next_event)));
>  
>  	  break;

Why check this condition inside the loops, rather than avoid entering
the loops when the condition is right, in the first place?

And please add comments there explaining the meaning of the
inhibit_mouse_event_check test.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Thu, 25 Nov 2021 19:34:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Thu, 25 Nov 2021 21:28:47 +0200
[Message part 1 (text/plain, inline)]
>> @@ -367,7 +367,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
>>       event with parameters.  */
>>    ptrdiff_t next_event;
>>    for (next_event = 0; next_event < key_count; next_event++)
>> -    if (EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
>> +    if (inhibit_mouse_event_check || EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
>>        break;
>>  
>>    /* Handle special starting chars `*' and `@'.  Also `-'.  */
>> @@ -618,6 +618,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
>>  	  do
>>  	    next_event++;
>>  	  while (next_event < key_count
>> +		 && ! inhibit_mouse_event_check
>>  		 && ! EVENT_HAS_PARAMETERS (AREF (keys, next_event)));
>>  
>>  	  break;
>
> Why check this condition inside the loops, rather than avoid entering
> the loops when the condition is right, in the first place?

I thought that checking the condition inside the loops
would be less risky for the emacs-28 release branch.

> And please add comments there explaining the meaning of the
> inhibit_mouse_event_check test.

This patch also adds comments, and removes one condition
that is not unnecessary when event with parameters
is not searched when inhibit_mouse_event_check is non-nil:

[inhibit_mouse_event_check_2.patch (text/x-diff, inline)]
diff --git a/src/callint.c b/src/callint.c
index 44dae361c1..68f103759a 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -364,11 +364,14 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
 
   /* The index of the next element of this_command_keys to examine for
      the 'e' interactive code.  Initialize it to point to the first
-     event with parameters.  */
-  ptrdiff_t next_event;
-  for (next_event = 0; next_event < key_count; next_event++)
-    if (EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
-      break;
+     event with parameters.  When `inhibit_mouse_event_check' is non-nil,
+     the command can accept an event without parameters,
+     so don't search for the event with parameters in this case.  */
+  ptrdiff_t next_event = 0;
+  if (!inhibit_mouse_event_check)
+    for (; next_event < key_count; next_event++)
+      if (EVENT_HAS_PARAMETERS (AREF (keys, next_event)))
+	break;
 
   /* Handle special starting chars `*' and `@'.  Also `-'.  */
   /* Note that `+' is reserved for user extensions.  */
@@ -606,7 +609,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
 	  break;
 
 	case 'e':		/* The invoking event.  */
-	  if (!inhibit_mouse_event_check && next_event >= key_count)
+	  if (next_event >= key_count)
 	    error ("%s must be bound to an event with parameters",
 		   (SYMBOLP (function)
 		    ? SSDATA (SYMBOL_NAME (function))
@@ -614,11 +617,15 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
 	  args[i] = AREF (keys, next_event);
 	  varies[i] = -1;
 
-	  /* Find the next parameterized event.  */
-	  do
+	  /* `inhibit_mouse_event_check' allows non-parameterized events.  */
+	  if (inhibit_mouse_event_check)
 	    next_event++;
-	  while (next_event < key_count
-		 && ! EVENT_HAS_PARAMETERS (AREF (keys, next_event)));
+	  else
+	    /* Find the next parameterized event.  */
+	    do
+	      next_event++;
+	    while (next_event < key_count
+		   && ! EVENT_HAS_PARAMETERS (AREF (keys, next_event)));
 
 	  break;
 

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50067; Package emacs. (Tue, 30 Nov 2021 18:15:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50067 <at> debbugs.gnu.org
Subject: Re: bug#50067: Context menus
Date: Tue, 30 Nov 2021 20:12:48 +0200
>> Why check this condition inside the loops, rather than avoid entering
>> the loops when the condition is right, in the first place?
>
> I thought that checking the condition inside the loops
> would be less risky for the emacs-28 release branch.
>
>> And please add comments there explaining the meaning of the
>> inhibit_mouse_event_check test.
>
> This patch also adds comments, and removes one condition
> that is not unnecessary when event with parameters
> is not searched when inhibit_mouse_event_check is non-nil:

Patch pushed now.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Dec 2021 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 80 days ago.

Previous Next


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