Add new user option 'custom-ensure-single-theme'
* etc/NEWS: Mention it. * lisp/custom.el (custom-ensure-single-active-theme): Add it. (load-theme): Use it.
This commit is contained in:
parent
f31b9d86a6
commit
b4dbf7184c
2 changed files with 23 additions and 0 deletions
11
etc/NEWS
11
etc/NEWS
|
@ -2932,6 +2932,17 @@ These are run after enabling and disabling a theme, respectively.
|
||||||
Using 'make-obsolete' on a theme is now supported. This will make
|
Using 'make-obsolete' on a theme is now supported. This will make
|
||||||
'load-theme' issue a warning when loading the theme.
|
'load-theme' issue a warning when loading the theme.
|
||||||
|
|
||||||
|
+++
|
||||||
|
*** New command 'toggle-theme'
|
||||||
|
If a theme defines a dual pair (e.g. a light or dark variant) this
|
||||||
|
command can be used disable the current one and enable the other.
|
||||||
|
|
||||||
|
---
|
||||||
|
*** New user option 'custom-ensure-single-active-theme'
|
||||||
|
If non-nil, all themes will be disabled before a new theme is enabled,
|
||||||
|
so that there is always at most one active theme at any time.
|
||||||
|
|
||||||
|
|
||||||
+++
|
+++
|
||||||
** New hook 'display-monitors-changed-functions'.
|
** New hook 'display-monitors-changed-functions'.
|
||||||
It is called whenever the configuration of different monitors on a
|
It is called whenever the configuration of different monitors on a
|
||||||
|
|
|
@ -1280,6 +1280,12 @@ This variable cannot be set in a Custom theme."
|
||||||
:risky t
|
:risky t
|
||||||
:version "24.1")
|
:version "24.1")
|
||||||
|
|
||||||
|
(defcustom custom-ensure-single-active-theme nil
|
||||||
|
"Non-nil means that `load-theme' should ensure only one theme is active."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'customize
|
||||||
|
:version "29.1")
|
||||||
|
|
||||||
(defun load-theme (theme &optional no-confirm no-enable)
|
(defun load-theme (theme &optional no-confirm no-enable)
|
||||||
"Load Custom theme named THEME from its file and possibly enable it.
|
"Load Custom theme named THEME from its file and possibly enable it.
|
||||||
The theme file is named THEME-theme.el, in one of the directories
|
The theme file is named THEME-theme.el, in one of the directories
|
||||||
|
@ -1304,6 +1310,9 @@ This function is normally called through Customize when setting
|
||||||
should be called with a non-nil NO-CONFIRM argument, or after
|
should be called with a non-nil NO-CONFIRM argument, or after
|
||||||
`custom-safe-themes' has been loaded.
|
`custom-safe-themes' has been loaded.
|
||||||
|
|
||||||
|
If `custom-ensure-single-active-theme' is non-nil, all other active
|
||||||
|
themes will be disabled before THEME is enabled.
|
||||||
|
|
||||||
Return t if THEME was successfully loaded, nil otherwise."
|
Return t if THEME was successfully loaded, nil otherwise."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
|
@ -1367,6 +1376,9 @@ Return t if THEME was successfully loaded, nil otherwise."
|
||||||
(setq tail (cdr tail)))
|
(setq tail (cdr tail)))
|
||||||
(when found
|
(when found
|
||||||
(put theme 'theme-settings (cons found (delq found settings)))))
|
(put theme 'theme-settings (cons found (delq found settings)))))
|
||||||
|
;; Check if the user only wants one theme to be active
|
||||||
|
(when custom-ensure-single-active-theme
|
||||||
|
(mapc #'disable-theme custom-enabled-themes))
|
||||||
;; Finally, enable the theme.
|
;; Finally, enable the theme.
|
||||||
(unless no-enable
|
(unless no-enable
|
||||||
(enable-theme theme))
|
(enable-theme theme))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue