953 |
|
|
954 |
This allows for a file-name convention for autoloading themes: |
This allows for a file-name convention for autoloading themes: |
955 |
Every theme X has a property `provide-theme' whose value is \"X-theme\". |
Every theme X has a property `provide-theme' whose value is \"X-theme\". |
956 |
\(require-theme X) then attempts to load the file `X-theme.el'." |
\(load-theme X) then attempts to load the file `X-theme.el'." |
957 |
(intern (concat (symbol-name theme) "-theme"))) |
(intern (concat (symbol-name theme) "-theme"))) |
958 |
|
|
959 |
;;; Loading themes. |
;;; Loading themes. |
996 |
"~/_emacs.d/" |
"~/_emacs.d/" |
997 |
"~/.emacs.d/") |
"~/.emacs.d/") |
998 |
"Directory in which Custom theme files should be written. |
"Directory in which Custom theme files should be written. |
999 |
`require-theme' searches this directory in addition to load-path. |
`load-theme' searches this directory in addition to load-path. |
1000 |
The command `customize-create-theme' writes the files it produces |
The command `customize-create-theme' writes the files it produces |
1001 |
into this directory." |
into this directory." |
1002 |
:type 'string |
:type 'string |
1031 |
;; `user' must always be the highest-precedence enabled theme. |
;; `user' must always be the highest-precedence enabled theme. |
1032 |
;; Make that remain true. (This has the effect of making user settings |
;; Make that remain true. (This has the effect of making user settings |
1033 |
;; override the ones just loaded, too.) |
;; override the ones just loaded, too.) |
1034 |
(custom-enable-theme 'user)) |
(enable-theme 'user)) |
1035 |
|
|
1036 |
(defun require-theme (theme) |
(defun load-theme (theme) |
1037 |
"Try to load a theme's settings from its file. |
"Try to load a theme's settings from its file. |
1038 |
This also enables the theme; use `custom-disable-theme' to disable it." |
This also enables the theme; use `disable-theme' to disable it." |
1039 |
|
|
1040 |
;; THEME's feature is stored in THEME's `theme-feature' property. |
;; THEME's feature is stored in THEME's `theme-feature' property. |
1041 |
;; Usually the `theme-feature' property contains a symbol created |
;; Usually the `theme-feature' property contains a symbol created |
1043 |
|
|
1044 |
;; Note we do no check for validity of the theme here. |
;; Note we do no check for validity of the theme here. |
1045 |
;; This allows to pull in themes by a file-name convention |
;; This allows to pull in themes by a file-name convention |
1046 |
|
(interactive "SCustom theme name: ") |
1047 |
(let ((load-path (if (file-directory-p custom-theme-directory) |
(let ((load-path (if (file-directory-p custom-theme-directory) |
1048 |
(cons custom-theme-directory load-path) |
(cons custom-theme-directory load-path) |
1049 |
load-path))) |
load-path))) |
1071 |
(let ((themes-loaded (get by-theme 'theme-loads-themes))) |
(let ((themes-loaded (get by-theme 'theme-loads-themes))) |
1072 |
(dolist (theme body) |
(dolist (theme body) |
1073 |
(cond ((and (consp theme) (eq (car theme) 'reset)) |
(cond ((and (consp theme) (eq (car theme) 'reset)) |
1074 |
(custom-disable-theme (cadr theme))) |
(disable-theme (cadr theme))) |
1075 |
((and (consp theme) (eq (car theme) 'hidden)) |
((and (consp theme) (eq (car theme) 'hidden)) |
1076 |
(require-theme (cadr theme)) |
(load-theme (cadr theme)) |
1077 |
(custom-disable-theme (cadr theme))) |
(disable-theme (cadr theme))) |
1078 |
(t |
(t |
1079 |
(require-theme theme))) |
(load-theme theme))) |
1080 |
(push theme themes-loaded)) |
(push theme themes-loaded)) |
1081 |
(put by-theme 'theme-loads-themes themes-loaded))) |
(put by-theme 'theme-loads-themes themes-loaded))) |
1082 |
|
|
1088 |
|
|
1089 |
;;; Enabling and disabling loaded themes. |
;;; Enabling and disabling loaded themes. |
1090 |
|
|
1091 |
(defun custom-enable-theme (theme) |
(defun enable-theme (theme) |
1092 |
"Reenable all variable and face settings defined by THEME. |
"Reenable all variable and face settings defined by THEME. |
1093 |
The newly enabled theme gets the highest precedence (after `user'). |
The newly enabled theme gets the highest precedence (after `user'). |
1094 |
If it is already enabled, just give it highest precedence (after `user')." |
If it is already enabled, just give it highest precedence (after `user')." |
1095 |
|
(interactive "SEnable Custom theme: ") |
1096 |
(let ((settings (get theme 'theme-settings))) |
(let ((settings (get theme 'theme-settings))) |
1097 |
(dolist (s settings) |
(dolist (s settings) |
1098 |
(let* ((prop (car s)) |
(let* ((prop (car s)) |
1106 |
(cons theme (delq theme custom-enabled-themes))) |
(cons theme (delq theme custom-enabled-themes))) |
1107 |
;; `user' must always be the highest-precedence enabled theme. |
;; `user' must always be the highest-precedence enabled theme. |
1108 |
(unless (eq theme 'user) |
(unless (eq theme 'user) |
1109 |
(custom-enable-theme 'user))) |
(enable-theme 'user))) |
1110 |
|
|
1111 |
(defun custom-disable-theme (theme) |
(defun disable-theme (theme) |
1112 |
"Disable all variable and face settings defined by THEME. |
"Disable all variable and face settings defined by THEME. |
1113 |
See `custom-known-themes' for a list of known themes." |
See `custom-known-themes' for a list of known themes." |
1114 |
|
(interactive "SDisable Custom theme: ") |
1115 |
(let ((settings (get theme 'theme-settings))) |
(let ((settings (get theme 'theme-settings))) |
1116 |
(dolist (s settings) |
(dolist (s settings) |
1117 |
(let* ((prop (car s)) |
(let* ((prop (car s)) |