Subject: RE: bug#52293: [External] : bug#52293: 29.0.50; [PATCH v3] Prevent further cases of duplicated separators in context menus

From: Drew Adams <[email-masked]>
Date: Wed, 15 Dec 2021 18:10:45 +0000

> > Instead of throwing the traditional Emacs `mouse-3'
> > under the bus, we should be running it up the flag
> > pole and shining a light on it.
> 
> I wonder how do you think it's possible to combine
> the traditional `mouse-3' that operates on the region,
> and `mouse-3' that pops up the context menu?

Why do you wonder?  You asked that same question
yesterday, and I answered it, in the same message
you're quoting from.

Is there some part of either the description or
the code of `mouse3.el' that isn't clear in this
regard?  Did you follow those links?  Do you have
a specific question about how it works or behaves?

Here are the links again.
Description:
https://www.emacswiki.org/emacs/Mouse3
Code:
https://www.emacswiki.org/emacs/download/mouse3.el

Anyway - from the description:

 Library `mouse3.el' lets you pop up such a menu by
 using only 'mouse-3' - no need to use the keyboard
 (hitting the 'Control' key). Yet you can still use
 'mouse-3' to extend and delete the selection.

 How does it work? [read that section]

That section tells you that "`mouse3.el' redefines
standard command 'mouse-save-then-kill' in a trivial
way to give you custom behavior for a second 'mouse-3'
click at the same spot."

Instead of a second single click always deleting, you
can use it to access a context menu, to delete or
perform any other actions.

Doesn't that remove the standard second-click-deletes 
behavior?  No, because it distinguishes a `mouse-3'
double-click (which performs the usual delete action)
from a second single click (which shows a context
menu - or in fact to do anything else you like).

Vanilla Emacs doesn't distinguish these two ways to
click `mouse-3' a second time, so it misses an
opportunity to provide both a menu and the standard
extend-or-delete-region behavior.

 The redefined `mouse-save-then-kill' command just uses 
 function `mouse3-second-click-command' to handle a
 second click at the same spot. That function returns
 the command that `mouse-save-then-kill' invokes:
 either the command that is the value of variable
 `mouse3-save-then-kill-command' or, if that is `nil'
 the command that is the value of user option
 `mouse3-second-click-default-command'.

The default value of that user option is command
`mouse3-popup-menu', which pops up a `Region' menu,
which generally has items that act on the region.
___

To obtain the vanilla Emacs behavior, customize that
option value to command `mouse3-kill/delete-region'.

To _always_ have `mouse-3' pop up a context menu,
set option `mouse3-menu-always-flag' to non-`nil', or
bind `mouse-3' to `mouse3-action-wo-save-then-kill'.

IOW, both vanilla Emacs's hard-coded behavior and
an always-use-context-menu behavior are trivial
subsets of what `mouse3.el' offer.