From: Lars Ingebrigtsen Date: Mon, 1 Nov 2021 15:06:16 +0000 (+0100) Subject: Don't output prefix keys in `C-h b', and output more data on objects X-Git-Tag: emacs-29.0.90~3671^2~298 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a5d79fcfe83e3b87a5f044d062afb8d828bfa7b2;p=emacs.git Don't output prefix keys in `C-h b', and output more data on objects * lisp/help.el (help--describe-command): Output [closure/lambda/byte-code] for those types of objects. (describe-map): Don't output prefix keys. --- diff --git a/etc/NEWS b/etc/NEWS index 0aff35627af..114441f1b6a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -307,6 +307,12 @@ Emacs buffers, like indentation and the like. The new ert function * Incompatible Lisp Changes in Emacs 29.1 +** Keymap descriptions have changed. +'help--describe-command', 'C-h b' and associated functions that output +keymap descriptions have changed. In particular, prefix commands are +not output at all, and instead of "??" for closures/functions, +"[closure]"/"[lambda]" is output. + --- ** 'downcase' details have changed slightly. In certain locales, changing the case of an ASCII-range character may diff --git a/lisp/help.el b/lisp/help.el index acd8a123ab5..293dd445459 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1357,7 +1357,13 @@ Return nil if the key sequence is too long." (insert "Keyboard Macro\n")) ((keymapp definition) (insert "Prefix Command\n")) - (t (insert "??\n"))))) + ((byte-code-function-p definition) + (insert "[byte-code]\n")) + ((and (consp definition) + (memq (car definition) '(closure lambda))) + (insert (format "[%s]\n" (car definition)))) + (t + (insert "??\n"))))) (defun help--describe-translation (definition) ;; Converted from describe_translation in keymap.c. @@ -1456,10 +1462,6 @@ TRANSL, PARTIAL, SHADOW, NOMENU, MENTION-SHADOW are as in (definition (cadr elem)) (shadowed (caddr elem)) (end start)) - (when first - (setq help--previous-description-column 0) - (insert "\n") - (setq first nil)) ;; Find consecutive chars that are identically defined. (when (fixnump start) (while (and (cdr vect) @@ -1474,24 +1476,32 @@ TRANSL, PARTIAL, SHADOW, NOMENU, MENTION-SHADOW are as in (eq this-shadowed next-shadowed)))) (setq vect (cdr vect)) (setq end (caar vect)))) - ;; Now START .. END is the range to describe next. - ;; Insert the string to describe the event START. - (insert (help--key-description-fontified (vector start) prefix)) - (when (not (eq start end)) - (insert " .. " (help--key-description-fontified (vector end) prefix))) - ;; Print a description of the definition of this character. - ;; Called function will take care of spacing out far enough - ;; for alignment purposes. - (if transl - (help--describe-translation definition) - (help--describe-command definition)) - ;; Print a description of the definition of this character. - ;; elt_describer will take care of spacing out far enough for - ;; alignment purposes. - (when shadowed - (goto-char (max (1- (point)) (point-min))) - (insert "\n (this binding is currently shadowed)") - (goto-char (min (1+ (point)) (point-max))))) + (when (or (not (eq start end)) + ;; Don't output keymap prefixes. + (not (keymapp definition))) + (when first + (setq help--previous-description-column 0) + (insert "\n") + (setq first nil)) + ;; Now START .. END is the range to describe next. + ;; Insert the string to describe the event START. + (insert (help--key-description-fontified (vector start) prefix)) + (when (not (eq start end)) + (insert " .. " (help--key-description-fontified (vector end) + prefix))) + ;; Print a description of the definition of this character. + ;; Called function will take care of spacing out far enough + ;; for alignment purposes. + (if transl + (help--describe-translation definition) + (help--describe-command definition)) + ;; Print a description of the definition of this character. + ;; elt_describer will take care of spacing out far enough for + ;; alignment purposes. + (when shadowed + (goto-char (max (1- (point)) (point-min))) + (insert "\n (this binding is currently shadowed)") + (goto-char (min (1+ (point)) (point-max)))))) ;; Next item in list. (setq vect (cdr vect)))))) diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el index 05ade12cf19..1234e5fb293 100644 --- a/test/lisp/help-tests.el +++ b/test/lisp/help-tests.el @@ -98,7 +98,6 @@ C-g abort-minibuffers TAB minibuffer-complete C-j minibuffer-complete-and-exit RET minibuffer-complete-and-exit -ESC Prefix Command SPC minibuffer-complete-word ? minibuffer-completion-help C- file-cache-minibuffer-complete @@ -109,11 +108,8 @@ C- file-cache-minibuffer-complete switch-to-completions previous-line-or-history-element -M-g Prefix Command M-v switch-to-completions -M-g ESC Prefix Command - M-< minibuffer-beginning-of-buffer M-n next-history-element M-p previous-history-element @@ -290,8 +286,6 @@ x foo-original " Key Binding ------------------------------------------------------------------------------- - Prefix Command - bar "))))) @@ -323,7 +317,6 @@ C-a foo Key Binding ------------------------------------------------------------------------------- C-a foo - Prefix Command foo ")))))