Move built-in theme directory to etc/.
authorChong Yidong <cyd@stupidchicken.com>
Sat, 16 Oct 2010 18:27:08 +0000 (14:27 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Sat, 16 Oct 2010 18:27:08 +0000 (14:27 -0400)
* custom.el: Custom themes no longer use load-path.
(custom-theme-load-path): New option.  Change built-in theme
directory to etc/.
(custom-enabled-themes): Add custom-theme-load-path dependency.
(custom-theme--load-path): New function.
(load-theme, custom-available-themes): Use it.

* cus-theme.el (describe-theme-1): Use custom-theme--load-path.
(customize-themes): Link to custom-theme-load-path variable.

etc/ChangeLog
etc/NEWS
etc/themes/tango-dark-theme.el [moved from lisp/themes/tango-dark-theme.el with 100% similarity]
etc/themes/tango-theme.el [moved from lisp/themes/tango-theme.el with 100% similarity]
etc/themes/wheatgrass-theme.el [moved from lisp/themes/wheatgrass-theme.el with 100% similarity]
lisp/ChangeLog
lisp/cus-theme.el
lisp/custom.el

index c084d4f..3e5a6e7 100644 (file)
@@ -1,3 +1,7 @@
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+       * themes: New directory for custom theme files, moved from lisp/.
+
 2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
 
        * tutorials/TUTORIAL.es: Fix typos.
index 1c43777..8429edc 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -199,6 +199,11 @@ loaded, customize `package-load-list'.
 
 *** `M-x customize-themes' lists Custom themes which can be enabled.
 
+*** New option `custom-theme-load-path' is the load path for themes.
+Emacs no longer looks for custom themes in `load-path'.  The default
+is to search in `custom-theme-directory', followed by a built-in theme
+directory named "themes/" in `data-directory'.
+
 ** The user option `remote-file-name-inhibit-cache' controls whether
 the remote file-name cache is used for read access.
 
index 109b4d9..9c47091 100644 (file)
@@ -1,3 +1,17 @@
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+       * custom.el: Custom themes no longer use load-path.
+       (custom-theme-load-path): New option.  Change built-in theme
+       directory to etc/.
+       (custom-enabled-themes): Add custom-theme-load-path dependency.
+       (custom-theme--load-path): New function.
+       (load-theme, custom-available-themes): Use it.
+
+       * cus-theme.el (describe-theme-1): Use custom-theme--load-path.
+       (customize-themes): Link to custom-theme-load-path variable.
+
+       * themes/*.el: Moved to etc/.
+
 2010-10-16  Ralf Angeli  <angeli@caeruleus.net>
 
        * textmodes/reftex-cite.el
index 241dd6c..34a0353 100644 (file)
@@ -316,7 +316,7 @@ SPEC, if non-nil, should be a face spec to which to set the widget."
 
     (with-temp-buffer
       (emacs-lisp-mode)
-      (unless (file-exists-p custom-theme-directory)
+      (unless (file-directory-p custom-theme-directory)
        (make-directory (file-name-as-directory custom-theme-directory) t))
       (setq buffer-file-name filename)
       (erase-buffer)
@@ -419,7 +419,7 @@ It includes all faces in list FACES."
   (prin1 theme)
   (princ " is a custom theme")
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
-                        (cons custom-theme-directory load-path)
+                        (custom-theme--load-path)
                         '("" "c")))
        doc)
     (when fn
@@ -508,26 +508,15 @@ omitted, a buffer named *Custom Themes* is used."
     "Type RET or click to enable/disable listed custom themes.
 Type \\[custom-describe-theme] to describe the theme at point.
 Theme files are named *-theme.el in `"))
-  (when (stringp custom-theme-directory)
-    (widget-create 'link :value custom-theme-directory
-                  :button-face 'custom-link
-                  :mouse-face 'highlight
-                  :pressed-face 'highlight
-                  :help-echo "Describe `custom-theme-directory'."
-                  :keymap custom-mode-link-map
-                  :follow-link 'mouse-face
-                  :action (lambda (widget &rest ignore)
-                            (describe-variable 'custom-theme-directory)))
-    (widget-insert "' or `"))
-  (widget-create 'link :value "load-path"
+  (widget-create 'link :value "custom-theme-load-path"
                 :button-face 'custom-link
                 :mouse-face 'highlight
                 :pressed-face 'highlight
-                :help-echo "Describe `load-path'."
+                :help-echo "Describe `custom-theme-load-path'."
                 :keymap custom-mode-link-map
                 :follow-link 'mouse-face
                 :action (lambda (widget &rest ignore)
-                          (describe-variable 'load-path)))
+                          (describe-variable 'custom-theme-load-path)))
   (widget-insert "'.\n\n")
 
   ;; If the user has made customizations, display a warning and
index c5ebe64..8ece438 100644 (file)
@@ -996,9 +996,8 @@ in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
 \f
 ;;; Defining themes.
 
-;; A theme file should be named `THEME-theme.el' (where THEME is the theme
-;; name), and found in either `custom-theme-directory' or the load path.
-;; It has the following format:
+;; A theme file is named `THEME-theme.el' (where THEME is the theme
+;; name) found in `custom-theme-load-path'.  It has this format:
 ;;
 ;;   (deftheme THEME
 ;;     DOCSTRING)
@@ -1053,16 +1052,31 @@ Every theme X has a property `provide-theme' whose value is \"X-theme\".
 \f
 ;;; Loading themes.
 
-(defcustom custom-theme-directory
-  user-emacs-directory
-  "Directory in which Custom theme files should be written.
-`load-theme' searches this directory in addition to load-path.
-The command `customize-create-theme' writes the files it produces
-into this directory."
+(defcustom custom-theme-directory user-emacs-directory
+  "Default user directory for storing custom theme files.
+The command `customize-create-theme' writes theme files into this
+directory.  By default, Emacs searches for custom themes in this
+directory first---see `custom-theme-load-path'."
   :type 'string
   :group 'customize
   :version "22.1")
 
+(defcustom custom-theme-load-path (list 'custom-theme-directory t)
+  "List of directories to search for custom theme files.
+Emacs commands for loading custom themes (e.g. `customize-themes'
+and `load-theme') search for custom theme files in the specified
+order.  Each element in the list should be one of the following:
+\(i) the symbol `custom-theme-directory', which means the value
+of that variable; (ii) the symbol t (the built-in Emacs theme
+directory, named \"themes\" in `data-directory'); or \(iii) a
+directory name (a string)."
+  :type '(repeat (choice (const :tag "custom-theme-directory"
+                               custom-theme-directory)
+                        (const :tag "Built-in theme directory" t)
+                        directory))
+  :group 'customize
+  :version "24.1")
+
 (defvar custom--inhibit-theme-enable nil
   "If non-nil, loading a theme does not enable it.
 This internal variable is set by `load-theme' when its NO-ENABLE
@@ -1108,7 +1122,7 @@ the theme."
     (put theme 'theme-feature nil)
     (put theme 'theme-documentation nil))
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
-                        (cons custom-theme-directory load-path)
+                        (custom-theme--load-path)
                         '("" "c"))))
     (unless fn
       (error "Unable to find theme file for `%s'." theme))
@@ -1158,19 +1172,29 @@ NAME should be a symbol."
 
 (defun custom-available-themes ()
   "Return a list of available Custom themes (symbols)."
-  (let* ((load-path (if (file-directory-p custom-theme-directory)
-                       (cons custom-theme-directory load-path)
-                     load-path))
-        sym themes)
-    (dolist (dir load-path)
-      (dolist (file (file-expand-wildcards
-                    (expand-file-name "*-theme.el" dir) t))
-       (setq file (file-name-nondirectory file))
-       (and (string-match "\\`\\(.+\\)-theme.el\\'" file)
-            (setq sym (intern (match-string 1 file)))
-            (custom-theme-name-valid-p sym)
-            (push sym themes))))
+  (let* (sym themes)
+    (dolist (dir (custom-theme--load-path))
+      (when (file-directory-p dir)
+       (dolist (file (file-expand-wildcards
+                      (expand-file-name "*-theme.el" dir) t))
+         (setq file (file-name-nondirectory file))
+         (and (string-match "\\`\\(.+\\)-theme.el\\'" file)
+              (setq sym (intern (match-string 1 file)))
+              (custom-theme-name-valid-p sym)
+              (push sym themes)))))
     (delete-dups themes)))
+
+(defun custom-theme--load-path ()
+  (let (lpath)
+    (dolist (f custom-theme-load-path)
+      (cond ((eq f 'custom-theme-directory)
+            (setq f custom-theme-directory))
+           ((eq f t)
+            (setq f (expand-file-name "themes" data-directory))))
+      (if (file-directory-p f)
+         (push f lpath)))
+    (nreverse lpath)))
+
 \f
 ;;; Enabling and disabling loaded themes.
 
@@ -1212,7 +1236,7 @@ This does not include the `user' theme, which is set by Customize,
 and always takes precedence over other Custom Themes."
   :group 'customize
   :type  '(repeat symbol)
-  :set-after '(custom-theme-directory)  ; so we can find the themes
+  :set-after '(custom-theme-directory custom-theme-load-path)
   :set (lambda (symbol themes)
         ;; Avoid an infinite loop when custom-enabled-themes is
         ;; defined in a theme (e.g. `user').  Enabling the theme sets