[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 87a0ee4 06/10: Automatically load themes alongside custom
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 87a0ee4 06/10: Automatically load themes alongside custom themes. |
Date: |
Sat, 07 Feb 2015 09:02:44 +0000 |
branch: master
commit 87a0ee45a62605758d37b0d2a6e9fab2dec1a26e
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Automatically load themes alongside custom themes.
---
context-coloring.el | 54 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 2a8b8f9..8ce8cad 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -479,24 +479,48 @@ would be redundant."
(defvar context-coloring-theme-hash-table (make-hash-table :test 'eq)
"Mapping of theme names to theme properties.")
+(defun context-coloring-apply-theme (theme)
+ "Applies THEME's properties to its respective custom theme,
+which must already exist and which *should* already be enabled."
+ (let ((properties (gethash theme context-coloring-theme-hash-table)))
+ (when (null properties)
+ (error (format "No such theme `%s'" theme)))
+ (let ((colors (plist-get properties :colors)))
+ (setq context-coloring-face-count (length colors)) ; Side-effect?
+ (let ((level -1))
+ ;; AFAIK, no way to know if a theme already has a face set, so just
+ ;; override blindly for now.
+ (apply
+ 'custom-theme-set-faces
+ theme
+ (mapcar
+ (lambda (color)
+ (setq level (+ level 1))
+ `(,(context-coloring-face-symbol level) ((t (:foreground
,color)))))
+ colors))))))
+
(defun context-coloring-define-theme (theme &rest properties)
"Define a theme named THEME for coloring scope levels.
PROPERTIES is a property list specifiying the following details:
`:colors': List of colors that this theme uses."
- (puthash
- theme
- (lambda ()
- (apply 'context-coloring-set-colors (plist-get properties :colors)))
- context-coloring-theme-hash-table))
-
-(defun context-coloring-load-theme (theme)
- "Apply THEME's colors and other properties for context
-coloring."
- (let ((function (gethash theme context-coloring-theme-hash-table)))
- (when (null function)
- (error (format "No such theme `%s'" theme)))
- (funcall function)))
+ (let ((aliases (plist-get properties :aliases)))
+ (dolist (name (append '(theme) aliases))
+ (puthash name properties context-coloring-theme-hash-table)
+ ;; Compensate for already-enabled themes by applying their colors now.
+ (when (custom-theme-enabled-p name)
+ (context-coloring-apply-theme name)))))
+
+(defun context-coloring-load-theme (&optional rest)
+ (declare (obsolete
+ "themes are now loaded alongside custom themes automatically."
+ "4.1.0")))
+
+(defadvice enable-theme (after context-coloring-enable-theme (theme) activate)
+ "Add colors to themes just-in-time."
+ (when (and (not (eq theme 'user)) ; Called internally.
+ (custom-theme-p theme)) ; Guard against non-existent themes.
+ (context-coloring-apply-theme theme)))
(context-coloring-define-theme
'leuven
@@ -524,6 +548,10 @@ coloring."
(context-coloring-define-theme
'solarized
+ :aliases '(solarized-light
+ solarized-dark
+ sanityinc-solarized-light
+ sanityinc-solarized-dark)
:colors '("#839496"
"#268bd2"
"#2aa198"
- [elpa] master updated (3c5b50a -> 8b585bc), Jackson Ray Hamilton, 2015/02/07
- [elpa] master 6e69c6b 02/10: Update theme documentation., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 90a4828 01/10: Update installation instructions., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 3a6c5db 03/10: Remove require., Jackson Ray Hamilton, 2015/02/07
- [elpa] master d8c682c 04/10: Add more placeholder faces., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 39d97de 05/10: Add leuven theme., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 5cd77bb 07/10: Evaluate theme name., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 87a0ee4 06/10: Automatically load themes alongside custom themes.,
Jackson Ray Hamilton <=
- [elpa] master 7717ded 08/10: Cleanup readme., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 59de0b7 09/10: Version 4.1.0., Jackson Ray Hamilton, 2015/02/07
- [elpa] master 8b585bc 10/10: Merge commit '59de0b7591713d38c6d5c99cb49c4a4cc434a272' from context-coloring, Jackson Ray Hamilton, 2015/02/07