branch: master
commit d9218751ca0adc9688f19de03c3b429046c19232
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-load-theme): New command
---
counsel.el | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/counsel.el b/counsel.el
index 0ae079f..27ec9e7 100644
--- a/counsel.el
+++ b/counsel.el
@@ -542,6 +542,30 @@ Optional INITIAL-INPUT is the initial input in the
minibuffer."
:keymap counsel-describe-map
:initial-input initial-input)))
+(declare-function powerline-reset "ext:powerline")
+
+(defun counsel--load-theme-action (x)
+ "Disable current themes and load theme X."
+ (condition-case nil
+ (progn
+ (mapc #'disable-theme custom-enabled-themes)
+ (load-theme (intern x))
+ (when (fboundp 'powerline-reset)
+ (powerline-reset)))
+ (error "Problem loading theme %s" x)))
+
+;;;###autoload
+(defun counsel-load-theme ()
+ "Forward to `load-theme'.
+Usable with `ivy-resume', `ivy-next-line-and-call' and
+`ivy-previous-line-and-call'."
+ (interactive)
+ (ivy-read "Load custom theme: "
+ (mapcar 'symbol-name
+ (custom-available-themes))
+ :action #'counsel--load-theme-action))
+
+
(provide 'counsel)
;;; counsel.el ends here