mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
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.
This commit is contained in:
parent
050fa501a2
commit
22ae842b34
2 changed files with 39 additions and 9 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue