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

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

[nongnu] elpa/telephone-line bfd9c8b431 067/195: New string trimmer fixe


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line bfd9c8b431 067/195: New string trimmer fixes appearance of paradox line number segment
Date: Wed, 5 Jan 2022 02:59:27 -0500 (EST)

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

    New string trimmer fixes appearance of paradox line number segment
---
 telephone-line-segments.el | 12 +++++-------
 telephone-line-utils.el    | 14 +++++++++++---
 telephone-line.el          |  5 ++---
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/telephone-line-segments.el b/telephone-line-segments.el
index 0b132d60e1..cfb82394a8 100644
--- a/telephone-line-segments.el
+++ b/telephone-line-segments.el
@@ -24,8 +24,6 @@
 
 (require 'telephone-line-utils)
 
-(require 's)
-
 (telephone-line-defsegment telephone-line-vc-segment
   vc-mode)
 
@@ -34,12 +32,13 @@
 
 (telephone-line-defsegment telephone-line-position-segment
   (if (eq major-mode 'paradox-menu-mode)
-      mode-line-front-space  ;Paradox fills this with position info.
+      ;;Paradox fills this with position info.
+      (telephone-line-trim (format-mode-line mode-line-front-space))
     mode-line-position))
 
 (telephone-line-defsegment telephone-line-airline-position-segment
   (if (eq major-mode 'paradox-menu-mode)
-      mode-line-front-space
+      (telephone-line-trim (format-mode-line mode-line-front-space))
     '((-3 "%p") " %4l:%3c")))
 
 (telephone-line-defsegment telephone-line-misc-info-segment
@@ -82,8 +81,7 @@ mouse-3: Toggle minor modes"
 
 (telephone-line-defsegment* telephone-line-erc-modified-channels-segment
   (when (boundp 'erc-modified-channels-object)
-    (s-with erc-modified-channels-object
-      s-trim (s-chop-suffix "]") (s-chop-prefix "["))))
+    (telephone-line-trim erc-modified-channels-object)))
 
 (eval-after-load 'evil
   '(telephone-line-defsegment* telephone-line-evil-tag-segment
@@ -95,7 +93,7 @@ mouse-3: Toggle minor modes"
                   (if telephone-line-evil-use-short-tag "VL" "V-LINE"))
                  (t "VISUAL"))))
        (if telephone-line-evil-use-short-tag
-           (s-left 2 tag)
+           (seq-take tag 2)
          tag))))
 
 (provide 'telephone-line-segments)
diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index 1dcd3f73ac..c95c2b7318 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -23,7 +23,6 @@
 (require 'color)
 (require 'cl-generic)
 
-(require 's)
 (require 'seq)
 
 (defcustom telephone-line-height nil
@@ -41,6 +40,15 @@
   :type 'boolean
   :group 'telephone-line-evil)
 
+(defun telephone-line-trim (string)
+  "Ad-hoc string trim which removes spaces and up to the first brace from 
STRING."
+  (let ((s (if (string-match "[\])][ ]*\\'" string)
+               (replace-match "" t t string)
+             string)))
+    (if (string-match "\\`[ ]*[\[(]" s)
+        (replace-match "" t t s)
+      s)))
+
 (defun telephone-line-create-axis (length)
   "Create an axis of length LENGTH.
 For odd lengths, this is a sequence from -floor(LENGTH/2) to
@@ -242,8 +250,8 @@ Segment is not precompiled."
 (defun telephone-line-raw (str &optional compiled)
   "Conditionally render STR as mode-line data, or just verify output if not 
COMPILED.
 Return nil for blank/empty strings."
-  (let ((trimmed-str (s-trim (format-mode-line str))))
-    (unless (s-blank? trimmed-str)
+  (let ((trimmed-str (telephone-line-trim (format-mode-line str))))
+    (unless (seq-empty-p trimmed-str)
       (if compiled
           (replace-regexp-in-string "%" "%%" trimmed-str)
         str))))
diff --git a/telephone-line.el b/telephone-line.el
index dc0d5160c3..9def78fb33 100644
--- a/telephone-line.el
+++ b/telephone-line.el
@@ -6,7 +6,7 @@
 ;; URL: https://github.com/dbordak/telephone-line
 ;; Version: 0.3
 ;; Keywords: mode-line
-;; Package-Requires: ((emacs "24.4") (cl-lib "0.5") (cl-generic "0.2") (s 
"1.9.0") (seq "1.8"))
+;; Package-Requires: ((emacs "24.4") (cl-lib "0.5") (cl-generic "0.2") (seq 
"1.8"))
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -34,7 +34,6 @@
 (require 'telephone-line-segments)
 
 (require 'seq)
-(require 's)
 (require 'cl-lib)
 
 (defgroup telephone-line nil
@@ -186,7 +185,7 @@ Secondary separators do not incur a background color 
change."
        cur-color-sym))))
 
 (defun telephone-line-propertize-segment (pred face segment)
-  (unless (s-blank? (s-trim (format-mode-line segment)))
+  (unless (seq-empty-p (telephone-line-trim (format-mode-line segment)))
     (if pred
         `(:propertize (" " ,segment " ") face ,face)
       `(" " ,segment " "))))



reply via email to

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