emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master dc4a858 060/348: counsel.el (counsel-hydra-heads): New com


From: Oleh Krehel
Subject: [elpa] master dc4a858 060/348: counsel.el (counsel-hydra-heads): New command
Date: Sat, 8 Apr 2017 11:03:24 -0400 (EDT)

branch: master
commit dc4a8582d8d81c49a5e6749a8ff7804ec726dfb7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-hydra-heads): New command
    
    Re #548
---
 counsel.el | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/counsel.el b/counsel.el
index c4a3174..171cd54 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2065,6 +2065,27 @@ And insert it into the minibuffer. Useful during
   (require 'comint)
   (counsel--browse-history comint-input-ring))
 
+;;** `counsel-hydra-heads'
+(defun counsel-hydra-heads ()
+  "Call a head of the current/last hydra."
+  (interactive)
+  (let* ((base (substring
+                (prin1-to-string hydra-curr-body-fn)
+                0 -4))
+         (heads (eval (intern (concat base "heads"))))
+         (keymap (eval (intern (concat base "keymap"))))
+         (head-names
+          (mapcar (lambda (x)
+                    (cons
+                     (if (nth 2 x)
+                         (format "[%s] %S (%s)" (nth 0 x) (nth 1 x) (nth 2 x))
+                       (format "[%s] %S" (nth 0 x) (nth 1 x)))
+                     (lookup-key keymap (kbd (nth 0 x)))))
+                  heads)))
+    (ivy-read "head: " head-names
+              :action #'call-interactively)
+    (hydra-keyboard-quit)))
+
 ;;* Misc OS
 ;;** `counsel-rhythmbox'
 (defvar helm-rhythmbox-library)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]