(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)
(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
"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
\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)
\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
(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))
(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.
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