aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-06-10 11:39:51 +0200
committerLars Ingebrigtsen2022-06-10 11:39:51 +0200
commit15a5c5ce40143edbdd436eeaa4cbb55f025f1771 (patch)
tree9003c7119931a522b02abad71fa8c021edc6a4e4
parent071722e41120f8894b5482d9eccc663a28f81058 (diff)
downloademacs-15a5c5ce40143edbdd436eeaa4cbb55f025f1771.tar.gz
emacs-15a5c5ce40143edbdd436eeaa4cbb55f025f1771.zip
Make describe-prefix-bindings say when there are no matches
* lisp/help.el (describe-prefix-bindings): Say when there are no bindings under a prefix (bug#55875), for instance in `C-c C-h' in a buffer with no `C-c' commands.
-rw-r--r--lisp/help.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/lisp/help.el b/lisp/help.el
index 4e0d807cb2c..abdce46edf3 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -392,16 +392,23 @@ If that doesn't give a function, return nil."
392The prefix described consists of all but the last event 392The prefix described consists of all but the last event
393of the key sequence that ran this command." 393of the key sequence that ran this command."
394 (interactive) 394 (interactive)
395 (let ((key (this-command-keys))) 395 (let* ((key (this-command-keys))
396 (describe-bindings 396 (prefix
397 (if (stringp key) 397 (if (stringp key)
398 (substring key 0 (1- (length key))) 398 (substring key 0 (1- (length key)))
399 (let ((prefix (make-vector (1- (length key)) nil)) 399 (let ((prefix (make-vector (1- (length key)) nil))
400 (i 0)) 400 (i 0))
401 (while (< i (length prefix)) 401 (while (< i (length prefix))
402 (aset prefix i (aref key i)) 402 (aset prefix i (aref key i))
403 (setq i (1+ i))) 403 (setq i (1+ i)))
404 prefix))))) 404 prefix))))
405 (describe-bindings prefix)
406 (with-current-buffer (help-buffer)
407 (when (< (buffer-size) 10)
408 (let ((inhibit-read-only t))
409 (insert (format "No commands with a binding that start with %s."
410 (help--key-description-fontified prefix))))))))
411
405;; Make C-h after a prefix, when not specifically bound, 412;; Make C-h after a prefix, when not specifically bound,
406;; run describe-prefix-bindings. 413;; run describe-prefix-bindings.
407(setq prefix-help-command 'describe-prefix-bindings) 414(setq prefix-help-command 'describe-prefix-bindings)