solarized-emacs

a fork of Bozhidar Batsov's solarized-emacs
git clone https://git.trogloxene.org/solarized-emacs.git
Log | Files | Refs | README

commit 01a350d6a2ed5d95baefa8d2fe91360b1dcfef35
parent e3d2448c9344f73efdb889047f1fc720c6828842
Author: Bozhidar Batsov <bozhidar@batsov.dev>
Date:   Tue,  4 Feb 2025 14:32:51 +0200

Add commands to reload and toggle the themes

Diffstat:
MREADME.md | 4++++
Msolarized.el | 19+++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -38,6 +38,9 @@ or (load-theme 'solarized-dark t) ``` +You can toggle between the light and dark variant of the theme automatically with +`M-x solarized-toggle-theme`. + ## Alternative Palettes The intent of this theme will always be that Solarized-dark/light will give you @@ -106,6 +109,7 @@ elisp code: ``` Note that these need to be set **before** `load-theme` is invoked for Solarized. +Alternatively you can invoke `M-x solarized-reload` after making configuration changes. ### Underline position setting for X diff --git a/solarized.el b/solarized.el @@ -427,6 +427,25 @@ If OVERWRITE is non-nil, overwrite theme file if exist." (define-obsolete-function-alias 'create-solarized-theme-file 'solarized-create-theme-file "1.3.0") +(defun solarized-reload (&optional theme) + "Reload the Solarized theme. +You can specify the variant to reload manually with THEME. + +Useful after changing some configuration options or tweaking some colors." + (interactive) + (let ((theme (or theme (car custom-enabled-themes)))) + (disable-theme theme) + (load-theme theme t))) + +(defun solarized-toggle-theme () + "Toggle between the light and dark variants of Solarized." + (interactive) + (let ((current-theme (car custom-enabled-themes))) + (cond + ((eq current-theme 'solarized-dark) (solarized-reload 'solarized-light)) + ((eq current-theme 'solarized-light) (solarized-reload 'solarized-dark)) + (t (message "You're not currently running a Solarized theme"))))) + ;;; Footer ;;;###autoload