Subject: Re: bug#52237: 29.0.50; [PATCH] Doubled separators in context-menu-mode

From: Jim Porter <[email-masked]>
Date: Thu, 2 Dec 2021 10:09:29 -0800

On 12/2/2021 9:31 AM, Drew Adams wrote:
> Why should any repetition of separators be removed
> or ignored?
> 
> If someone codes that then they presumably want that.
> Vanilla Emacs need not code such repetition.

As far as I understand (which isn't very far; I've only just started 
tinkering with context-menu-mode), the general idea is that the context 
menu is generated dynamically by a list of functions stored in 
`context-menu-functions'. Each of these can add items to the menu. Some 
of these, like `context-menu-minor', first add a separator and then 
iterate over a list of things (minor modes in this case) to add more 
items. If that list is empty, you just get a separator, but then that 
separator might get doubled up with the separator from the *next* 
context menu function.

In some cases, these separators are used as anchors to determine where 
to put the results of *later* context menu functions too. For example, 
`context-menu-middle-separator' is one of the default entries in 
`context-menu-functions', and as the name implies, it *only* adds a 
separator. Some other context menu functions (e.g. `elisp-context-menu') 
look for that separator to know where to put new menu items, so we want 
that separator to be there during construction, even if it might result 
in duplicated separators by the end (which `context-menu-map' would then 
strip out before display). This logic could apply to separators 
generated by other functions too, such as `context-menu-minor' described 
above.