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

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

[elpa] master 71a1a0c 14/31: Rename ambiguous "defined" to "originally s


From: Jackson Ray Hamilton
Subject: [elpa] master 71a1a0c 14/31: Rename ambiguous "defined" to "originally set".
Date: Mon, 09 Feb 2015 01:09:34 +0000

branch: master
commit 71a1a0cd62304e446f42c42e27af71e1d601ee0e
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Rename ambiguous "defined" to "originally set".
---
 context-coloring.el           |   68 ++++++++++++++++++++++------------------
 test/context-coloring-test.el |   28 +++++++++--------
 2 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 9dcaf33..9554fdf 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -485,17 +485,22 @@ would be redundant."
   "context-coloring-level-\\([[:digit:]]+\\)-face"
   "Regular expression for extracting a level from a face.")
 
-(defvar context-coloring-defined-theme-hash-table (make-hash-table :test 'eq)
+(defvar context-coloring-originally-set-theme-hash-table (make-hash-table 
:test 'eq)
   "Cache of custom themes who originally set their own
   `context-coloring-level-N-face' faces.")
 
-(defun context-coloring-theme-definedp (theme)
-  "Return t if there is a `context-coloring-level-N-face' defined
-for THEME, nil otherwise."
-  (let (defined)
+(defun context-coloring-theme-originally-set-p (theme)
+  "Return t if there is a `context-coloring-level-N-face'
+originally set for THEME, nil otherwise."
+  (let (originally-set)
     (cond
-     ((setq defined (gethash theme context-coloring-defined-theme-hash-table))
-      (eq defined 'defined))
+     ;; `setq' might return a non-nil value for the sake of this `cond'.
+     ((setq
+       originally-set
+       (gethash
+        theme
+        context-coloring-originally-set-theme-hash-table))
+      (eq originally-set 'yes))
      (t
       (let* ((settings (get theme 'theme-settings))
              (tail settings)
@@ -509,25 +514,26 @@ for THEME, nil otherwise."
           (setq tail (cdr tail)))
         found)))))
 
-(defun context-coloring-cache-defined (theme defined)
-  "Remember if THEME had colors defined for it; if DEFINED is
-non-nil, it did, otherwise it didn't."
-  ;; Caching the definededness of a theme is kind of dirty, but we have to do 
it
-  ;; to remember the past state of the theme. There are probably some edge 
cases
-  ;; where caching will be an issue, but they are probably rare.
+(defun context-coloring-cache-originally-set (theme originally-set)
+  "Remember if THEME had colors originally set for it; if
+ORIGINALLY-SET is non-nil, it did, otherwise it didn't."
+  ;; Caching whether a theme was originally set is kind of dirty, but we have 
to
+  ;; do it to remember the past state of the theme.  There are probably some
+  ;; edge cases where caching will be an issue, but they are probably rare.
   (puthash
    theme
-   (if defined 'defined 'undefined)
-   context-coloring-defined-theme-hash-table))
+   (if originally-set 'yes 'no)
+   context-coloring-originally-set-theme-hash-table))
 
-(defun context-coloring-warn-theme-defined (theme)
-  "Warns the user that the colors for a theme are already defined."
+(defun context-coloring-warn-theme-originally-set (theme)
+  "Warns the user that the colors for a theme are already
+originally set."
   (warn "Context coloring colors for theme `%s' are already defined" theme))
 
 (defun context-coloring-theme-highest-level (theme)
   "Return the highest level N of a face like
-`context-coloring-level-N-face' defined for THEME, or -1 if there
-is none."
+`context-coloring-level-N-face' set for THEME, or -1 if there is
+none."
   (let* ((settings (get theme 'theme-settings))
          (tail settings)
          face-string
@@ -598,18 +604,18 @@ use your custom theme's author's colors instead."
     (dolist (name (append `(,theme) aliases))
       (puthash name properties context-coloring-theme-hash-table)
       (when (custom-theme-p name)
-        (let ((defined (context-coloring-theme-definedp name)))
-          (context-coloring-cache-defined name defined)
+        (let ((originally-set (context-coloring-theme-originally-set-p name)))
+          (context-coloring-cache-originally-set name originally-set)
           ;; In the particular case when you innocently define colors that a
-          ;; custom theme already sets, warn.  Arguably this only has to be 
done
-          ;; at enable time, but it is probably more useful to do it at
+          ;; custom theme originally set, warn.  Arguably this only has to be
+          ;; done at enable time, but it is probably more useful to do it at
           ;; definition time for prompter feedback.
-          (when (and defined
+          (when (and originally-set
                      (not recede)
                      (not override))
-            (context-coloring-warn-theme-defined name))
+            (context-coloring-warn-theme-originally-set name))
           ;; Set (or overwrite) colors.
-          (when (not (and defined
+          (when (not (and originally-set
                           recede))
             (context-coloring-apply-theme name)))))))
 
@@ -620,7 +626,7 @@ use your custom theme's author's colors instead."
     "4.1.0")))
 
 (defun context-coloring-enable-theme (theme)
-  "Applies THEME if its colors are not already defined, else just
+  "Applies THEME if its colors are not already set, else just
 sets `context-coloring-face-count' to the correct value for
 THEME."
   (let* ((properties (gethash theme context-coloring-theme-hash-table))
@@ -642,13 +648,13 @@ THEME."
          (t
           (context-coloring-apply-theme theme)))))
      (t
-      (let ((defined (context-coloring-theme-definedp theme)))
+      (let ((originally-set (context-coloring-theme-originally-set-p theme)))
         ;; Cache now in case the context theme was defined after the custom
         ;; theme.
-        (context-coloring-cache-defined theme defined)
-        (when (and defined
+        (context-coloring-cache-originally-set theme originally-set)
+        (when (and originally-set
                    (not override))
-          (context-coloring-warn-theme-defined theme))
+          (context-coloring-warn-theme-originally-set theme))
         (context-coloring-apply-theme theme))))))
 
 (defadvice enable-theme (after context-coloring-enable-theme (theme) activate)
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index aa24087..d7fd714 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -310,12 +310,14 @@ is FOREGROUND."
     (setq context-coloring-test-theme-index
           (+ context-coloring-test-theme-index 1))))
 
-(defun context-coloring-test-assert-theme-definedp (settings &optional negate)
-  "Assert that `context-coloring-theme-definedp' returns t for a
-theme with SETTINGS (or the inverse if NEGATE is non-nil)."
+(defun context-coloring-test-assert-theme-originally-set-p (settings &optional 
negate)
+  "Assert that `context-coloring-theme-originally-set-p' returns
+t for a theme with SETTINGS (or the inverse if NEGATE is
+non-nil)."
   (let ((theme (context-coloring-test-get-next-theme)))
     (put theme 'theme-settings settings)
-    (when (funcall (if negate 'identity 'not) (context-coloring-theme-definedp 
theme))
+    (when (funcall (if negate 'identity 'not)
+                   (context-coloring-theme-originally-set-p theme))
       (ert-fail (format (concat "Expected theme `%s' with settings `%s' "
                                 "%sto be considered to have defined a level, "
                                 "but it %s.")
@@ -323,21 +325,21 @@ theme with SETTINGS (or the inverse if NEGATE is 
non-nil)."
                         (if negate "not " "")
                         (if negate "was" "wasn't"))))))
 
-(defun context-coloring-test-assert-not-theme-definedp (&rest arguments)
-  "Assert that `context-coloring-theme-definedp' does not return
-t for a theme with SETTINGS."
-  (apply 'context-coloring-test-assert-theme-definedp (append arguments '(t))))
+(defun context-coloring-test-assert-not-theme-originally-set-p (&rest 
arguments)
+  "Assert that `context-coloring-theme-originally-set-p' does not
+return t for a theme with SETTINGS."
+  (apply 'context-coloring-test-assert-theme-originally-set-p (append 
arguments '(t))))
 
-(ert-deftest context-coloring-test-theme-definedp ()
-  (context-coloring-test-assert-theme-definedp
+(ert-deftest context-coloring-test-theme-originally-set-p ()
+  (context-coloring-test-assert-theme-originally-set-p
    '((theme-face context-coloring-level-0-face)))
-  (context-coloring-test-assert-theme-definedp
+  (context-coloring-test-assert-theme-originally-set-p
    '((theme-face face)
      (theme-face context-coloring-level-0-face)))
-  (context-coloring-test-assert-theme-definedp
+  (context-coloring-test-assert-theme-originally-set-p
    '((theme-face context-coloring-level-0-face)
      (theme-face face)))
-  (context-coloring-test-assert-not-theme-definedp
+  (context-coloring-test-assert-not-theme-originally-set-p
    '((theme-face face)))
   )
 



reply via email to

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