]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-load-theme): New command
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 23 Jun 2015 14:39:07 +0000 (16:39 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 23 Jun 2015 14:43:28 +0000 (16:43 +0200)
counsel.el

index 0ae079f4ac975b044a084b42f015c6f6425b87ba..27ec9e7874efcd4adcd0326d4e1140a0ef0234c6 100644 (file)
@@ -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