changeset 67123:6e41569f62c8

* custom.el (enable-theme): Signal error if argument is not a theme. Don't recalculate a face if it's not loaded yet. * cus-face.el (custom-theme-set-faces): Don't change saved-face if the `user' theme is in effect.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 25 Nov 2005 18:00:10 +0000
parents d0c771d4e157
children 47ddc89c842c
files lisp/ChangeLog lisp/cus-face.el lisp/custom.el
diffstat 3 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Nov 25 17:57:06 2005 +0000
+++ b/lisp/ChangeLog	Fri Nov 25 18:00:10 2005 +0000
@@ -1,5 +1,11 @@
 2005-11-25  Chong Yidong  <cyd@stupidchicken.com>
 
+	* custom.el (enable-theme): Signal error if argument is not a
+	theme.  Don't recalculate a face if it's not loaded yet.
+
+	* cus-face.el (custom-theme-set-faces): Don't change saved-face if
+	the `user' theme is in effect.
+
 	* info.el (Info-on-current-buffer): Record actual filename in
 	Info-current-file, instead of t, or a fake filename if a non-file
 	buffer.  Make autoload.
--- a/lisp/cus-face.el	Fri Nov 25 17:57:06 2005 +0000
+++ b/lisp/cus-face.el	Fri Nov 25 18:00:10 2005 +0000
@@ -320,13 +320,18 @@
 	    (let ((face (nth 0 entry))
 		  (spec (nth 1 entry))
 		  (now (nth 2 entry))
-		  (comment (nth 3 entry)))
+		  (comment (nth 3 entry))
+		  oldspec)
 	      ;; If FACE is actually an alias, customize the face it
 	      ;; is aliased to.
 	      (if (get face 'face-alias)
 		  (setq face (get face 'face-alias)))
-	      (put face 'saved-face spec)
-	      (put face 'saved-face-comment comment)
+
+	      (setq oldspec (get face 'theme-face))
+	      (when (not (and oldspec (eq 'user (caar oldspec))))
+		(put face 'saved-face spec)
+		(put face 'saved-face-comment comment))
+
 	      (custom-push-theme 'theme-face face theme 'set spec)
 	      (when (or now immediate)
 		(put face 'force-face (if now 'rogue 'immediate)))
--- a/lisp/custom.el	Fri Nov 25 17:57:06 2005 +0000
+++ b/lisp/custom.el	Fri Nov 25 18:00:10 2005 +0000
@@ -1120,9 +1120,14 @@
 (defun enable-theme (theme)
   "Reenable all variable and face settings defined by THEME.
 The newly enabled theme gets the highest precedence (after `user').
-If it is already enabled, just give it highest precedence (after `user')."
+If it is already enabled, just give it highest precedence (after `user').
+
+This signals an error if THEME does not specify any theme
+settings.  Theme settings are set using `load-theme'."
   (interactive "SEnable Custom theme: ")
   (let ((settings (get theme 'theme-settings)))
+    (if (and (not (eq theme 'user)) (null settings))
+	(error "No theme settings defined in %s." (symbol-name theme)))
     (dolist (s settings)
       (let* ((prop (car s))
 	     (symbol (cadr s))
@@ -1130,7 +1135,8 @@
 	(put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
 	(if (eq prop 'theme-value)
 	    (custom-theme-recalc-variable symbol)
-	  (custom-theme-recalc-face symbol)))))
+	  (if (facep symbol)
+	      (custom-theme-recalc-face symbol))))))
   (setq custom-enabled-themes
         (cons theme (delq theme custom-enabled-themes)))
   ;; `user' must always be the highest-precedence enabled theme.