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

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

[nongnu] elpa/keycast f87f9c965e 06/10: keycast-mode-line-mode: Support


From: ELPA Syncer
Subject: [nongnu] elpa/keycast f87f9c965e 06/10: keycast-mode-line-mode: Support buffers with local mode-line-format
Date: Mon, 5 Dec 2022 06:59:12 -0500 (EST)

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

    keycast-mode-line-mode: Support buffers with local mode-line-format
---
 keycast.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/keycast.el b/keycast.el
index ff8850f8e5..a62eeab2ee 100644
--- a/keycast.el
+++ b/keycast.el
@@ -330,12 +330,31 @@ t to show the actual COMMAND, or a symbol to be shown 
instead."
             (< keycast--command-repetitions 0))
         (cl-incf keycast--command-repetitions)
       (setq keycast--command-repetitions 0)))
+  (when keycast-mode-line-mode
+    (keycast--maybe-edit-local-format
+     'mode-line-format
+     'keycast-mode-line
+     'keycast--mode-line-modified-buffers))
   (when (and keycast-log-mode
              (not keycast--reading-passwd))
     (keycast-log-update-buffer))
   (when (keycast--mode-active-p 'line)
     (force-mode-line-update (minibufferp))))
 
+(defun keycast--maybe-edit-local-format (format item record)
+  (let ((value (buffer-local-value format (current-buffer))))
+    (unless (and (listp value)
+                 (memq item value))
+      (set record (cons (current-buffer) (symbol-value record)))
+      (set format (if (keycast--format-atom-p value)
+                      (list "" item value)
+                    (nconc (list "" item) value))))))
+
+(defun keycast--format-atom-p (format)
+  (or (stringp format)
+      (and (not (stringp (car-safe format)))
+           (not (listp (car-safe format))))))
+
 (defun keycast--format (format)
   (and (not keycast--reading-passwd)
        (let* ((key (ignore-errors
@@ -393,6 +412,7 @@ t to show the actual COMMAND, or a symbol to be shown 
instead."
 
 (defvar keycast--removed-tail nil)
 (defvar keycast--temporary-mode-line nil)
+(defvar keycast--mode-line-modified-buffers nil)
 
 (defalias 'keycast-mode 'keycast-mode-line-mode)
 
@@ -435,6 +455,11 @@ t to show the actual COMMAND, or a symbol to be shown 
instead."
             (t
              (setcar cons (cadr cons))
              (setcdr cons (cddr cons)))))
+    (dolist (buf keycast--mode-line-modified-buffers)
+      (when (buffer-live-p buf)
+        (with-current-buffer buf
+          (setq-local mode-line-format
+                      (delq 'keycast-mode-line mode-line-format)))))
     (unless (keycast--mode-active-p)
       (remove-hook 'post-command-hook #'keycast--update)
       (remove-hook 'minibuffer-exit-hook #'keycast--minibuffer-exit)))))



reply via email to

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