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

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

[nongnu] elpa/keycast 464bae181f 05/31: Show counter if a command is inv


From: ELPA Syncer
Subject: [nongnu] elpa/keycast 464bae181f 05/31: Show counter if a command is invoked more than once in a row
Date: Sun, 9 Jan 2022 05:58:37 -0500 (EST)

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

    Show counter if a command is invoked more than once in a row
    
    Closes #5.
    Closes #6.
---
 keycast.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/keycast.el b/keycast.el
index 789d4662b5..a6417a0086 100644
--- a/keycast.el
+++ b/keycast.el
@@ -1,6 +1,6 @@
 ;;; keycast.el --- Show current command and its key in the mode line  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2018  Jonas Bernoulli
+;; Copyright (C) 2018-2019  Jonas Bernoulli
 
 ;; Author: Jonas Bernoulli <jonas@bernoul.li>
 ;; Homepage: https://github.com/tarsius/keycast
@@ -147,9 +147,13 @@ instead."
 
 (defvar keycast--this-command nil)
 (defvar keycast--this-command-keys nil)
+(defvar keycast--command-repetitions 0)
 
 (defun keycast-mode-line-update ()
   "Update mode line with current `this-command' and `this-command-keys'."
+  (if (eq last-command this-command)
+      (cl-incf keycast--command-repetitions)
+    (setq keycast--command-repetitions 0))
   ;; Remember these values because the mode line update won't actually
   ;; happen until we return to the command loop and by that time these
   ;; values have been reset to nil.
@@ -219,8 +223,9 @@ instead."
                                (concat (make-string (ceiling pad 2) ?\s) key
                                        (make-string (floor   pad 2) ?\s)))
                              'face 'keycast-key)
-                 (format " %s" (propertize (symbol-name cmd)
-                                           'face 'keycast-command))))))))
+                 (propertize (format " %s" cmd) 'face 'keycast-command)
+                 (and (> keycast--command-repetitions 0)
+                      (format " x%s" (1+ keycast--command-repetitions)))))))))
 
 (put 'mode-line-keycast 'risky-local-variable t)
 (make-variable-buffer-local 'mode-line-keycast)



reply via email to

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