diff options
| author | Daniel Colascione | 2018-06-16 15:42:56 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2018-06-16 15:44:23 -0700 |
| commit | aabaa9f8c8b79df44887392fcaa199e17b016afd (patch) | |
| tree | 7c7f15543866bad5acaa5ca9ce49877bfb5740fb | |
| parent | 6021e1db92e355fbf5c66765fb0bc4658a80180a (diff) | |
| download | emacs-aabaa9f8c8b79df44887392fcaa199e17b016afd.tar.gz emacs-aabaa9f8c8b79df44887392fcaa199e17b016afd.zip | |
Apply non-user themes only when asked
Theme settings now generally aren't actually applied until a call to
`enable-theme-, either one made explicitly or implicitly through
`load-theme' with NO-ENABLE nil. This change has the effect of not
applying theme changes just because we load a lisp file containing a
theme specification. The previous behavior is preserved for the
special case of the `user' theme, which is frequently used for
ad-hoc customization.
* lisp/cus-face.el (custom-theme-set-faces): Call
`custom--should-apply-setting' to decide whether to apply
a setting.
* lisp/custom.el (custom--should-apply-setting): New function.
(custom--inhibit-theme-enable): Add `apply-only-user' option;
default to it.
(custom-push-theme, custom-theme-set-variables): Call
`custom--should-apply-setting' to decide whether to apply
a setting.
| -rw-r--r-- | etc/NEWS | 9 | ||||
| -rw-r--r-- | lisp/cus-face.el | 2 | ||||
| -rw-r--r-- | lisp/custom.el | 15 |
3 files changed, 21 insertions, 5 deletions
| @@ -518,6 +518,15 @@ names" in the Tramp manual for full documentation of these facilities. | |||
| 518 | 518 | ||
| 519 | * Incompatible Lisp Changes in Emacs 27.1 | 519 | * Incompatible Lisp Changes in Emacs 27.1 |
| 520 | 520 | ||
| 521 | +++ | ||
| 522 | ** Theme settings generally aren't actually applied until a call to | ||
| 523 | `enable-theme-, either one made explicitly or implicitly through | ||
| 524 | `load-theme' with NO-ENABLE nil. This change has the effect of not | ||
| 525 | applying theme changes just because we load a lisp file containing a | ||
| 526 | theme specification. The previous behavior is preserved for the | ||
| 527 | special case of the `user' theme, which is frequently used for | ||
| 528 | ad-hoc customization. | ||
| 529 | |||
| 521 | ** The 'repetitions' argument of 'benchmark-run' can now also be a variable. | 530 | ** The 'repetitions' argument of 'benchmark-run' can now also be a variable. |
| 522 | ** The FILENAME argument to 'file-name-base' is now mandatory and no | 531 | ** The FILENAME argument to 'file-name-base' is now mandatory and no |
| 523 | longer defaults to 'buffer-file-name'. | 532 | longer defaults to 'buffer-file-name'. |
diff --git a/lisp/cus-face.el b/lisp/cus-face.el index 2b352b3dc60..039c1fafa70 100644 --- a/lisp/cus-face.el +++ b/lisp/cus-face.el | |||
| @@ -342,7 +342,7 @@ argument list." | |||
| 342 | ;; is aliased to. | 342 | ;; is aliased to. |
| 343 | (if (get face 'face-alias) | 343 | (if (get face 'face-alias) |
| 344 | (setq face (get face 'face-alias))) | 344 | (setq face (get face 'face-alias))) |
| 345 | (if custom--inhibit-theme-enable | 345 | (if (custom--should-apply-setting theme) |
| 346 | ;; Just update theme settings. | 346 | ;; Just update theme settings. |
| 347 | (custom-push-theme 'theme-face face theme 'set spec) | 347 | (custom-push-theme 'theme-face face theme 'set spec) |
| 348 | ;; Update theme settings and set the face spec. | 348 | ;; Update theme settings and set the face spec. |
diff --git a/lisp/custom.el b/lisp/custom.el index 2a489c4f5b3..4a778a0573e 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -843,6 +843,11 @@ to the front of this list.") | |||
| 843 | (unless (custom-theme-p theme) | 843 | (unless (custom-theme-p theme) |
| 844 | (error "Unknown theme `%s'" theme))) | 844 | (error "Unknown theme `%s'" theme))) |
| 845 | 845 | ||
| 846 | (defun custom--should-apply-setting (theme) | ||
| 847 | (or (null custom--inhibit-theme-enable) | ||
| 848 | (and (eq custom--inhibit-theme-enable 'apply-only-user) | ||
| 849 | (eq theme 'user)))) | ||
| 850 | |||
| 846 | (defun custom-push-theme (prop symbol theme mode &optional value) | 851 | (defun custom-push-theme (prop symbol theme mode &optional value) |
| 847 | "Record VALUE for face or variable SYMBOL in custom theme THEME. | 852 | "Record VALUE for face or variable SYMBOL in custom theme THEME. |
| 848 | PROP is `theme-face' for a face, `theme-value' for a variable. | 853 | PROP is `theme-face' for a face, `theme-value' for a variable. |
| @@ -882,7 +887,7 @@ See `custom-known-themes' for a list of known themes." | |||
| 882 | (setcar (cdr setting) value))) | 887 | (setcar (cdr setting) value))) |
| 883 | ;; Add a new setting: | 888 | ;; Add a new setting: |
| 884 | (t | 889 | (t |
| 885 | (unless custom--inhibit-theme-enable | 890 | (when (custom--should-apply-setting theme) |
| 886 | (unless old | 891 | (unless old |
| 887 | ;; If the user changed a variable outside of Customize, save | 892 | ;; If the user changed a variable outside of Customize, save |
| 888 | ;; the value to a fake theme, `changed'. If the theme is | 893 | ;; the value to a fake theme, `changed'. If the theme is |
| @@ -981,7 +986,7 @@ COMMENT is a comment string about SYMBOL." | |||
| 981 | (let* ((symbol (indirect-variable (nth 0 entry))) | 986 | (let* ((symbol (indirect-variable (nth 0 entry))) |
| 982 | (value (nth 1 entry))) | 987 | (value (nth 1 entry))) |
| 983 | (custom-push-theme 'theme-value symbol theme 'set value) | 988 | (custom-push-theme 'theme-value symbol theme 'set value) |
| 984 | (unless custom--inhibit-theme-enable | 989 | (when (custom--should-apply-setting theme) |
| 985 | ;; Now set the variable. | 990 | ;; Now set the variable. |
| 986 | (let* ((now (nth 2 entry)) | 991 | (let* ((now (nth 2 entry)) |
| 987 | (requests (nth 3 entry)) | 992 | (requests (nth 3 entry)) |
| @@ -1149,11 +1154,13 @@ This variable is designed for use in lisp code (including | |||
| 1149 | external packages). For manual user customizations, use | 1154 | external packages). For manual user customizations, use |
| 1150 | `custom-theme-directory' instead.") | 1155 | `custom-theme-directory' instead.") |
| 1151 | 1156 | ||
| 1152 | (defvar custom--inhibit-theme-enable nil | 1157 | (defvar custom--inhibit-theme-enable 'apply-only-user |
| 1153 | "Whether the custom-theme-set-* functions act immediately. | 1158 | "Whether the custom-theme-set-* functions act immediately. |
| 1154 | If nil, `custom-theme-set-variables' and `custom-theme-set-faces' | 1159 | If nil, `custom-theme-set-variables' and `custom-theme-set-faces' |
| 1155 | change the current values of the given variable or face. If | 1160 | change the current values of the given variable or face. If |
| 1156 | non-nil, they just make a record of the theme settings.") | 1161 | t, they just make a record of the theme settings. If the |
| 1162 | value is `apply-only-user', then apply setting to the | ||
| 1163 | `user' theme immediately and defer other updates.") | ||
| 1157 | 1164 | ||
| 1158 | (defun provide-theme (theme) | 1165 | (defun provide-theme (theme) |
| 1159 | "Indicate that this file provides THEME. | 1166 | "Indicate that this file provides THEME. |