Subject: Re: bug#76172: 31.0.50; C-h f menu-bar-open-mouse signals error

From: Stefan Kangas <[email-masked]>
Date: Mon, 10 Feb 2025 07:19:38 -0600

tags 76172 + patch
thanks

Gerd Möllmann <[email-masked]> writes:

> 1. emacs -Q -nw
> 2. C-h f menu-bar-open-mouse RET
>
> => Wrong type argument: listp, menu-bar-open-mouse

It looks like this special case is just not covered.  Evaluating

    (car (cdr (cdr (assq 'menu-bar global-map))))

leads to

    (mouse-1 . menu-bar-open-mouse)

but that has a different form than all other menu bar entries, and the
`(nth 1 ...)` call will obviously not work.

This should fix it:

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 9324cf85454..6112df99850 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -649,7 +649,8 @@ help-fns--insert-menu-bindings
          (lambda (entry level)
            (when (symbolp map)
              (setq map (symbol-function map)))
-           (when-let* ((elem (assq entry (cdr map))))
+           (when-let* ((elem (assq entry (cdr map)))
+                       (_ (proper-list-p elem)))
              (when (> level 0)
                (push sep string))
              (if (eq (nth 1 elem) 'menu-item)