[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9b31ead 08/17: Update semantics for local heads to `:bind
From: |
Oleh Krehel |
Subject: |
[elpa] master 9b31ead 08/17: Update semantics for local heads to `:bind nil' |
Date: |
Tue, 10 Feb 2015 07:13:25 +0000 |
branch: master
commit 9b31ead60dab68f913358858b86b784716bbbeb9
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Update semantics for local heads to `:bind nil'
* hydra.el (hydra--head-property): Accept an optional DEFAULT arg.
(defhydra): A head will not be bound in the body map when it has `:bind
nil' in its plist.
Example:
(defhydra hydra-next-error (c++-mode-map "C-x")
"next-error"
("`" next-error "next")
("j" next-error "next" :bind nil)
("k" previous-error "previous" :bind nil))
Here, only "C-x `" will be bound in `c++-mode-map', "C-x j" and "C-x k"
will not be bound. However, e.g. "C-x `jjk" will be possible.
---
hydra.el | 33 +++++++++++++++++++++------------
1 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/hydra.el b/hydra.el
index ccc6279..b8eef4a 100644
--- a/hydra.el
+++ b/hydra.el
@@ -163,12 +163,15 @@ It's possible to set this to nil.")
(and (consp x)
(memq (car x) '(function quote)))))
-(defun hydra--head-property (h prop)
- "Return the value of property PROP for Hydra head H."
+(defun hydra--head-property (h prop &optional default)
+ "Return the value of property PROP for Hydra head H.
+Return DEFAULT if PROP is not in H."
(let ((plist (if (stringp (cl-caddr h))
(cl-cdddr h)
(cddr h))))
- (plist-get plist prop)))
+ (if (memq prop h)
+ (plist-get plist prop)
+ default)))
(defun hydra--color (h body-color)
"Return the color of a Hydra head H with BODY-COLOR."
@@ -398,15 +401,21 @@ in turn can be either red or blue."
(cl-mapcar
(lambda (head name)
(unless (or (null body-key)
- (null method)
- (hydra--head-property head :local))
- (list
- (if (hydra--callablep method)
- 'funcall
- 'define-key)
- method
- (vconcat (kbd body-key) (kbd (car head)))
- (list 'function name))))
+ (null method))
+ (let ((bind (hydra--head-property head :bind 'default)))
+ (cond ((null bind) nil)
+
+ ((eq bind 'default)
+ (list
+ (if (hydra--callablep method)
+ 'funcall
+ 'define-key)
+ method
+ (vconcat (kbd body-key) (kbd (car head)))
+ (list 'function name)))
+
+ (t
+ (error "Invalid :bind property %S" head))))))
heads names))
,(hydra--make-defun body-name nil nil doc hint keymap
body-color body-pre body-post))))
- [elpa] master updated (61bddf2 -> 11b130e), Oleh Krehel, 2015/02/10
- [elpa] master b65db57 02/17: Update :post for amaranth Hydras, Oleh Krehel, 2015/02/10
- [elpa] master 9991985 01/17: hydra-test.el: update the test to not fail for older Emacs, Oleh Krehel, 2015/02/10
- [elpa] master 1660d71 05/17: Allow :pre and :post to be function symbols, Oleh Krehel, 2015/02/10
- [elpa] master 7ead8db 06/17: hydra.el (defhydra): Declare indent 2, Oleh Krehel, 2015/02/10
- [elpa] master 1b1d31d 07/17: Support local hydra heads, Oleh Krehel, 2015/02/10
- [elpa] master 9a8e2f1 04/17: hydra.el (hydra-keyboard-quit): New custom var, Oleh Krehel, 2015/02/10
- [elpa] master 9b31ead 08/17: Update semantics for local heads to `:bind nil',
Oleh Krehel <=
- [elpa] master 969fa66 10/17: fix typo - single not singe, Oleh Krehel, 2015/02/10
- [elpa] master d41be74 11/17: `hydra/body' will pass the initial `current-prefix-arg' along, Oleh Krehel, 2015/02/10
- [elpa] master ad771a4 03/17: Move defun-creating code into a defun, Oleh Krehel, 2015/02/10
- [elpa] master 763bb2a 13/17: Allow lambda :bind property for body and heads, Oleh Krehel, 2015/02/10
- [elpa] master 0712a43 12/17: README.md: update, Oleh Krehel, 2015/02/10
- [elpa] master d10c26e 14/17: Update comments and mark the old examples obsolete, Oleh Krehel, 2015/02/10
- [elpa] master 0c08964 16/17: README.md: update, Oleh Krehel, 2015/02/10
- [elpa] master 4ca646e 15/17: Allow a sexp as head's CMD paramater, Oleh Krehel, 2015/02/10
- [elpa] master bb01930 09/17: Fix "catch 'hydra-disable", Oleh Krehel, 2015/02/10
- [elpa] master 11b130e 17/17: Merge commit '0c08964462812942db51d177e6ea922b26019e65' from hydra, Oleh Krehel, 2015/02/10