aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el33
1 files changed, 23 insertions, 10 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 2ec3da680f8..09447900ded 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1788,23 +1788,36 @@ to get different commands to edit and resubmit."
1788 ;; and it serves as a shorthand for "Extended command: ". 1788 ;; and it serves as a shorthand for "Extended command: ".
1789 "M-x ") 1789 "M-x ")
1790 (lambda (string pred action) 1790 (lambda (string pred action)
1791 (let ((pred 1791 (if (and suggest-key-bindings (eq action 'metadata))
1792 (if (memq action '(nil t)) 1792 '(metadata
1793 ;; Exclude obsolete commands from completions. 1793 (annotation-function . read-extended-command--annotation)
1794 (lambda (sym) 1794 (category . command))
1795 (and (funcall pred sym) 1795 (let ((pred
1796 (or (equal string (symbol-name sym)) 1796 (if (memq action '(nil t))
1797 (not (get sym 'byte-obsolete-info))))) 1797 ;; Exclude obsolete commands from completions.
1798 pred))) 1798 (lambda (sym)
1799 (complete-with-action action obarray string pred))) 1799 (and (funcall pred sym)
1800 (or (equal string (symbol-name sym))
1801 (not (get sym 'byte-obsolete-info)))))
1802 pred)))
1803 (complete-with-action action obarray string pred))))
1800 #'commandp t nil 'extended-command-history))) 1804 #'commandp t nil 'extended-command-history)))
1801 1805
1806(defun read-extended-command--annotation (command-name)
1807 (let* ((function (and (stringp command-name) (intern-soft command-name)))
1808 (binding (where-is-internal function overriding-local-map t)))
1809 (when (and binding (not (stringp binding)))
1810 (format " (%s)" (key-description binding)))))
1811
1802(defcustom suggest-key-bindings t 1812(defcustom suggest-key-bindings t
1803 "Non-nil means show the equivalent key-binding when M-x command has one. 1813 "Non-nil means show the equivalent key-binding when M-x command has one.
1804The value can be a length of time to show the message for. 1814The value can be a length of time to show the message for.
1805If the value is non-nil and not a number, we wait 2 seconds. 1815If the value is non-nil and not a number, we wait 2 seconds.
1806 1816
1807Also see `extended-command-suggest-shorter'." 1817Also see `extended-command-suggest-shorter'.
1818
1819Equivalent key-bindings are also shown in the completion list of
1820M-x for all commands that have them."
1808 :group 'keyboard 1821 :group 'keyboard
1809 :type '(choice (const :tag "off" nil) 1822 :type '(choice (const :tag "off" nil)
1810 (integer :tag "time" 2) 1823 (integer :tag "time" 2)