aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-11-01 16:06:16 +0100
committerLars Ingebrigtsen2021-11-01 16:06:21 +0100
commita5d79fcfe83e3b87a5f044d062afb8d828bfa7b2 (patch)
treebc849f70b6c184ba1dc334d2ac53e2aac036c2f8
parentaa90de71a2d3344884a2622ceef00507bcdf28d2 (diff)
downloademacs-a5d79fcfe83e3b87a5f044d062afb8d828bfa7b2.tar.gz
emacs-a5d79fcfe83e3b87a5f044d062afb8d828bfa7b2.zip
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.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/help.el56
-rw-r--r--test/lisp/help-tests.el7
3 files changed, 39 insertions, 30 deletions
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
307 307
308* Incompatible Lisp Changes in Emacs 29.1 308* Incompatible Lisp Changes in Emacs 29.1
309 309
310** Keymap descriptions have changed.
311'help--describe-command', 'C-h b' and associated functions that output
312keymap descriptions have changed. In particular, prefix commands are
313not output at all, and instead of "??" for closures/functions,
314"[closure]"/"[lambda]" is output.
315
310--- 316---
311** 'downcase' details have changed slightly. 317** 'downcase' details have changed slightly.
312In certain locales, changing the case of an ASCII-range character may 318In 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."
1357 (insert "Keyboard Macro\n")) 1357 (insert "Keyboard Macro\n"))
1358 ((keymapp definition) 1358 ((keymapp definition)
1359 (insert "Prefix Command\n")) 1359 (insert "Prefix Command\n"))
1360 (t (insert "??\n"))))) 1360 ((byte-code-function-p definition)
1361 (insert "[byte-code]\n"))
1362 ((and (consp definition)
1363 (memq (car definition) '(closure lambda)))
1364 (insert (format "[%s]\n" (car definition))))
1365 (t
1366 (insert "??\n")))))
1361 1367
1362(defun help--describe-translation (definition) 1368(defun help--describe-translation (definition)
1363 ;; Converted from describe_translation in keymap.c. 1369 ;; Converted from describe_translation in keymap.c.
@@ -1456,10 +1462,6 @@ TRANSL, PARTIAL, SHADOW, NOMENU, MENTION-SHADOW are as in
1456 (definition (cadr elem)) 1462 (definition (cadr elem))
1457 (shadowed (caddr elem)) 1463 (shadowed (caddr elem))
1458 (end start)) 1464 (end start))
1459 (when first
1460 (setq help--previous-description-column 0)
1461 (insert "\n")
1462 (setq first nil))
1463 ;; Find consecutive chars that are identically defined. 1465 ;; Find consecutive chars that are identically defined.
1464 (when (fixnump start) 1466 (when (fixnump start)
1465 (while (and (cdr vect) 1467 (while (and (cdr vect)
@@ -1474,24 +1476,32 @@ TRANSL, PARTIAL, SHADOW, NOMENU, MENTION-SHADOW are as in
1474 (eq this-shadowed next-shadowed)))) 1476 (eq this-shadowed next-shadowed))))
1475 (setq vect (cdr vect)) 1477 (setq vect (cdr vect))
1476 (setq end (caar vect)))) 1478 (setq end (caar vect))))
1477 ;; Now START .. END is the range to describe next. 1479 (when (or (not (eq start end))
1478 ;; Insert the string to describe the event START. 1480 ;; Don't output keymap prefixes.
1479 (insert (help--key-description-fontified (vector start) prefix)) 1481 (not (keymapp definition)))
1480 (when (not (eq start end)) 1482 (when first
1481 (insert " .. " (help--key-description-fontified (vector end) prefix))) 1483 (setq help--previous-description-column 0)
1482 ;; Print a description of the definition of this character. 1484 (insert "\n")
1483 ;; Called function will take care of spacing out far enough 1485 (setq first nil))
1484 ;; for alignment purposes. 1486 ;; Now START .. END is the range to describe next.
1485 (if transl 1487 ;; Insert the string to describe the event START.
1486 (help--describe-translation definition) 1488 (insert (help--key-description-fontified (vector start) prefix))
1487 (help--describe-command definition)) 1489 (when (not (eq start end))
1488 ;; Print a description of the definition of this character. 1490 (insert " .. " (help--key-description-fontified (vector end)
1489 ;; elt_describer will take care of spacing out far enough for 1491 prefix)))
1490 ;; alignment purposes. 1492 ;; Print a description of the definition of this character.
1491 (when shadowed 1493 ;; Called function will take care of spacing out far enough
1492 (goto-char (max (1- (point)) (point-min))) 1494 ;; for alignment purposes.
1493 (insert "\n (this binding is currently shadowed)") 1495 (if transl
1494 (goto-char (min (1+ (point)) (point-max))))) 1496 (help--describe-translation definition)
1497 (help--describe-command definition))
1498 ;; Print a description of the definition of this character.
1499 ;; elt_describer will take care of spacing out far enough for
1500 ;; alignment purposes.
1501 (when shadowed
1502 (goto-char (max (1- (point)) (point-min)))
1503 (insert "\n (this binding is currently shadowed)")
1504 (goto-char (min (1+ (point)) (point-max))))))
1495 ;; Next item in list. 1505 ;; Next item in list.
1496 (setq vect (cdr vect)))))) 1506 (setq vect (cdr vect))))))
1497 1507
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
98TAB minibuffer-complete 98TAB minibuffer-complete
99C-j minibuffer-complete-and-exit 99C-j minibuffer-complete-and-exit
100RET minibuffer-complete-and-exit 100RET minibuffer-complete-and-exit
101ESC Prefix Command
102SPC minibuffer-complete-word 101SPC minibuffer-complete-word
103? minibuffer-completion-help 102? minibuffer-completion-help
104C-<tab> file-cache-minibuffer-complete 103C-<tab> file-cache-minibuffer-complete
@@ -109,11 +108,8 @@ C-<tab> file-cache-minibuffer-complete
109<prior> switch-to-completions 108<prior> switch-to-completions
110<up> previous-line-or-history-element 109<up> previous-line-or-history-element
111 110
112M-g Prefix Command
113M-v switch-to-completions 111M-v switch-to-completions
114 112
115M-g ESC Prefix Command
116
117M-< minibuffer-beginning-of-buffer 113M-< minibuffer-beginning-of-buffer
118M-n next-history-element 114M-n next-history-element
119M-p previous-history-element 115M-p previous-history-element
@@ -290,8 +286,6 @@ x foo-original
290 " 286 "
291Key Binding 287Key Binding
292------------------------------------------------------------------------------- 288-------------------------------------------------------------------------------
293<remap> Prefix Command
294
295<remap> <foo> bar 289<remap> <foo> bar
296"))))) 290")))))
297 291
@@ -323,7 +317,6 @@ C-a foo
323Key Binding 317Key Binding
324------------------------------------------------------------------------------- 318-------------------------------------------------------------------------------
325C-a foo 319C-a foo
326<menu-bar> Prefix Command
327 320
328<menu-bar> <foo> foo 321<menu-bar> <foo> foo
329"))))) 322")))))