branch: elpa/solarized-theme commit 01a350d6a2ed5d95baefa8d2fe91360b1dcfef35 Author: Bozhidar Batsov <bozhi...@batsov.dev> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
Add commands to reload and toggle the themes --- README.md | 4 ++++ solarized.el | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index d3f701b22d..cf6e5ffdef 100644 --- 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 index 73e2a2c9cb..f0ed078f02 100644 --- 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