Next: , Previous: , Up: Advanced customization [Index]


7.17 DIY Toggle themes without reloading them

Users who have a stable setup and who only ever need to toggle between the themes without triggering a full reload, are better off defining their own command which calls enable-theme instead of load-theme:

(defun my-modus-themes-toggle ()
 "Toggle between `modus-operandi' and `modus-vivendi' themes.
This uses `enable-theme' instead of the standard method of
`load-theme'. The technicalities are covered in the Modus themes
manual."
 (interactive)
 (pcase (modus-themes--current-theme)
 ('modus-operandi (progn (enable-theme 'modus-vivendi)
 (disable-theme 'modus-operandi)))
 ('modus-vivendi (progn (enable-theme 'modus-operandi)
 (disable-theme 'modus-vivendi)))
 (_ (error "No Modus theme is loaded; evaluate `modus-themes-load-themes' first"))))

Differences between loading and enabling.

Recall that modus-themes-toggle uses load-theme.

AltStyle によって変換されたページ (->オリジナル) /