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

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

[nongnu] elpa/telephone-line 7feb552dcf 048/195: Remove names


From: ELPA Syncer
Subject: [nongnu] elpa/telephone-line 7feb552dcf 048/195: Remove names
Date: Wed, 5 Jan 2022 02:59:21 -0500 (EST)

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

    Remove names
---
 telephone-line-utils.el |  72 ++++++++++++++-------------
 telephone-line.el       | 126 +++++++++++++++++++++++-------------------------
 2 files changed, 96 insertions(+), 102 deletions(-)

diff --git a/telephone-line-utils.el b/telephone-line-utils.el
index 3f4ae3036c..0780760a14 100644
--- a/telephone-line-utils.el
+++ b/telephone-line-utils.el
@@ -24,32 +24,30 @@
 (require 'seq)
 (require 'color)
 
-(define-namespace telephone-line-
-
-(defcustom height nil
+(defcustom telephone-line-height nil
   "Override the mode-line height."
   :group 'telephone-line
   :type '(choice integer (const nil)))
 
-(defcustom separator-extra-padding 1
+(defcustom telephone-line-separator-extra-padding 1
   "Extra spacing around separators."
   :group 'telephone-line
   :type '(choice integer))
 
-(defcustom evil-use-short-tag nil
+(defcustom telephone-line-evil-use-short-tag nil
   "If non-nil, use an abbreviated name for the evil mode tag."
   :type 'boolean
   :group 'telephone-line-evil)
 
-(defun separator-height ()
+(defun telephone-line-separator-height ()
   "Get the height for a telephone-line separator."
-  (or height (frame-char-height)))
+  (or telephone-line-height (frame-char-height)))
 
-(defun separator-width ()
+(defun telephone-line-separator-width ()
   "Get the default width for a telephone-line separator."
-  (ceiling (separator-height) 2))
+  (ceiling (telephone-line-separator-height) 2))
 
-(defun create-axis (length)
+(defun telephone-line-create-axis (length)
   "Create an axis of length LENGTH.
 For odd lengths, this is a sequence from -floor(LENGTH/2) to
 +floor(LENGTH/2), so for instance a LENGTH of 9 produces:
@@ -64,24 +62,24 @@ For instance, a LENGTH of 10 produces:
     (append (number-sequence (- middle) 0)
             (number-sequence (if (cl-oddp length) 1 0) middle))))
 
-(defun create-trig-axis (length)
+(defun telephone-line-create-trig-axis (length)
   "Create a trig axis with LENGTH steps, ranging from -pi to +pi.
 As with create-axis, on even LENGTHs, the 0 is repeated to
 preserve symmetry."
-  (let* ((integer-axis (create-axis length))
+  (let* ((integer-axis (telephone-line-create-axis length))
          (integer-max (seq-max integer-axis)))
     (mapcar (lambda (x)
               (/ (* float-pi x) integer-max))
             integer-axis)))
 
-(defun -normalize-axis (seq)
+(defun telephone-line--normalize-axis (seq)
   "Apply an offset to all values of SEQ such that its range begins at 0."
   (let ((minimum (seq-min seq)))
     (if (not (eq minimum 0))
         (mapcar (lambda (i) (- i minimum)) seq)
       seq)))
 
-(defun interpolate-rgb (color1 color2 &optional ratio)
+(defun telephone-line-interpolate-rgb (color1 color2 &optional ratio)
   "Interpolate between COLOR1 and COLOR2, with color1/color2 RATIO.
 When no RATIO is provided, produces the color halfway between
 color1 and color2."
@@ -92,7 +90,7 @@ color1 and color2."
                       (* (- 1 ratio) (nth n (color-name-to-rgb color2)))))
          '(0 1 2))))
 
-(defun color-to-bytestring (color)
+(defun telephone-line-color-to-bytestring (color)
   "Return an RGB bytestring for a given COLOR."
   (seq-mapcat (lambda (subc)
                 (byte-to-string (floor (* 255 subc))))
@@ -102,24 +100,24 @@ color1 and color2."
               'string))
 
 ;; TODO: error on non-rectangular input?
-(defun -create-pbm-image (body fg-color bg-color)
+(defun telephone-line--create-pbm-image (body fg-color bg-color)
   (create-image
    (concat
     (format "P6 %d %d 255 " (length (car body)) (length body))
     (seq-mapcat (lambda (pixel)
-                  (color-to-bytestring
-                   (interpolate-rgb bg-color fg-color pixel)))
+                  (telephone-line-color-to-bytestring
+                   (telephone-line-interpolate-rgb bg-color fg-color pixel)))
                 (seq-mapcat #'identity body)
                 'string))
    'pbm t
    :ascent 'center))
 
-(defun propertize-image (image)
+(defun telephone-line-propertize-image (image)
   "Return a propertized string of IMAGE."
   (propertize (make-string (ceiling (car (image-size image))) ? )
               'display image))
 
-(defun row-pattern (fill total)
+(defun telephone-line-row-pattern (fill total)
   "Make a PBM line that has FILL FG-COLOR bytes out of TOTAL BG-COLOR bytes."
   (seq-let (intfill rem) (cl-floor fill)
     (nconc
@@ -128,7 +126,7 @@ color1 and color2."
        (cons (- 1 rem) ;AA pixel
              (make-list (- total intfill 1) 1)))))) ;Right gap
 
-(defun row-pattern-hollow (padding total)
+(defun telephone-line-row-pattern-hollow (padding total)
   (seq-let (intpadding rem) (cl-floor padding)
     (nconc
      (make-list intpadding 1) ;Left gap
@@ -138,9 +136,10 @@ color1 and color2."
        (cons (- 1 rem)  ;Right AA pixel
              (make-list (- total intpadding 2) 1)))))) ;Right gap
 
-(defun create-body (width height axis-func pattern-func)
+(defun telephone-line-create-body (width height axis-func pattern-func)
   "Create a bytestring of a PBM image body of dimensions WIDTH and HEIGHT, and 
shape created from AXIS-FUNC and PATTERN-FUNC."
-  (let* ((normalized-axis (-normalize-axis (mapcar axis-func (create-axis 
height))))
+  (let* ((normalized-axis (telephone-line--normalize-axis
+                           (mapcar axis-func (telephone-line-create-axis 
height))))
          (range (1+ (seq-max normalized-axis)))
          (scaling-factor (/ width (float range))))
     (mapcar (lambda (x)
@@ -148,16 +147,16 @@ color1 and color2."
                        (* x scaling-factor) width))
             normalized-axis)))
 
-(defmacro complement (func)
+(defmacro telephone-line-complement (func)
   `(lambda (x)
      (- (,func x))))
 
-(defun -separator-arg-handler (arg)
+(defun telephone-line--separator-arg-handler (arg)
   (if (facep arg)
       (face-attribute arg :background)
     arg))
 
-(defmacro -defseparator-internal (name body &optional alt-string)
+(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))
@@ -170,7 +169,7 @@ color1 and color2."
                            :background bg-color
                            :inverse-video t))))))
 
-(defmacro defseparator (name axis-func pattern-func &optional alt-char 
forced-width)
+(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."
@@ -180,7 +179,7 @@ NOTE: Forced-width primary separators are not currently 
supported."
        (telephone-line-create-body width height ,axis-func ,pattern-func))
      (char-to-string ,alt-char)))
 
-(defun -pad-body (body char-width)
+(defun telephone-line--pad-body (body char-width)
   (let* ((body-width (length (car body)))
          (padding-width (- (* char-width (frame-char-width)) body-width))
          (left-padding (make-list (floor padding-width 2) 1))
@@ -189,7 +188,7 @@ NOTE: Forced-width primary separators are not currently 
supported."
               (append left-padding row right-padding))
             body)))
 
-(defmacro defsubseparator (name axis-func pattern-func &optional alt-char 
forced-width)
+(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."
   `(telephone-line--defseparator-internal ,name
      (let* ((height (telephone-line-separator-height))
@@ -202,14 +201,14 @@ NOTE: Forced-width primary separators are not currently 
supported."
      (string ?  ,alt-char ? )))
 
 :autoload
-(defmacro defsegment (name body)
+(defmacro telephone-line-defsegment (name body)
   "Create function NAME by wrapping BODY with telephone-line padding and 
propertization."
   (declare (indent defun))
   `(defun ,name (face)
      (telephone-line-raw ,body face)))
 
 :autoload
-(defmacro defsegment* (name body)
+(defmacro telephone-line-defsegment* (name body)
   "Create function NAME by wrapping BODY with telephone-line padding and 
propertization.
 Segment is not precompiled."
   (declare (indent defun))
@@ -217,7 +216,7 @@ Segment is not precompiled."
      (telephone-line-raw ,body)))
 
 :autoload
-(defmacro defsegment-plist (name plists)
+(defmacro telephone-line-defsegment-plist (name plists)
   (declare (indent defun))
   `(defun ,name (face)
      (telephone-line-raw
@@ -226,7 +225,7 @@ Segment is not precompiled."
                ,plists))))
 
 :autoload
-(defun raw (str &optional compiled)
+(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))))
@@ -236,10 +235,11 @@ Return nil for blank/empty strings."
         str))))
 
 ;;Stole this bit from seq.el
-(defun -activate-font-lock-keywords ()
+(defun telephone-line--activate-font-lock-keywords ()
   "Activate font-lock keywords for some symbols defined in telephone-line."
   (font-lock-add-keywords 'emacs-lisp-mode
                           '("\\<telephone-line-defsegment*\\>"
+                            "\\<telephone-line-defsegment-plist\\>"
                             "\\<telephone-line-defsegment\\>"
                             "\\<telephone-line-defseparator\\>"
                             "\\<telephone-line-defsubseparator\\>")))
@@ -247,9 +247,7 @@ Return nil for blank/empty strings."
 (unless (fboundp 'elisp--font-lock-flush-elisp-buffers)
   ;; In Emacsā‰„25, (via elisp--font-lock-flush-elisp-buffers and a few others)
   ;; we automatically highlight macros.
-  (add-hook 'emacs-lisp-mode-hook #'-activate-font-lock-keywords))
-
-) ; End of namespace
+  (add-hook 'emacs-lisp-mode-hook 
#'telephone-line--activate-font-lock-keywords))
 
 (provide 'telephone-line-utils)
 ;;; telephone-line-utils.el ends here
diff --git a/telephone-line.el b/telephone-line.el
index 236c01d064..f9fedd9c17 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") (names 
"0.5") (s "1.9.0") (seq "1.8"))
+;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (memoize "1.0.1") (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
@@ -37,139 +37,136 @@
 (require 's)
 (require 'cl-lib)
 
-;;;###autoload
-(define-namespace telephone-line-
-
 (defgroup telephone-line nil
   "Fancy separated mode-line."
   :group 'mode-line)
 
-(defface accent-active
+(defface telephone-line-accent-active
   '((t (:foreground "white" :background "grey22" :inherit mode-line)))
   "Accent face for mode-line."
   :group 'telephone-line)
 
-(defface accent-inactive
+(defface telephone-line-accent-inactive
   '((t (:foreground "white" :background "grey11" :inherit mode-line-inactive)))
   "Accent face for inactive mode-line."
   :group 'telephone-line)
 
-(defface evil
+(defface telephone-line-evil
   '((t (:foreground "white" :weight bold :inherit mode-line)))
   "Meta-face used for property inheritance on all telephone-line-evil faces."
   :group 'telephone-line-evil)
 
-(defface evil-insert
+(defface telephone-line-evil-insert
   '((t (:background "green" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Insert state."
   :group 'telephone-line-evil)
 
-(defface evil-normal
+(defface telephone-line-evil-normal
   '((t (:background "red" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Normal state."
   :group 'telephone-line-evil)
 
-(defface evil-visual
+(defface telephone-line-evil-visual
   '((t (:background "orange" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Visual{,-Block,-Line} state."
   :group 'telephone-line-evil)
 
-(defface evil-replace
+(defface telephone-line-evil-replace
   '((t (:background "black" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Replace state."
   :group 'telephone-line-evil)
 
-(defface evil-motion
+(defface telephone-line-evil-motion
   '((t (:background "blue" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Motion state."
   :group 'telephone-line-evil)
 
-(defface evil-operator
+(defface telephone-line-evil-operator
   '((t (:background "sky blue" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Operator state."
   :group 'telephone-line-evil)
 
-(defface evil-emacs
+(defface telephone-line-evil-emacs
   '((t (:background "blue violet" :inherit telephone-line-evil)))
   "Face used in evil color-coded segments when in Emacs state."
   :group 'telephone-line-evil)
 
-(defcustom primary-left-separator #'telephone-line-abs-left
+(defcustom telephone-line-primary-left-separator #'telephone-line-abs-left
   "The primary separator to use on the left-hand side."
   :group 'telephone-line
   :type 'function)
 
-(defcustom primary-right-separator #'telephone-line-abs-right
+(defcustom telephone-line-primary-right-separator #'telephone-line-abs-right
   "The primary separator to use on the right-hand side."
   :group 'telephone-line
   :type 'function)
 
-(defcustom secondary-left-separator #'telephone-line-abs-hollow-left
+(defcustom telephone-line-secondary-left-separator 
#'telephone-line-abs-hollow-left
   "The secondary separator to use on the left-hand side.
 
 Secondary separators do not incur a background color change."
   :group 'telephone-line
   :type 'function)
 
-(defcustom secondary-right-separator #'telephone-line-abs-hollow-right
+(defcustom telephone-line-secondary-right-separator 
#'telephone-line-abs-hollow-right
   "The secondary separator to use on the right-hand side.
 
 Secondary separators do not incur a background color change."
   :group 'telephone-line
   :type 'function)
 
-(defun fill (reserve &optional face)
+(defun telephone-line-fill (reserve &optional face)
   "Return RESERVE empty space on the right, optionally with a FACE." ;;TODO: 
Add face
   (propertize " "
               'display `((space :align-to (- (+ right right-fringe 
right-margin)
                                              ,reserve)))))
 
-(defun -set-selected-window ()
+(defun telephone-line--set-selected-window ()
   (when (not (minibuffer-window-active-p (frame-selected-window)))
-    (setq selected-window (frame-selected-window))))
+    (setq telephone-line-selected-window (frame-selected-window))))
 
-(add-hook 'window-configuration-change-hook #'-set-selected-window)
-(defadvice select-window (after select-window activate)
+(add-hook 'window-configuration-change-hook 
#'telephone-line--set-selected-window)
+(defadvice telephone-line-select-window (after select-window activate)
   "Set telephone-line's selected window value for use in determining the 
active mode-line."
-  (-set-selected-window))
-(defadvice select-frame (after select-frame activate)
+  (telephone-line--set-selected-window))
+(defadvice telephone-line-select-frame (after select-frame activate)
   "Set telephone-line's selected window value for use in determining the 
active mode-line."
-  (-set-selected-window))
+  (telephone-line--set-selected-window))
 
-(defun selected-window-active ()
+(defun telephone-line-selected-window-active ()
   "Return whether the current window is active."
-  (and (boundp 'selected-window)
-       (eq selected-window (selected-window))))
+  (and (boundp 'telephone-line-selected-window)
+       (eq telephone-line-selected-window (selected-window))))
 
-(defun face-map (sym)
+(defun telephone-line-face-map (sym)
   "Return the face corresponding to SYM for the selected window's active 
state."
-  (-face-map sym (selected-window-active)))
+  (telephone-line--face-map sym (telephone-line-selected-window-active)))
 
 ;;TODO: Custom alist
-(defun -face-map (sym active)
+(defun telephone-line--face-map (sym active)
   "Return the face corresponding to SYM for the given ACTIVE state."
-  (cond ((eq sym 'evil) (evil-face active))
+  (cond ((eq sym 'evil) (telephone-line-evil-face active))
         ((eq sym 'accent) (if active 'telephone-line-accent-active
                             'telephone-line-accent-inactive))
         (active 'mode-line)
         (t 'mode-line-inactive)))
 
 ;;TODO: Custom alist
-(defun opposite-face-sym (sym)
+(defun telephone-line-opposite-face-sym (sym)
   "Return the 'opposite' of the given SYM."
   (cdr (assoc
         sym '((evil . nil)
               (accent . nil)
               (nil . accent)))))
 
-(defun evil-face (active)
+(defun telephone-line-evil-face (active)
   "Return an appropriate face for the current evil mode, given whether the 
frame is ACTIVE."
   (cond ((not active) 'mode-line-inactive)
         ((not (boundp 'evil-state)) 'mode-line)
         (t (intern (concat "telephone-line-evil-" (symbol-name evil-state))))))
 
 ;;TODO: Clean this up
-(defun -separator-generator (primary-sep)
+(defun telephone-line--separator-generator (primary-sep)
   (lambda (acc e)
     (let ((cur-color-sym (car e))
           (prev-color-sym (cdr acc))
@@ -188,18 +185,19 @@ Secondary separators do not incur a background color 
change."
          (list cur-subsegments))
        cur-color-sym))))
 
-(defun propertize-segment (pred face segment)
+(defun telephone-line-propertize-segment (pred face segment)
   (unless (s-blank? (s-trim (format-mode-line segment)))
     (if pred
         `(:propertize (" " ,segment " ") face ,face)
       `(" " ,segment " "))))
 
 ;;TODO: Clean this up
-(defun add-subseparators (subsegments sep-func color-sym)
-  (let* ((cur-face (face-map color-sym))
-         (opposite-face (face-map (opposite-face-sym color-sym)))
+(defun telephone-line-add-subseparators (subsegments sep-func color-sym)
+  (let* ((cur-face (telephone-line-face-map color-sym))
+         (opposite-face (telephone-line-face-map
+                         (telephone-line-opposite-face-sym color-sym)))
          (subseparator (funcall sep-func cur-face opposite-face)))
-    (propertize-segment
+    (telephone-line-propertize-segment
      color-sym cur-face
      (cdr (seq-mapcat
            (lambda (subseg)
@@ -209,13 +207,13 @@ Secondary separators do not incur a background color 
change."
                    subsegments))))))
 
 ;;TODO: Clean this up
-(defun add-separators (segments primary-sep secondary-sep)
+(defun telephone-line-add-separators (segments primary-sep secondary-sep)
   "Interpolates SEGMENTS with PRIMARY-SEP and SECONDARY-SEP.
 
 Primary separators are added at initialization.  Secondary
 separators, as they are conditional, are evaluated on-the-fly."
   (car (seq-reduce
-        (-separator-generator primary-sep)
+        (telephone-line--separator-generator primary-sep)
         (mapcar (lambda (segment-pair)
                   (seq-let (color-sym &rest subsegments) segment-pair
                     (cons color-sym
@@ -225,7 +223,7 @@ separators, as they are conditional, are evaluated 
on-the-fly."
                 (seq-reverse segments))
         '(nil . nil))))
 
-(defun width (values num-separators)
+(defun telephone-line-width (values num-separators)
   "Get the column-length of VALUES, with NUM-SEPARATORS interposed."
   (let ((base-width (string-width (format-mode-line values)))
         (separator-width (/ (telephone-line-separator-width)
@@ -239,31 +237,31 @@ separators, as they are conditional, are evaluated 
on-the-fly."
            (* num-separators (- separator-width (ceiling separator-width))))
       base-width)))
 
-(defcustom lhs '((accent . (telephone-line-vc-segment))
-                 (nil    . (telephone-line-minor-mode-segment
-                            telephone-line-buffer-segment)))
+(defcustom telephone-line-lhs '((accent . (telephone-line-vc-segment))
+                                (nil    . (telephone-line-minor-mode-segment
+                                           telephone-line-buffer-segment)))
   "Left hand side segment alist."
   :type '(alist :key-type segment-color :value-type subsegment-list)
   :group 'telephone-line)
 
-(defcustom rhs '((nil    . (telephone-line-misc-info-segment
-                            telephone-line-major-mode-segment))
-                 (accent . (telephone-line-position-segment)))
+(defcustom telephone-line-rhs '((nil    . (telephone-line-misc-info-segment
+                                           telephone-line-major-mode-segment))
+                                (accent . (telephone-line-position-segment)))
   "Right hand side segment alist."
   :type '(alist :key-type segment-color :value-type subsegment-list)
   :group 'telephone-line)
 
-(defun -generate-mode-line-lhs ()
-  (add-separators lhs
-                  primary-left-separator
-                  secondary-left-separator))
+(defun telephone-line--generate-mode-line-lhs ()
+  (telephone-line-add-separators telephone-line-lhs
+                                 telephone-line-primary-left-separator
+                                 telephone-line-secondary-left-separator))
 
-(defun -generate-mode-line-rhs ()
-  (add-separators rhs
-                  primary-right-separator
-                  secondary-right-separator))
+(defun telephone-line--generate-mode-line-rhs ()
+  (telephone-line-add-separators telephone-line-rhs
+                                 telephone-line-primary-right-separator
+                                 telephone-line-secondary-right-separator))
 
-(defun -generate-mode-line ()
+(defun telephone-line--generate-mode-line ()
   `(,@(telephone-line--generate-mode-line-lhs)
     (:eval (telephone-line-fill
             (telephone-line-width
@@ -271,10 +269,10 @@ separators, as they are conditional, are evaluated 
on-the-fly."
              ,(- (length telephone-line-rhs) 1))))
     ,@(telephone-line--generate-mode-line-rhs)))
 
-(defvar -default-mode-line mode-line-format)
+(defvar telephone-line--default-mode-line mode-line-format)
 
-:autoload
-(define-minor-mode mode
+;;;###autoload
+(define-minor-mode telephone-line-mode
   "Toggle telephone-line on or off."
   :group 'telephone-line
   :global t
@@ -282,9 +280,7 @@ separators, as they are conditional, are evaluated 
on-the-fly."
   (setq-default mode-line-format
                 (if telephone-line-mode
                     `("%e" ,@(telephone-line--generate-mode-line))
-                  -default-mode-line)))
-
-) ; End of namespace
+                  telephone-line--default-mode-line)))
 
 (provide 'telephone-line)
 ;;; telephone-line.el ends here



reply via email to

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