emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101981: Move built-in theme director


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101981: Move built-in theme directory to etc/.
Date: Sat, 16 Oct 2010 14:27:08 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101981
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2010-10-16 14:27:08 -0400
message:
  Move built-in theme directory to etc/.
  
  * 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.
renamed:
  lisp/themes/ => etc/themes/
modified:
  etc/ChangeLog
  etc/NEWS
  lisp/ChangeLog
  lisp/cus-theme.el
  lisp/custom.el
=== modified file 'etc/ChangeLog'
--- a/etc/ChangeLog     2010-10-14 14:32:27 +0000
+++ b/etc/ChangeLog     2010-10-16 18:27:08 +0000
@@ -1,3 +1,7 @@
+2010-10-16  Chong Yidong  <address@hidden>
+
+       * themes: New directory for custom theme files, moved from lisp/.
+
 2010-10-14  Juanma Barranquero  <address@hidden>
 
        * tutorials/TUTORIAL.es: Fix typos.

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2010-10-15 16:44:01 +0000
+++ b/etc/NEWS  2010-10-16 18:27:08 +0000
@@ -199,6 +199,11 @@
 
 *** `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.
 

=== renamed directory 'lisp/themes' => 'etc/themes'
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-16 15:08:47 +0000
+++ b/lisp/ChangeLog    2010-10-16 18:27:08 +0000
@@ -1,3 +1,17 @@
+2010-10-16  Chong Yidong  <address@hidden>
+
+       * 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  <address@hidden>
 
        * textmodes/reftex-cite.el

=== modified file 'lisp/cus-theme.el'
--- a/lisp/cus-theme.el 2010-10-16 00:16:34 +0000
+++ b/lisp/cus-theme.el 2010-10-16 18:27:08 +0000
@@ -316,7 +316,7 @@
 
     (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 @@
   (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 @@
     "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

=== modified file 'lisp/custom.el'
--- a/lisp/custom.el    2010-10-14 03:55:18 +0000
+++ b/lisp/custom.el    2010-10-16 18:27:08 +0000
@@ -996,9 +996,8 @@
 
 ;;; 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 @@
 
 ;;; 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 @@
     (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 @@
 
 (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)))
+
 
 ;;; Enabling and disabling loaded themes.
 
@@ -1212,7 +1236,7 @@
 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


reply via email to

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