\f
* Lisp Changes in Emacs 29.1
+** Themes
+
+---
+*** New hooks 'enable-theme-hook' and 'disable-theme-hook'.
+These are run after enabling and disabling a theme, respectively.
+
+---
+*** Themes can now be made obsolete.
+Using 'make-obsolete' on a theme is now supported. This will make
+'load-theme' issue a warning when loading the theme.
+
+++
** New hook 'display-monitors-changed-functions'.
It is called whenever the configuration of different monitors on a
** Third 'mapconcat' argument SEPARATOR is now optional.
An explicit nil always meant the empty string, now it can be left out.
----
-** Themes can now be made obsolete.
-Using 'make-obsolete' on a theme is now supported. This will make
-'load-theme' issue a warning when loading the theme.
-
+++
** New function 'define-keymap'.
This function allows defining a number of keystrokes with one form.
\f
;;; Enabling and disabling loaded themes.
+(defcustom enable-theme-hook nil
+ "Atypical hook run after a theme has been enabled.
+The functions in the hook are called with one parameter -- the
+ name of the theme that's been enabled (as a symbol)."
+ :type 'hook
+ :group 'customize
+ :version "29.1")
+
+(defcustom disable-theme-hook nil
+ "Atypical hook run after a theme has been disabled.
+The functions in the hook are called with one parameter -- the
+ name of the theme that's been disabled (as a symbol)."
+ :type 'hook
+ :group 'customize
+ :version "29.1")
+
(defun enable-theme (theme)
"Reenable all variable and face settings defined by THEME.
THEME should be either `user', or a theme loaded via `load-theme'.
precedence (after `user') among enabled themes.
Note that any already-enabled themes remain enabled after this
-function runs. To disable other themes, use `disable-theme'."
+function runs. To disable other themes, use `disable-theme'.
+
+After THEME has been enabled, `enable-theme-hook' is run."
(interactive (list (intern
(completing-read
"Enable custom theme: "
(setq custom-enabled-themes
(cons theme (remq theme custom-enabled-themes)))
;; Give the `user' theme the highest priority.
- (enable-theme 'user)))
+ (enable-theme 'user))
+ ;; Allow callers to react to the enabling.
+ (run-hook-with-args 'enable-theme-hook theme))
(defcustom custom-enabled-themes nil
"List of enabled Custom Themes, highest precedence first.
(defun disable-theme (theme)
"Disable all variable and face settings defined by THEME.
-See `custom-enabled-themes' for a list of enabled themes."
+See `custom-enabled-themes' for a list of enabled themes.
+
+After THEME has been disabled, `disable-theme-hook' is run."
(interactive (list (intern
(completing-read
"Disable custom theme: "
"unspecified-fg" "black"))
(face-set-after-frame-default frame))
(setq custom-enabled-themes
- (delq theme custom-enabled-themes))))
+ (delq theme custom-enabled-themes))
+ ;; Allow callers to react to the disabling.
+ (run-hook-with-args 'disable-theme-hook theme)))
;; Only used if window-system not null.
(declare-function x-get-resource "frame.c"