Change the display of menu bindings in *Help*

* lisp/help-fns.el (help-fns--insert-menu-bindings): New function
to describe menu entries more fully (bug#52870).
(help-fns--key-bindings): Use it.
This commit is contained in:
Lars Ingebrigtsen 2022-04-25 21:14:24 +02:00
parent f2a4dc66c2
commit fd1ca094bc
2 changed files with 40 additions and 3 deletions

View file

@ -416,6 +416,18 @@ command also works for non-Emoji characters.)
** Help
---
*** Commands like 'C-h f' have changed how they describe menu bindings.
For instance, previously a command might be described as having the
following bindings:
It is bound to <open>, C-x C-f, <menu-bar> <file> <new-file>.
This has been changed to:
It is bound to <open> and C-x C-f.
It can also be invoked from the menu: File → Visit New File....
+++
*** The 'C-h .' command now accepts a prefix argument.
'C-u C-h .' would previously inhibit displaying a warning message if

View file

@ -568,9 +568,7 @@ the C sources, too."
(insert (concat "It can "
(and keys "also ")
"be invoked from the menu: "))
;; FIXME: Should insert menu names instead of key
;; binding names.
(help-fns--insert-bindings menus)
(help-fns--insert-menu-bindings menus)
(insert ".")
(fill-region-as-paragraph start (point))))
(ensure-empty-lines)))))))
@ -584,6 +582,33 @@ the C sources, too."
(insert (help--key-description-fontified key)))
keys))
(defun help-fns--insert-menu-bindings (menus)
(seq-do-indexed
(lambda (menu i)
(insert
(cond ((zerop i) "")
((= i (1- (length menus))) " and ")
(t ", ")))
(let ((map (lookup-key global-map (seq-take menu 1)))
(start (point)))
(seq-do-indexed
(lambda (entry level)
(when (> level 0)
(insert
(if (char-displayable-p ?→)
""
" => ")))
(let ((elem (assq entry (cdr map))))
(if (eq (nth 1 elem) 'menu-item)
(progn
(insert (nth 2 elem))
(setq map (cadddr elem)))
(insert (nth 1 elem))
(setq map (cddr elem)))))
(cdr (seq-into menu 'list)))
(put-text-property start (point) 'face 'help-key-binding)))
menus))
(defun help-fns--compiler-macro (function)
(let ((handler (function-get function 'compiler-macro)))
(when handler