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

From: Juri Linkov <[email-masked]>
Date: Sat, 04 Dec 2021 21:50:20 +0200

> I found another odd case, but I'm not 100% sure the best way to fix it:
>
>   emacs -Q --eval '(context-menu-mode)'
>   C-h o identity RET
>   ;; Right-click somewhere in the Help buffer
>
> There's a doubled separator after "Next Topic". Looking at the code, this
> is because `help-mode-context-menu' inserts new items using `define-key',
> which has the effect of putting the new items *before* the (hidden) menu
> title. The resulting keymap ends up looking like this:
>
>   (keymap
>    (Previous\ Topic ...)
>    (Next\ Topic ...)
>    (help-mode-separator "--")
>    #("Context Menu" 0 12 (hide t))
>    (separator-undo "--")
>    ...)

The core function that displays the menu can handle
the menu title in the middle of the menu, so it wasn't
a problem until the recent need to remove duplicate items.

> Since there's a hidden item (the keymap title) between the
> `help-mode-separator' and `separator-undo'[1], the de-duplication doesn't
> handle that. Is there a standard/common way of defining a key such that it
> goes immediately *after* the keymap's title? I guess we could add
> `context-menu-top-separator' as an anchor (by analogy to
> `context-menu-middle-separator'), but maybe there's a simpler way...

I see no simpler way, so perhaps we need to add `context-menu-top-separator'.

> [1] As an aside, is there a standard naming convention to use here? Should
> "separator" go at the beginning of the name or the end?

`context-menu-middle-separator' is a function, so it requires the
`context-menu-' prefix.  It adds the menu item [middle-separator].
Since "middle" is an adjective, the word order can't be "separator-middle".
But "buffers-separator" doesn't look nicer than `separator-buffers'.

If you could propose a more consistent naming convention,
maybe it's not too late to rename these symbols on the release branch,
because after the release it will be impossible to rename them.