summaryrefslogtreecommitdiff
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-21 14:56:13 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-21 14:56:13 +0200
commit22ae842b346621095223213621f2244a5a59d3b8 (patch)
tree4fa3f0c45fc7d5cc6f506b6da4316e1fc4952f55 /lisp/custom.el
parent050fa501a204e8db1688e89e2aaccb87f0286b27 (diff)
downloademacs-22ae842b346621095223213621f2244a5a59d3b8.tar.gz
Add new hooks when enabling and disabling themes
* lisp/custom.el (enable-theme-hook, disable-theme-hook): New hooks (bug#37802). (enable-theme, disable-theme): Call them.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el32
1 files changed, 28 insertions, 4 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 76c14831cac..181711967db 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1422,6 +1422,22 @@ are not directories are omitted from the expansion."
;;; 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'.
@@ -1430,7 +1446,9 @@ After this function completes, THEME will have the highest
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: "
@@ -1478,7 +1496,9 @@ function runs. To disable other themes, use `disable-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.
@@ -1523,7 +1543,9 @@ Setting this variable through Customize calls `enable-theme' or
(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: "
@@ -1567,7 +1589,9 @@ See `custom-enabled-themes' for a list of enabled themes."
"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"