emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/keycast f3509489f2 2/6: keycast--update: Fix special-handl


From: ELPA Syncer
Subject: [nongnu] elpa/keycast f3509489f2 2/6: keycast--update: Fix special-handling of execute-extended-command
Date: Tue, 16 Jan 2024 16:00:10 -0500 (EST)

branch: elpa/keycast
commit f3509489f279d5756ad3662eaad7e049c5397e92
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    keycast--update: Fix special-handling of execute-extended-command
---
 keycast.el | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/keycast.el b/keycast.el
index a43f3ea5b2..95c42e36fa 100644
--- a/keycast.el
+++ b/keycast.el
@@ -347,23 +347,24 @@ t to show the actual COMMAND, or a symbol to be shown 
instead."
 (defun keycast--update ()
   (let ((key (this-single-command-keys))
         (cmd this-command))
-    (when (and keycast--minibuffer-exited
-               (or (not (equal key []))
-                   (not (eq this-original-command 'execute-extended-command))))
-      ;; Show the command that exited the minibuffer instead of
-      ;; once more showing the command that used the minibuffer.
+    (cond
+     ;; Special handling for `execute-extended-command'.
+     ((eq this-original-command 'execute-extended-command)
+      ;; Instead of "M-x t h e - c o m m a n d RET", just use
+      ;; "M-x", because we follow that up with the command anyway.
+      (setq key [?\M-x]))
+     ;; If a command uses the minibuffer then `post-command-hook'
+     ;; gets called twice on behalf of that command:
+     ((equal key [])
+      ;; 1. When the minibuffer is entered.  The key is void in that
+      ;;    case, which allows us to detect that it is the first call,
+      ;;    but also means we have to get the actual key like this.
+      (setq key (this-single-command-raw-keys)))
+     (keycast--minibuffer-exited
+      ;; 2. When the minibuffer is exited (unless it is aborted).
       (setq key (car keycast--minibuffer-exited))
-      (setq cmd (cdr keycast--minibuffer-exited)))
+      (setq cmd (cdr keycast--minibuffer-exited))))
     (setq keycast--minibuffer-exited nil)
-    (when (or
-           ;; If a command uses the minibuffer, then
-           ;; `post-command-hook' gets called twice (unless the
-           ;; minibuffer is aborted).  This is the first call.
-           (equal key [])
-           ;; `execute-extended-command' intentionally corrupts
-           ;; the value returned by `this-single-command-keys'.
-           (eq (aref key 0) ?\M-x))
-      (setq key (this-single-command-raw-keys)))
     (setq keycast--this-command-keys key)
     (setq keycast--this-command-desc
           (cond ((symbolp cmd) cmd)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]