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

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

[nongnu] elpa/keycast c4a995a468: keycast--update: Handle prefix command


From: ELPA Syncer
Subject: [nongnu] elpa/keycast c4a995a468: keycast--update: Handle prefix command peculiarity
Date: Wed, 17 Jan 2024 10:00:27 -0500 (EST)

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

    keycast--update: Handle prefix command peculiarity
    
    Closes #32.
---
 keycast.el | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/keycast.el b/keycast.el
index dac4e6c081..6c167edf2f 100644
--- a/keycast.el
+++ b/keycast.el
@@ -366,6 +366,12 @@ t to show the actual COMMAND, or a symbol to be shown 
instead."
 (defvar keycast--command-repetitions 0)
 (defvar keycast--reading-passwd nil)
 
+(defvar keycast--prefix-argument-commands
+  '(universal-argument
+    universal-argument-more
+    negative-argument
+    digit-argument))
+
 (defun keycast--minibuffer-exit ()
   (setq keycast--minibuffer-exited
         (cons (this-single-command-keys) this-command))
@@ -378,13 +384,19 @@ 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))
-    ;; If a valid but incomplete prefix sequence is followed by
-    ;; an unbound key, then Emacs calls the `undefined' command
-    ;; but does not set `this-command', which is nil instead.
-    (when (and (not cmd)
-               (>= (length key) 1)
-               (eq (aref key (1- (length key))) ?\C-g))
-      (setq cmd 'undefined))
+    (cond
+     ((memq this-original-command keycast--prefix-argument-commands)
+      ;; These commands set `this-command' to `last-command', to
+      ;; prevent `last-command' being the prefix command, for the
+      ;; command that uses the prefix argument.
+      (setq cmd this-original-command))
+     ((and (not cmd)
+           (>= (length key) 1)
+           (eq (aref key (1- (length key))) ?\C-g))
+      ;; If a valid but incomplete prefix sequence is followed by
+      ;; an unbound key, then Emacs calls the `undefined' command
+      ;; but does not set `this-command', which is nil instead.
+      (setq cmd 'undefined)))
     (cond
      ;; Special handling for `execute-extended-command'.
      ((eq this-original-command 'execute-extended-command)



reply via email to

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