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.
This commit is contained in:
Lars Ingebrigtsen 2021-11-01 16:06:16 +01:00
parent aa90de71a2
commit a5d79fcfe8
3 changed files with 39 additions and 30 deletions

View file

@ -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

View file

@ -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))))))

View file

@ -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-<tab> file-cache-minibuffer-complete
@ -109,11 +108,8 @@ C-<tab> file-cache-minibuffer-complete
<prior> switch-to-completions
<up> 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
-------------------------------------------------------------------------------
<remap> Prefix Command
<remap> <foo> bar
")))))
@ -323,7 +317,6 @@ C-a foo
Key Binding
-------------------------------------------------------------------------------
C-a foo
<menu-bar> Prefix Command
<menu-bar> <foo> foo
")))))