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

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

[nongnu] elpa/keycast a4329bc142 2/3: keymap-log-mode: Show repeated com


From: ELPA Syncer
Subject: [nongnu] elpa/keycast a4329bc142 2/3: keymap-log-mode: Show repeated commands only once with a counter
Date: Sat, 15 Jan 2022 10:58:31 -0500 (EST)

branch: elpa/keycast
commit a4329bc142f280cd8d9587fa2d53c5cd62d2e428
Author: Guangwang Huang <whatacold@gmail.com>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    keymap-log-mode: Show repeated commands only once with a counter
    
    Closes #21.
    
    Co-authored-by: Guangwang Huang <whatacold@gmail.com>
---
 keycast.el | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/keycast.el b/keycast.el
index ba0346580f..f0c3565cca 100644
--- a/keycast.el
+++ b/keycast.el
@@ -107,7 +107,8 @@ with no argument and acts on `selected-window'.
 %K The key with no styling and without any padding.
 %c The command using the `keycast-command' face.
 %C The command with no styling.
-%r The times the command was repeated."
+%r The times the command was repeated.
+%R The times the command was repeated using the `shadow' face."
   :package-version '(keycast . "1.0.3")
   :group 'keycast
   :type 'integer)
@@ -153,7 +154,7 @@ instead."
                         (const   :tag "Use actual command" t)
                         (symbol  :tag "Substitute command")))))
 
-(defcustom keycast-log-format "%-20K%C\n"
+(defcustom keycast-log-format "%-20K%C%R\n"
   "The format spec used by `keycast-log-mode'.
 
 %s `keycast-separator-width' spaces.
@@ -161,7 +162,8 @@ instead."
 %K The key with no styling and without any padding.
 %c The command using the `keycast-command' face.
 %C The command with no styling.
-%r The times the command was repeated."
+%r The times the command was repeated.
+%R The times the command was repeated using the `shadow' face."
   :package-version '(keycast . "2.0.0")
   :group 'keycast
   :type 'string)
@@ -244,7 +246,10 @@ instead."
                          (let ((pad (max 2 (- 5 (length key)))))
                            (concat (make-string (ceiling pad 2) ?\s) key
                                    (make-string (floor   pad 2) ?\s)))))
-                    (c (format " %s" cmd)))
+                    (c (format " %s" cmd))
+                    (r (if (> keycast--command-repetitions 0)
+                           (format " x%s" (1+ keycast--command-repetitions))
+                         "")))
                 (format-spec
                  format
                  `((?s . ,(make-string keycast-separator-width ?\s))
@@ -252,9 +257,8 @@ instead."
                    (?K . ,key)
                    (?c . ,(propertize c 'face 'keycast-command))
                    (?C . ,c)
-                   (?r . ,(if (> keycast--command-repetitions 0)
-                              (format " x%s" (1+ keycast--command-repetitions))
-                            "")))))))))
+                   (?r . ,r)
+                   (?R . ,(propertize r 'face 'shadow)))))))))
 
 (defun keycast--read-passwd (fn prompt &optional confirm default)
   (let ((keycast--reading-passwd t))
@@ -352,6 +356,12 @@ instead."
       (with-current-buffer buf
         (goto-char (if keycast-log-newest-first (point-min) (point-max)))
         (let ((inhibit-read-only t))
+          (when (and (> keycast--command-repetitions 0)
+                     (string-match-p "%[rR]" keycast-log-format))
+            (unless keycast-log-newest-first
+              (backward-char))
+            (delete-region (line-beginning-position)
+                           (1+ (line-end-position))))
           (when-let ((output (keycast--format keycast-log-format)))
             (insert output)))
         (goto-char (if keycast-log-newest-first (point-min) (point-max)))))))



reply via email to

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