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

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

[nongnu] elpa/telephone-line 23195b81b4 112/195: Add support for subsegm


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 23195b81b4 112/195: Add support for subsegment modifiers; add :active modifier
Date: Wed, 5 Jan 2022 02:59:33 -0500 (EST)

branch: elpa/telephone-line
commit 23195b81b49c8c3577617a1b525168d78c70fa22
Author: Daniel Bordak <dbordak@fastmail.fm>
Commit: Daniel Bordak <dbordak@fastmail.fm>

    Add support for subsegment modifiers; add :active modifier
---
 telephone-line.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/telephone-line.el b/telephone-line.el
index 3823183c58..43777ca6ce 100644
--- a/telephone-line.el
+++ b/telephone-line.el
@@ -240,6 +240,20 @@ Secondary separators do not incur a background color 
change."
            (mapcar (lambda (f) (funcall f cur-face))
                    subsegments))))))
 
+(defun telephone-line-preprocess-subsegments (subsegments)
+  "Normalize SUBSEGMENTS to create a strict list of functions."
+  (mapcar (lambda (subsegment)
+            (if (functionp subsegment)
+                subsegment
+              (seq-let (segment-func &rest modifiers) subsegment
+                (if (seq-contains modifiers ':active)
+                    `(lambda (face)
+                       (if (telephone-line-selected-window-active)
+                           (,segment-func face)
+                         nil))
+                  segment-func))))
+          subsegments))
+
 ;;TODO: Clean this up
 (defun telephone-line-add-separators (segments primary-sep secondary-sep)
   "Interpolates SEGMENTS with PRIMARY-SEP and SECONDARY-SEP.
@@ -253,7 +267,9 @@ separators, as they are conditional, are evaluated 
on-the-fly."
                     (cons color-sym
                           `(:eval
                             (telephone-line-add-subseparators
-                             ',subsegments ,secondary-sep ',color-sym)))))
+                             ',(telephone-line-preprocess-subsegments 
subsegments)
+                             ,secondary-sep
+                             ',color-sym)))))
                 (seq-reverse segments))
         '(nil . nil))))
 



reply via email to

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