diff options
| author | Mauro Aranda | 2025-03-09 09:22:29 -0300 |
|---|---|---|
| committer | Mauro Aranda | 2025-03-09 09:22:29 -0300 |
| commit | 203747b87fbf976fda887d0652b05685447b8d65 (patch) | |
| tree | bebb2bda7c05300df67990fd3a103edcbc86c264 | |
| parent | 5890ee840e65fee2b730079d18faa34c35316368 (diff) | |
| download | emacs-203747b87fbf976fda887d0652b05685447b8d65.tar.gz emacs-203747b87fbf976fda887d0652b05685447b8d65.zip | |
Allow changing theme settings without reloading it
* lisp/custom.el (custom--should-apply-setting): Return non-nil
for an enabled theme. Provide docstring. This allows for users
to reevaluate a custom-theme-set-* function and see the settings
applied right away. (Bug#76685)
(custom--inhibit-theme-enable): Adapt docstring.
* etc/NEWS: Announce the new behavior.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/custom.el | 14 |
2 files changed, 18 insertions, 1 deletions
| @@ -384,6 +384,11 @@ to wrong results in some cases. We believe that it is no longer useful; | |||
| 384 | please contact us if you still need it for some reason. | 384 | please contact us if you still need it for some reason. |
| 385 | 385 | ||
| 386 | ** 'byte-compile-cond-use-jump-table' is now obsolete. | 386 | ** 'byte-compile-cond-use-jump-table' is now obsolete. |
| 387 | --- | ||
| 388 | ** Modified settings for an enabled theme now apply immediately. | ||
| 389 | Evaluating a custom-theme-set-faces or custom-theme-set-variables | ||
| 390 | call for an enabled theme causes the settings to apply immediately, | ||
| 391 | without a need to re-load the theme. | ||
| 387 | 392 | ||
| 388 | 393 | ||
| 389 | * Editing Changes in Emacs 31.1 | 394 | * Editing Changes in Emacs 31.1 |
diff --git a/lisp/custom.el b/lisp/custom.el index 5360c397c59..d309754ab9b 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -901,7 +901,15 @@ to the front of this list.") | |||
| 901 | (error "Unknown theme `%s'" theme))) | 901 | (error "Unknown theme `%s'" theme))) |
| 902 | 902 | ||
| 903 | (defun custom--should-apply-setting (theme) | 903 | (defun custom--should-apply-setting (theme) |
| 904 | (or (null custom--inhibit-theme-enable) | 904 | "Non-nil if settings for the theme THEME should apply immediately. |
| 905 | |||
| 906 | Theme settings apply immediately if: | ||
| 907 | - THEME is already enabled. | ||
| 908 | - THEME is being enabled via `enable-theme' or an interactive call to | ||
| 909 | `load-theme'. | ||
| 910 | - THEME is the `user' theme." | ||
| 911 | (or (memq theme custom-enabled-themes) | ||
| 912 | (null custom--inhibit-theme-enable) | ||
| 905 | (and (eq custom--inhibit-theme-enable 'apply-only-user) | 913 | (and (eq custom--inhibit-theme-enable 'apply-only-user) |
| 906 | (eq theme 'user)))) | 914 | (eq theme 'user)))) |
| 907 | 915 | ||
| @@ -1235,6 +1243,10 @@ external packages). For manual user customizations, use | |||
| 1235 | 1243 | ||
| 1236 | (defvar custom--inhibit-theme-enable 'apply-only-user | 1244 | (defvar custom--inhibit-theme-enable 'apply-only-user |
| 1237 | "Whether the custom-theme-set-* functions act immediately. | 1245 | "Whether the custom-theme-set-* functions act immediately. |
| 1246 | |||
| 1247 | If the theme argument for those functions is an already enabled theme, | ||
| 1248 | the theme settings always apply immediately, ignoring this variable. | ||
| 1249 | |||
| 1238 | If nil, `custom-theme-set-variables' and `custom-theme-set-faces' | 1250 | If nil, `custom-theme-set-variables' and `custom-theme-set-faces' |
| 1239 | change the current values of the given variable or face. If | 1251 | change the current values of the given variable or face. If |
| 1240 | t, they just make a record of the theme settings. If the | 1252 | t, they just make a record of the theme settings. If the |