Function: help-fns--key-bindings
help-fns--key-bindings is a byte-compiled function defined in
help-fns.el.gz.
Signature
(help-fns--key-bindings FUNCTION)
Source Code
;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
(defun help-fns--key-bindings (function)
(when (commandp function)
(let ((pt2 (with-current-buffer standard-output (point)))
(remapped (command-remapping function)))
(unless (memq remapped '(ignore undefined))
(let* ((all-keys
(with-current-buffer
(or describe-function-orig-buffer (current-buffer))
(where-is-internal
(or remapped function) overriding-local-map nil nil)))
(seps (seq-group-by
(lambda (key)
(and (vectorp key)
(eq (elt key 0) 'menu-bar)))
all-keys))
(keys (cdr (assq nil seps)))
(menus (cdr (assq t seps)))
non-modified-keys)
(if (and (eq function 'self-insert-command)
(vectorp (car-safe keys))
(consp (aref (car keys) 0)))
(princ "It is bound to many ordinary text characters.\n")
;; Which non-control non-meta keys run this command?
(dolist (key keys)
(if (member (event-modifiers (aref key 0)) '(nil (shift)))
(push key non-modified-keys)))
(when remapped
(princ "Its keys are remapped to ")
(princ (if (symbolp remapped)
(format-message "`%s'" remapped)
"an anonymous command"))
(princ ".\n"))
(when keys
(princ (if remapped
"Without this remapping, it would be bound to "
"It is bound to "))
;; If lots of ordinary text characters run this command,
;; don't mention them one by one.
(if (< (length non-modified-keys) 10)
(with-current-buffer standard-output
(help-fns--insert-bindings keys))
(dolist (key non-modified-keys)
(setq keys (delq key keys)))
(if keys
(with-current-buffer standard-output
(help-fns--insert-bindings keys)
(insert ", and many ordinary text characters"))
(princ "many ordinary text characters."))))
(when (or remapped keys non-modified-keys)
(princ ".")
(terpri)))
(with-current-buffer standard-output
(fill-region-as-paragraph pt2 (point))
(unless (bolp)
(insert "\n"))
(when menus
(let ((start (point)))
(help-fns--insert-menu-bindings
menus
(concat "It can " (and keys "also ")
"be invoked from the menu: "))
(fill-region-as-paragraph start (point))))
(ensure-empty-lines)))))))