Function: help-quick
help-quick is an interactive and byte-compiled function defined in
help.el.gz.
Signature
(help-quick)
Documentation
Display a quick-help buffer showing popular commands and their bindings.
The window showing quick-help can be toggled using C-h C-q (help-quick-toggle).
You can click on a key binding shown in the quick-help buffer to display
the documentation of the command bound to that key sequence.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/help.el.gz
;; Inspired by a mg fork (https://github.com/troglobit/mg)
(defun help-quick ()
"Display a quick-help buffer showing popular commands and their bindings.
The window showing quick-help can be toggled using \\[help-quick-toggle].
You can click on a key binding shown in the quick-help buffer to display
the documentation of the command bound to that key sequence."
(interactive)
(with-current-buffer (get-buffer-create "*Quick Help*")
(let ((inhibit-read-only t) (padding 2) blocks)
;; Go through every section and prepare a text-rectangle to be
;; inserted later.
(dolist (section help-quick-sections)
(let ((max-key-len 0) (max-cmd-len 0) keys)
(dolist (ent (reverse (cdr section)))
(catch 'skip
(let* ((bind (where-is-internal (car ent) nil t))
(key (if bind
(propertize
(key-description bind)
'face 'help-key-binding)
(throw 'skip nil))))
(setq max-cmd-len (max (length (cdr ent)) max-cmd-len)
max-key-len (max (length key) max-key-len))
(push (list key (cdr ent) (car ent)) keys))))
(when keys
(let ((fmt (format "%%-%ds %%-%ds%s" max-key-len max-cmd-len
(make-string padding ?\s)))
(width (+ max-key-len 1 max-cmd-len padding)))
(push `(,width
,(propertize
(concat
(car section)
(make-string (- width (length (car section))) ?\s))
'face 'bold)
,@(mapcar (lambda (ent)
(format fmt
(propertize
(car ent)
'quick-help-cmd
(caddr ent))
(cadr ent)))
keys))
blocks)))))
;; Insert each rectangle in order until they don't fit into the
;; frame any more, in which case the next sections are inserted
;; in a new "line".
(erase-buffer)
(dolist (block (nreverse blocks))
(when (> (+ (car block) (current-column)) (frame-width))
(goto-char (point-max))
(newline 2))
(save-excursion
(insert-rectangle (cdr block)))
(end-of-line))
(delete-trailing-whitespace)
(save-excursion
(goto-char (point-min))
(while-let ((match (text-property-search-forward 'quick-help-cmd)))
(make-text-button (prop-match-beginning match)
(prop-match-end match)
'mouse-face 'highlight
'button t
'keymap button-map
'action #'describe-symbol
'button-data (prop-match-value match)))))
(help-mode)
;; Display the buffer at the bottom of the frame...
(with-selected-window (display-buffer-at-bottom (current-buffer) '())
;; ... mark it as dedicated to prevent focus from being stolen
(set-window-dedicated-p (selected-window) t)
;; ... and shrink it immediately.
(fit-window-to-buffer))
(message
(substitute-command-keys "Toggle display of quick-help buffer using \\[help-quick-toggle]."))))