[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 71d70f6 46/72: Add :body-pre switch
From: |
Oleh Krehel |
Subject: |
[elpa] master 71d70f6 46/72: Add :body-pre switch |
Date: |
Fri, 06 Mar 2015 13:04:17 +0000 |
branch: master
commit 71d70f6aacc4d11b4bd84e95c000d41b42ce34bb
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add :body-pre switch
It will be run as the first thing in the prefix/body function.
re #41
Example:
(defvar hydra-vi/init-pos nil)
(defhydra hydra-vi (:body-pre (setq hydra-vi/init-pos (point))
:color pink)
"vi"
;; arrows
("h" backward-char)
("j" next-line)
("k" previous-line)
("l" forward-char)
;; exit points
("q" (goto-char hydra-vi/init-pos) "ins" :exit t)
("C-n" (forward-line 1) nil :exit t)
("C-p" (forward-line -1) nil :exit t))
---
hydra.el | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/hydra.el b/hydra.el
index a7114ed..7658c76 100644
--- a/hydra.el
+++ b/hydra.el
@@ -610,12 +610,15 @@ result of `defhydra'."
(cadr body)))
(body-color (hydra--body-color body))
(body-pre (plist-get (cddr body) :pre))
+ (body-body-pre (plist-get (cddr body) :body-pre))
(body-post (plist-get (cddr body) :post))
(method (or (plist-get body :bind)
(car body)))
(doc (hydra--doc body-key body-name heads)))
(when (and body-pre (symbolp body-pre))
(setq body-pre `(funcall #',body-pre)))
+ (when (and body-body-pre (symbolp body-body-pre))
+ (setq body-body-pre `(funcall #',body-body-pre)))
(when (and body-post (symbolp body-post))
(setq body-post `(funcall #',body-post)))
(hydra--handle-nonhead keymap name body heads)
@@ -665,7 +668,7 @@ result of `defhydra'."
(defun ,hint-name ()
,(hydra--message name body docstring heads))
,(hydra--make-defun body-name nil nil doc hint-name keymap
- body-color body-pre body-post
+ body-color (or body-body-pre body-pre) body-post
'(setq prefix-arg current-prefix-arg)))))
(defmacro defhydradio (name body &rest heads)
- [elpa] master 0881733 28/72: hydra.el (defhydra): Fix typo, (continued)
- [elpa] master 0881733 28/72: hydra.el (defhydra): Fix typo, Oleh Krehel, 2015/03/06
- [elpa] master a4c4eb6 36/72: Add example for `Buffer-menu-mode', Oleh Krehel, 2015/03/06
- [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 <=
- [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, 2015/03/06
- [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