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

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

[nongnu] elpa/autothemer 9e27fbeae5 17/21: Find unused palette entries i


From: ELPA Syncer
Subject: [nongnu] elpa/autothemer 9e27fbeae5 17/21: Find unused palette entries in generated themes, and fix the FIXME (#12)
Date: Thu, 6 Jan 2022 02:58:10 -0500 (EST)

branch: elpa/autothemer
commit 9e27fbeae525249aafe2cd8a37aaedf65d3bfde1
Author: Török Edwin <edwintorok@users.noreply.github.com>
Commit: Jason Milkins <jasonm23@users.noreply.github.com>

    Find unused palette entries in generated themes, and fix the FIXME (#12)
    
    * Fix warning about use of free variable 'defined-colors-as-structs`
    
    If a theme uses lexical binding then there would be a warning that
    `defined-colors-as-structs` is a free variable.
    Suppress it the same way the other temporary symbols are suppressed.
    
    Signed-off-by: Edwin Török <edwin@etorok.net>
    
    * Find unused palette entries in generated themes
    
    Emit `autothemer--current-theme` code only once when n=0 and not
    byte-compiled.
    On a theme using lexical scope this raises byte compiler warnings
    when `palette` entries are defined, but not used in either `reserved-specs` 
or `body`.
    This breaks `autothemer-generate-templates` when loading a byte-compiled
    theme, however the default with `load-theme` is to load the `.el` file
    even if `.elc` is present, so this won't affect the majority of users.
    
    Because we emit `body` only when `n=0` emit an `ignore` when `n>0` to
    avoid spurious warnings.
    
    This commit is best reviewed by ignoring whitespace changes.
    
    Signed-off-by: Edwin Török <edwin@etorok.net>
---
 autothemer.el | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/autothemer.el b/autothemer.el
index 9c359096c5..c15fb960f3 100644
--- a/autothemer.el
+++ b/autothemer.el
@@ -65,6 +65,7 @@ bindings within both the REDUCED-SPECS and the BODY."
          (temp-colorname (make-symbol "colorname")))
     (setq face-customizer
           `(let ((,face-specs)
+                 (,temp-color-structs)
                  (,temp-defined-colors))
              (deftheme ,name ,description)
              ,@(cl-loop for n from 0 to (1- n-displays)
@@ -72,22 +73,21 @@ bindings within both the REDUCED-SPECS and the BODY."
                         `(let* ,(autothemer--extract-let-block full-palette n)
                            ,@(when (and body (eq n 0))
                                body)
-                           ;; FIXME: instead of emitting this code for all n,
-                           ;; and including a runtime check for n = 0, the when
-                           ;; clause below should only be emitted for n = 0 in
-                           ;; the first place
-                           (when ,(eq n 0)
-                             (setq ,temp-defined-colors
-                                   (list ,@(--map (list 'list `',it it) 
color-names)))
-                             (setq ,temp-color-structs
-                                   (cl-loop for (,temp-colorname ,temp-color)
-                                            in ,temp-defined-colors
-                                            collect (make-autothemer--color 
:name ,temp-colorname
-                                                                            
:value ,temp-color)))
-                             (setq autothemer--current-theme
-                                   (make-autothemer--theme
-                                    :colors ,temp-color-structs
-                                    :defined-faces ',face-names)))
+                           ,(when (> n 0)
+                              `(ignore ,@color-names))
+                           ,(when (and (eq n 0) (not (bound-and-true-p 
byte-compile-current-file)))
+                              `(progn
+                                 (setq ,temp-defined-colors
+                                       (list ,@(--map (list 'list `',it it) 
color-names)))
+                                 (setq ,temp-color-structs
+                                       (cl-loop for (,temp-colorname 
,temp-color)
+                                                in ,temp-defined-colors
+                                                collect 
(make-autothemer--color :name ,temp-colorname
+                                                                               
 :value ,temp-color)))
+                                 (setq autothemer--current-theme
+                                       (make-autothemer--theme
+                                        :colors ,temp-color-structs
+                                        :defined-faces ',face-names))))
                            (setq ,face-specs
                                  (autothemer--append-column
                                   ,face-specs



reply via email to

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