]> code.delx.au - gnu-emacs-elpa/commitdiff
Allow #'command syntax for heads, just to have it
authorOleh Krehel <ohwoeowho@gmail.com>
Thu, 6 Aug 2015 06:17:23 +0000 (08:17 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Thu, 6 Aug 2015 06:17:23 +0000 (08:17 +0200)
* hydra.el (hydra--make-callable):
(hydra--head-name): Allow #'command syntax in the CMD place for each
head.

This isn't the recommended syntax, however you can use it if you prefer.

Fixes #156

hydra.el

index a9b4587c0a239ba3e0afe772114840297d96393a..c5c31964eb1fe1f48fe6f3d8c6b77ad2958ebb50 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -363,11 +363,14 @@ When ARG is non-nil, use that instead."
   "Generate a callable symbol from X.
 If X is a function symbol or a lambda, return it.  Otherwise, it
 should be a single statement.  Wrap it in an interactive lambda."
-  (if (or (symbolp x) (functionp x))
-      x
-    `(lambda ()
-       (interactive)
-       ,x)))
+  (cond ((or (symbolp x) (functionp x))
+         x)
+        ((and (consp x) (eq (car x) 'function))
+         (cadr x))
+        (t
+         `(lambda ()
+            (interactive)
+            ,x))))
 
 (defun hydra-plist-get-default (plist prop default)
   "Extract a value from a property list.
@@ -716,9 +719,13 @@ BODY-AFTER-EXIT is added to the end of the wrapper."
 (defun hydra--head-name (h name)
   "Return the symbol for head H of hydra with NAME."
   (let ((str (format "%S/%s" name
-                     (if (symbolp (cadr h))
-                         (cadr h)
-                       (concat "lambda-" (car h))))))
+                     (cond ((symbolp (cadr h))
+                            (cadr h))
+                           ((and (consp (cadr h))
+                                 (eq (cl-caadr h) 'function))
+                            (cadr (cadr h)))
+                           (t
+                            (concat "lambda-" (car h)))))))
     (when (and (hydra--head-property h :exit)
                (not (memq (cadr h) '(body nil))))
       (setq str (concat str "-and-exit")))