]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't show minibuffer keybindings for suggestions in read-extended-command
authorJuri Linkov <juri@linkov.net>
Wed, 16 Dec 2020 21:27:11 +0000 (23:27 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 16 Dec 2020 21:27:11 +0000 (23:27 +0200)
* lisp/simple.el (read-extended-command): Use 'affixation-function'
instead of 'annotation-function'.  (Bug#45035)
(read-extended-command--affixation): New function created from
'read-extended-command--annotation'.

lisp/simple.el

index 6059c23a14e490cc092c4a80774582a95b559786..090162b973a9ab161a58661751e0dab64e636df8 100644 (file)
@@ -1958,22 +1958,27 @@ to get different commands to edit and resubmit."
      (lambda (string pred action)
        (if (and suggest-key-bindings (eq action 'metadata))
           '(metadata
-            (annotation-function . read-extended-command--annotation)
+            (affixation-function . read-extended-command--affixation)
             (category . command))
          (complete-with-action action obarray string pred)))
      #'commandp t nil 'extended-command-history)))
 
-(defun read-extended-command--annotation (command-name)
-  (let* ((fun (and (stringp command-name) (intern-soft command-name)))
-         (binding (where-is-internal fun overriding-local-map t))
-         (obsolete (get fun 'byte-obsolete-info))
-         (alias (symbol-function fun)))
-    (cond ((symbolp alias)
-           (format " (%s)" alias))
-          (obsolete
-           (format " (%s)" (car obsolete)))
-          ((and binding (not (stringp binding)))
-           (format " (%s)" (key-description binding))))))
+(defun read-extended-command--affixation (command-names)
+  (with-selected-window (or (minibuffer-selected-window) (selected-window))
+    (mapcar
+     (lambda (command-name)
+       (let* ((fun (and (stringp command-name) (intern-soft command-name)))
+              (binding (where-is-internal fun overriding-local-map t))
+              (obsolete (get fun 'byte-obsolete-info))
+              (alias (symbol-function fun))
+              (suffix (cond ((symbolp alias)
+                             (format " (%s)" alias))
+                            (obsolete
+                             (format " (%s)" (car obsolete)))
+                            ((and binding (not (stringp binding)))
+                             (format " (%s)" (key-description binding))))))
+         (if suffix (list command-name suffix) command-name)))
+     command-names)))
 
 (defcustom suggest-key-bindings t
   "Non-nil means show the equivalent key-binding when M-x command has one.