[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signat
From: |
Oleh Krehel |
Subject: |
[elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signature |
Date: |
Fri, 06 Mar 2015 13:04:19 +0000 |
branch: master
commit ace99b3e39e0703d153a4673d240d2862c5ceb18
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra.el (hydra--make-defun): Update signature
---
hydra.el | 107 ++++++++++++++++++++++++++++++++++---------------------------
1 files changed, 60 insertions(+), 47 deletions(-)
diff --git a/hydra.el b/hydra.el
index 8c84419..e9fdc5c 100644
--- a/hydra.el
+++ b/hydra.el
@@ -493,41 +493,58 @@ HEADS is a list of heads."
heads ",\n")
(format "The body can be accessed via `%S'." body-name)))
-(defun hydra--make-defun (name cmd color
- doc hint keymap
- body-color body-pre body-post &optional other-post)
- "Make a defun wrapper, using NAME, CMD, COLOR, DOC, HINT, and KEYMAP.
-BODY-COLOR, BODY-PRE, BODY-POST, and OTHER-POST are used as well."
- `(defun ,name ()
- ,doc
- (interactive)
- ,@(when body-pre (list body-pre))
- (hydra-disable)
- ,@(when (memq color '(blue teal)) '((hydra-cleanup)))
- (catch 'hydra-disable
- ,@(delq nil
- (if (memq color '(blue teal))
- `(,(when cmd `(call-interactively #',cmd))
- ,body-post)
- `(,(when cmd
- `(condition-case err
- (prog1 t
- (call-interactively #',cmd))
- ((quit error)
- (message "%S" err)
- (unless hydra-lv
- (sit-for 0.8))
- nil)))
- (when hydra-is-helpful
- (,hint))
- (setq hydra-last
- (hydra-set-transient-map
- (setq hydra-curr-map ',keymap)
- t
- ,(if (and (not (memq body-color '(amaranth pink
teal))) body-post)
- `(lambda () (hydra-cleanup) ,body-post)
- `(lambda () (hydra-cleanup)))))
- ,other-post))))))
+(defun hydra--make-defun (name body doc head
+ keymap body-pre body-post &optional other-post)
+ "Make a defun wrapper, using NAME, BODY, DOC, HEAD, and KEYMAP.
+NAME and BODY are the arguments to `defhydra'.
+DOC was generated with `hydra--doc'.
+HEAD is one of the HEADS passed to `defhydra'.
+BODY-PRE and BODY-POST are pre-processed in `defhydra'.
+OTHER-POST is an optional extension to the :post key of BODY."
+ (let ((name (hydra--head-name head name))
+ (cmd (when (car head)
+ (hydra--make-callable
+ (cadr head))))
+ (color (when (car head)
+ (hydra--head-color head body)))
+ (doc (if (car head)
+ (format "%s\n\nCall the head: `%S'." doc (cadr head))
+ doc))
+ (hint (intern (format "%S/hint" name)))
+ (body-color (hydra--body-color body)))
+ `(defun ,name ()
+ ,doc
+ (interactive)
+ ,@(when body-pre (list body-pre))
+ (hydra-disable)
+ ,@(when (memq color '(blue teal)) '((hydra-cleanup)))
+ (catch 'hydra-disable
+ ,@(delq nil
+ (if (memq color '(blue teal))
+ `(,(when cmd `(call-interactively #',cmd))
+ ,body-post)
+ `(,(when cmd
+ `(condition-case err
+ (prog1 t
+ (call-interactively #',cmd))
+ ((quit error)
+ (message "%S" err)
+ (unless hydra-lv
+ (sit-for 0.8))
+ nil)))
+ (when hydra-is-helpful
+ (,hint))
+ (setq hydra-last
+ (hydra-set-transient-map
+ (setq hydra-curr-map ',keymap)
+ t
+ ,(if (and
+ (not (memq body-color
+ '(amaranth pink teal)))
+ body-post)
+ `(lambda () (hydra-cleanup) ,body-post)
+ `(lambda () (hydra-cleanup)))))
+ ,other-post)))))))
(defun hydra-pink-fallback ()
"On intercepting a non-head, try to run it."
@@ -658,7 +675,6 @@ result of `defhydra'."
(setq body (cons nil (cons nil body))))
(let* ((keymap (copy-keymap hydra-base-map))
(body-name (intern (format "%S/body" name)))
- (hint-name (intern (format "%S/hint" name)))
(body-key (unless (hydra--callablep body)
(cadr body)))
(body-color (hydra--body-color body))
@@ -683,13 +699,8 @@ result of `defhydra'."
`(progn
,@(mapcar
(lambda (head)
- (hydra--make-defun
- (hydra--head-name head name)
- (hydra--make-callable
- (cadr head)) (hydra--head-color head body)
- (format "%s\n\nCall the head: `%S'." doc (cadr head))
- hint-name keymap
- body-color body-pre body-post))
+ (hydra--make-defun name body doc head keymap
+ body-pre body-post))
(hydra--delete-duplicates heads))
,@(unless (or (null body-key)
(null method)
@@ -725,11 +736,13 @@ result of `defhydra'."
(t
(error "Invalid :bind property %S" head)))))))
heads))
- (defun ,hint-name ()
+ (defun ,(intern (format "%S/hint" name)) ()
,(hydra--message name body docstring heads))
- ,(hydra--make-defun body-name nil nil doc hint-name keymap
- body-color (or body-body-pre body-pre) body-post
- '(setq prefix-arg current-prefix-arg)))))
+ ,(hydra--make-defun
+ name body doc '(nil body)
+ keymap
+ (or body-body-pre body-pre) body-post
+ '(setq prefix-arg current-prefix-arg)))))
(defmacro defhydradio (name body &rest heads)
"Create radios with prefix NAME.
- [elpa] master 88b32d5 24/72: hydra.el (hydra--hint): Add exception, (continued)
- [elpa] master 88b32d5 24/72: hydra.el (hydra--hint): Add exception, Oleh Krehel, 2015/03/06
- [elpa] master c41c932 31/72: README.md: fix tables, Oleh Krehel, 2015/03/06
- [elpa] master 1eebfed 34/72: Allow `format'-style width specifiers in docstring, Oleh Krehel, 2015/03/06
- [elpa] master e962ff1 39/72: hydra.el: remove no :pre, :post restriction for Emacs<24.4, Oleh Krehel, 2015/03/06
- [elpa] master a6c6a55 38/72: Improve compatibility for Emacs <= 24.3, Oleh Krehel, 2015/03/06
- [elpa] master 2c01db0 42/72: hydra.el (hydra--handle-nonhead): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master a71b76e 35/72: Intercept quit signals, Oleh Krehel, 2015/03/06
- [elpa] master ae70e9a 41/72: Fix pink and teal Hydras running :post, Oleh Krehel, 2015/03/06
- [elpa] master 71d70f6 46/72: Add :body-pre switch, Oleh Krehel, 2015/03/06
- [elpa] master cb28124 44/72: Allow sexps in Ruby-style docstrings, Oleh Krehel, 2015/03/06
- [elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signature,
Oleh Krehel <=
- [elpa] master efcffc0 45/72: hydra-examples.el: Add example 9, Oleh Krehel, 2015/03/06
- [elpa] master ef1f61d 40/72: hydra.el (hydra--handle-nonhead): Fix bug, Oleh Krehel, 2015/03/06
- [elpa] master 2eddb83 43/72: hydra-test.el (hydra-format): New test, Oleh Krehel, 2015/03/06
- [elpa] master 5242aad 48/72: Fix :exit t / :exit nil inheritance issue, Oleh Krehel, 2015/03/06
- [elpa] master 0f733d8 37/72: Add an option to fontify heads in a custom way, Oleh Krehel, 2015/03/06
- [elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings, Oleh Krehel, 2015/03/06
- [elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom, Oleh Krehel, 2015/03/06
- [elpa] master 0d9c95e 47/72: Update README.md, Oleh Krehel, 2015/03/06
- [elpa] master 3c06695 56/72: Amend the key regex in docstring to include <>, Oleh Krehel, 2015/03/06
- [elpa] master e567bd6 59/72: lv.el (lv-window): set-window-parameter 'no-other-window, Oleh Krehel, 2015/03/06