From 9ac12592781934bcd934bc0cae71a637311119ec Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 19 Apr 2023 20:46:40 +0300 Subject: [PATCH] Fix display of menu-bar bindings of commands in *Help* buffers * lisp/help-fns.el (help-fns--insert-menu-bindings): Propertize with 'help-key-binding' face only the menu items, not the arrows between successive items. This is because 'char-displayable-p' is unreliable when we propertize the character with an arbitrary face: that face could specify a font which doesn't support the character after all, while 'char-displayable-p' assumes there are no restrictions on fonts that can be used for displaying the character. Also, make the code more efficient by avoiding the call to 'char-displayable-p' inside the loop. --- lisp/help-fns.el | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index a1fc2267564..be13d40cfa3 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -592,22 +592,22 @@ the C sources, too." ;; First collect all the printed representations of menus. (dolist (menu menus) (let ((map (lookup-key global-map (seq-take menu 1))) - (string nil)) + (string nil) + (sep (if (char-displayable-p ?→) " → " " => "))) (seq-do-indexed (lambda (entry level) (when (symbolp map) (setq map (symbol-function map))) (when-let ((elem (assq entry (cdr map)))) (when (> level 0) - (push (if (char-displayable-p ?→) - " → " - " => ") - string)) + (push sep string)) (if (eq (nth 1 elem) 'menu-item) (progn - (push (nth 2 elem) string) + (push (propertize (nth 2 elem) 'face 'help-key-binding) + string) (setq map (cadddr elem))) - (push (nth 1 elem) string) + (push (propertize (nth 1 elem) 'face 'help-key-binding) + string) (setq map (cddr elem))))) (cdr (seq-into menu 'list))) (when string @@ -622,8 +622,7 @@ the C sources, too." (cond ((zerop i) "") ((= i (1- (length menus))) " and ") (t ", ")) - (propertize (string-join (nreverse string)) - 'face 'help-key-binding))) + (string-join (nreverse string)))) strings)))) (defun help-fns--compiler-macro (function)