Subject: bug#71761: 29.3; Emacs-Lisp menu display is incorrect during Edebug

From: Stefan Monnier <[email-masked]>
Date: Sun, 30 Jun 2024 00:12:46 -0400

> AFAICT, the duplicate menu is the consequence of the fact that
> edebug-mode has its keymap inherit from emacs-lisp-mode:
>
>   (defvar-keymap edebug-mode-map
>     :parent emacs-lisp-mode-map
>
> So when Edebug is activated, it wants to display yet another "Emacs
> Lisp" menu on the menu bar.

Yup, it's a longstanding problem.  E.g. we don't really have a way for
major/minor mode keymaps to *add* elements to an existing menu.

> Stefan, do you see a way to avoid that?

I think `keymap-canonicalize` is the place where we could try to handle
that, but IIRC the menu code doesn't really use it, and for "good"
reasons: we can't really take all the active keymaps and merge them into
a single canonicalized keymap because it's hard for such a merge to be
both semantically correct at the same time as providing elements in the
expected visual order (e.g. the ordering of top-level menus would
naturally be in the order of priority of the keymaps from where they
come, which would put minor mode menus at the top-left, followed by
major mode menus followed by global menus, whereas we want the exact
opposite ordering visually).

        Stefan