diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-01 03:18:02 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-01 03:18:02 +0100 |
commit | 1200ecba27ca567817ffeecdebf6fb80928c9c2c (patch) | |
tree | 3ebc7ddb7942ae642c6849a85804b9fcaa2fcf09 /lisp | |
parent | 686d85c767d7c14d0cc6351701396cd71da37630 (diff) | |
download | emacs-1200ecba27ca567817ffeecdebf6fb80928c9c2c.tar.gz emacs-1200ecba27ca567817ffeecdebf6fb80928c9c2c.tar.bz2 emacs-1200ecba27ca567817ffeecdebf6fb80928c9c2c.zip |
Don't print empty keymaps in `C-h b'
* lisp/help.el (describe-map-tree): Don't print the heading if the
keymap is empty (bug#22334). Tweak the look to compress it more
vertically.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/help.el | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lisp/help.el b/lisp/help.el index afb91a580aa..c4f81401eb9 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1275,17 +1275,8 @@ Any inserted text ends in two newlines (used by result)) amaps)) (maps orig-maps) - (print-title (or maps always-title))) - ;; Print title. - (when print-title - (insert (concat (if title - (concat title - (if prefix - (concat " Starting With " - (help--key-description-fontified prefix))) - ":\n")) - "key binding\n" - "--- -------\n"))) + (print-title (or maps always-title)) + (start-point (point))) ;; Describe key bindings. (setq help--keymaps-seen nil) (while (consp maps) @@ -1310,8 +1301,24 @@ Any inserted text ends in two newlines (used by (describe-map (cdr elt) elt-prefix transl partial sub-shadows no-menu mention-shadow))) (setq maps (cdr maps))) - (when print-title - (insert "\n")))) + ;; Print title... + (when (and print-title + ;; ... unless the keymap was empty. + (/= (point) start-point)) + (save-excursion + (goto-char start-point) + (when (eolp) + (delete-region (point) (1+ (point)))) + (insert + (concat + (if title + (concat title + (if prefix + (concat " Starting With " + (help--key-description-fontified prefix))) + ":\n")) + "\nkey binding\n" + (make-separator-line))))))) (defun help--shadow-lookup (keymap key accept-default remap) "Like `lookup-key', but with command remapping. |