Subject: Re: bug#39035: Show key bindings on M-x completion

From: Juri Linkov <[email-masked]>
Date: Thu, 30 Jan 2020 01:42:55 +0200

tags 39035 fixed
close 39035 28.1
quit

>> +       (if (and suggest-key-bindings (eq action 'metadata))
>> +	   '(metadata
>> +	     (annotation-function . read-extended-command--annotation)
>> +	     (category . suggest-key-bindings))
>
> The `category` should describe the things that are being completed,
> i.e. `command` rather than `suggest-key-bindings`.

Fixed.

>> +(defun read-extended-command--annotation (command-name)
>> +  (let* ((function (and (stringp command-name) (intern-soft command-name)))
>> +         (binding (where-is-internal function overriding-local-map t)))
>> +    (when binding
>> +      (format " (%s)" (if (stringp binding)
>> +                          (concat "M-x " binding " RET")
>> +                        (key-description binding))))))
>
> Since we're in the middle of a `M-x`, I think a `M-x foo RET` annotation
> would not be useful at all: better not put anything when a command has
> no corresponding key binding (one could argue that it could be useful to
> put the `M-x <shortenedname> RET` like `M-x re-u RET` for
> `rename-uniquely`, but it would be too costly to compute and still
> wouldn't be terribly useful).

Thanks for suggestions, the fixed patch was pushed to master.