diff --git a/etc/NEWS b/etc/NEWS index ca9669b66e9..7223d8700c1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -384,6 +384,11 @@ to wrong results in some cases. We believe that it is no longer useful; please contact us if you still need it for some reason. ** 'byte-compile-cond-use-jump-table' is now obsolete. +--- +** Modified settings for an enabled theme now apply immediately. +Evaluating a custom-theme-set-faces or custom-theme-set-variables +call for an enabled theme causes the settings to apply immediately, +without a need to re-load the theme. * 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.") (error "Unknown theme `%s'" theme))) (defun custom--should-apply-setting (theme) - (or (null custom--inhibit-theme-enable) + "Non-nil if settings for the theme THEME should apply immediately. + +Theme settings apply immediately if: +- THEME is already enabled. +- THEME is being enabled via `enable-theme' or an interactive call to + `load-theme'. +- THEME is the `user' theme." + (or (memq theme custom-enabled-themes) + (null custom--inhibit-theme-enable) (and (eq custom--inhibit-theme-enable 'apply-only-user) (eq theme 'user)))) @@ -1235,6 +1243,10 @@ external packages). For manual user customizations, use (defvar custom--inhibit-theme-enable 'apply-only-user "Whether the custom-theme-set-* functions act immediately. + +If the theme argument for those functions is an already enabled theme, +the theme settings always apply immediately, ignoring this variable. + If nil, `custom-theme-set-variables' and `custom-theme-set-faces' change the current values of the given variable or face. If t, they just make a record of the theme settings. If the