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

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

[nongnu] elpa/telephone-line f5a1d0cbd2 057/195: Move over to new OO sep


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line f5a1d0cbd2 057/195: Move over to new OO separators
Date: Wed, 5 Jan 2022 02:59:26 -0500 (EST)

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

    Move over to new OO separators
---
 telephone-line-separators.el | 49 ++++++++++++++++++++++++--------------------
 telephone-line-utils.el      | 42 +------------------------------------
 telephone-line.el            |  6 +++---
 3 files changed, 31 insertions(+), 66 deletions(-)

diff --git a/telephone-line-separators.el b/telephone-line-separators.el
index b786973c76..18909e0296 100644
--- a/telephone-line-separators.el
+++ b/telephone-line-separators.el
@@ -31,6 +31,11 @@
             (/ num (float width)))
           (number-sequence 1 width)))
 
+(defvar telephone-line-gradient
+  (telephone-line-separator "gradient"
+              :axis-func #'identity
+              :pattern-func #'telephone-line-row-pattern-fixed-gradient))
+
 (defvar telephone-line-abs-right
   (telephone-line-separator "abs-right"
               :axis-func #'abs
@@ -48,30 +53,30 @@
                  :axis-func (telephone-line-complement abs)
                  :alt-char #xe0b2))
 
-(telephone-line-defseparator telephone-line-cubed-right
-  (lambda (x) (expt x 3)) #'telephone-line-row-pattern)
-(telephone-line-defseparator telephone-line-cubed-left
-  (lambda (x) (- (expt x 3))) #'telephone-line-row-pattern)
-(telephone-line-defsubseparator telephone-line-cubed-hollow-right
-  (lambda (x) (expt x 3)) #'telephone-line-row-pattern-hollow)
-(telephone-line-defsubseparator telephone-line-cubed-hollow-left
-  (lambda (x) (- (expt x 3))) #'telephone-line-row-pattern-hollow)
-
-(telephone-line-defseparator telephone-line-identity-right
-  #'identity #'telephone-line-row-pattern)
-(telephone-line-defseparator telephone-line-identity-left
-  #'- #'telephone-line-row-pattern)
-(telephone-line-defsubseparator telephone-line-identity-hollow-right
-  #'identity #'telephone-line-row-pattern-hollow)
-(telephone-line-defsubseparator telephone-line-identity-hollow-left
-  #'- #'telephone-line-row-pattern-hollow)
+(defvar telephone-line-cubed-right
+  (telephone-line-separator "cubed-right"
+              :axis-func (lambda (x) (expt x 3))))
+(defvar telephone-line-cubed-left
+  (telephone-line-separator "cubed-left"
+              :axis-func (lambda (x) (- (expt x 3)))))
+(defvar telephone-line-cubed-hollow-right
+  (telephone-line-subseparator "cubed-hollow-right"
+                 :axis-func (lambda (x) (expt x 3))))
+(defvar telephone-line-cubed-hollow-left
+  (telephone-line-subseparator "cubed-hollow-left"
+                 :axis-func (lambda (x) (- (expt x 3)))))
 
-(telephone-line-defseparator telephone-line-gradient
-  #'identity #'telephone-line-row-pattern-fixed-gradient)
+(defvar telephone-line-identity-right
+  (telephone-line-separator "identity-right" :axis-func #'identity))
+(defvar telephone-line-identity-left
+  (telephone-line-separator "identity-left" :axis-func #'-))
+(defvar telephone-line-identity-hollow-right
+  (telephone-line-subseparator "identity-hollow-right" :axis-func #'identity))
+(defvar telephone-line-identity-hollow-left
+  (telephone-line-subseparator "identity-hollow-left" :axis-func #'-))
 
-(defun telephone-line-nil (color1 color2)
-  "The nil separator.  COLOR1 and COLOR2 are disregarded."
-  nil)
+(defvar telephone-line-nil
+  (telephone-line-separator "nil" :axis-func (lambda (c1 c2) nil)))
 
 (provide 'telephone-line-separators)
 ;;; telephone-line-separators.el ends here
diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index e57b51bdd7..236e8f9bca 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -23,7 +23,6 @@
 (require 'color)
 (require 'eieio)
 
-(require 'memoize)
 (require 's)
 (require 'seq)
 
@@ -163,19 +162,6 @@ color1 and color2."
       (face-attribute arg :background)
     arg))
 
-(defmacro telephone-line--defseparator-internal (name body &optional 
alt-string)
-  (declare (indent defun))
-  `(defmemoize ,name (foreground background)
-     (let ((bg-color (telephone-line--separator-arg-handler background))
-           (fg-color (telephone-line--separator-arg-handler foreground)))
-       (if window-system
-           (telephone-line-propertize-image
-            (telephone-line--create-pbm-image ,body bg-color fg-color))
-         (list :propertize ,alt-string
-               'face (list :foreground fg-color
-                           :background bg-color
-                           :inverse-video t))))))
-
 (defun telephone-line--pad-body (body char-width)
   "Pad 2d byte-list BODY to a width of CHAR-WIDTH, given as a number of 
characters."
   (let* ((body-width (length (car body)))
@@ -186,30 +172,6 @@ color1 and color2."
               (append left-padding row right-padding))
             body)))
 
-(defmacro telephone-line-defseparator (name axis-func pattern-func &optional 
alt-char forced-width)
-  "Define a separator named NAME, using AXIS-FUNC and PATTERN-FUNC to create 
the shape, optionally forcing FORCED-WIDTH.
-
-NOTE: Forced-width primary separators are not currently supported."
-  (declare (indent defun))
-  `(telephone-line--defseparator-internal ,name
-     (let ((height (telephone-line-separator-height))
-           (width (or ,forced-width (telephone-line-separator-width))))
-       (telephone-line--create-body width height ,axis-func ,pattern-func))
-     (char-to-string ,alt-char)))
-
-(defmacro telephone-line-defsubseparator (name axis-func pattern-func 
&optional alt-char forced-width)
-  "Define a subseparator named NAME, using AXIS-FUNC and PATTERN-FUNC to 
create the shape, optionally forcing FORCED-WIDTH."
-  (declare (indent defun))
-  `(telephone-line--defseparator-internal ,name
-     (let* ((height (telephone-line-separator-height))
-            (width (or ,forced-width (telephone-line-separator-width)))
-            (char-width (+ (ceiling width (frame-char-width))
-                           telephone-line-separator-extra-padding)))
-        (telephone-line--pad-body
-         (telephone-line--create-body width height ,axis-func ,pattern-func)
-         char-width))
-     (string ?  ,alt-char ? )))
-
 :autoload
 (defmacro telephone-line-defsegment (name body)
   "Create function NAME by wrapping BODY with telephone-line padding and 
propertization."
@@ -299,9 +261,7 @@ Return nil for blank/empty strings."
   (font-lock-add-keywords 'emacs-lisp-mode
                           '("\\<telephone-line-defsegment*\\>"
                             "\\<telephone-line-defsegment-plist\\>"
-                            "\\<telephone-line-defsegment\\>"
-                            "\\<telephone-line-defseparator\\>"
-                            "\\<telephone-line-defsubseparator\\>")))
+                            "\\<telephone-line-defsegment\\>")))
 
 (unless (fboundp 'elisp--font-lock-flush-elisp-buffers)
   ;; In Emacsā‰„25, (via elisp--font-lock-flush-elisp-buffers and a few others)
diff --git a/telephone-line.el b/telephone-line.el
index 08de3cc5c8..4374b9767d 100644
--- a/telephone-line.el
+++ b/telephone-line.el
@@ -6,7 +6,7 @@
 ;; URL: https://github.com/dbordak/telephone-line
 ;; Version: 0.2
 ;; Keywords: mode-line
-;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (memoize "1.0.1") (s 
"1.9.0") (seq "1.8"))
+;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (eieio "1.4") (s "1.9.0") 
(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
@@ -178,8 +178,8 @@ Secondary separators do not incur a background color 
change."
             cur-subsegments ;New segment
             ;; Separator
             `(:eval (telephone-line-separator-render ,primary-sep
-                             (telephone-line-face-map ',prev-color-sym)
-                             (telephone-line-face-map ',cur-color-sym)))
+                                       (telephone-line-face-map 
',prev-color-sym)
+                                       (telephone-line-face-map 
',cur-color-sym)))
             accumulated-segments) ;Old segments
          (list cur-subsegments))
        cur-color-sym))))



reply via email to

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