unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: "Omar Antolín Camarena" <omar@matem.unam.mx>
Cc: 45035@debbugs.gnu.org
Subject: bug#45035: 28.0.50; Command completion annotations show minibuffer keybindings
Date: Wed, 16 Dec 2020 11:15:40 +0200	[thread overview]
Message-ID: <87wnxiqezv.fsf@mail.linkov.net> (raw)
In-Reply-To: <86pn3mpbxf.fsf@matem.unam.mx> ("Omar Antolín Camarena"'s message of "Sun, 06 Dec 2020 20:50:04 -0600")

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

>> Thanks, I think your idea is correct.  But I'm not sure if
>> minibuffer-completion-help is the right place for wrapping in
>> with-minibuffer-selected-window.  This means that all calls of
>> annotation-function will be in the original buffer, whereas
>> only read-extended-command--annotation needs such wrapping.
>
> Oh, that's a very good point. Probably it would be best to leave
> minibuffer-completion-help as is, and change only
> read-extended-command--annotation.
>
>> Or do you care that such wrapping will be called for every command
>> in read-extended-command--annotation?  Then instead of annotation-function
>> you could try to use a new function affixation-function that is called
>> only once, so you could add wrapping to it.
>
> My Emacs doesn't have affixation-function yet, so I don't really know
> anything about it.

I'm sorry that your version of Emacs is not updated too often.
So here I created a patch based on current master, and after
pushing it, sometimes it will arrive to your updated version.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: read-extended-command--affixation.patch --]
[-- Type: text/x-diff, Size: 2057 bytes --]

diff --git a/lisp/simple.el b/lisp/simple.el
index c309df11ad..f669996c2f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1958,22 +1958,27 @@ read-extended-command
      (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.

  reply	other threads:[~2020-12-16  9:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04  1:00 bug#45035: 28.0.50; Command completion annotations show minibuffer keybindings Omar Antolín Camarena
2020-12-05 20:51 ` Juri Linkov
2020-12-07  2:50   ` Omar Antolín Camarena
2020-12-16  9:15     ` Juri Linkov [this message]
2020-12-16 21:27       ` Omar Antolín Camarena
2020-12-16 21:27       ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnxiqezv.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=45035@debbugs.gnu.org \
    --cc=omar@matem.unam.mx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).