[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f231dc0 55/72: Simplify the hint part of each head
From: |
Oleh Krehel |
Subject: |
[elpa] master f231dc0 55/72: Simplify the hint part of each head |
Date: |
Fri, 06 Mar 2015 13:04:20 +0000 |
branch: master
commit f231dc0237c7d3fe01422185476713ff1af5ab10
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Simplify the hint part of each head
* hydra.el (defhydra): All heads that don't have a hint, will get "" as
hint. The behavior will remain the same.
(hydra--head-property): Simplify, since plist is now always `cdddr'.
(hydra--hint): Simplify, heads always have length at least 3. Simplify,
third element is always a string or nil.
---
hydra.el | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/hydra.el b/hydra.el
index 658c710..fdc5379 100644
--- a/hydra.el
+++ b/hydra.el
@@ -239,10 +239,7 @@ should be a single statement. Wrap it in an interactive
lambda."
(defun hydra--head-property (h prop &optional default)
"Return for Hydra head H the value of property PROP.
Return DEFAULT if PROP is not in H."
- (let ((plist (if (or (stringp (cl-caddr h))
- (null (cl-caddr h)))
- (cl-cdddr h)
- (cddr h))))
+ (let ((plist (cl-cdddr h)))
(if (memq prop h)
(plist-get plist prop)
default)))
@@ -396,20 +393,18 @@ NAME, BODY, DOCSTRING and HEADS are parameters to
`defhydra'."
(dolist (h heads)
(let ((val (assoc (cadr h) alist))
(pstr (hydra-fontify-head h body)))
- (unless (and (> (length h) 2)
- (null (cl-caddr h)))
+ (unless (null (cl-caddr h))
(if val
(setf (cadr val)
(concat (cadr val) " " pstr))
(push
(cons (cadr h)
- (cons pstr
- (and (stringp (cl-caddr h)) (cl-caddr h))))
+ (cons pstr (cl-caddr h)))
alist)))))
(mapconcat
(lambda (x)
(format
- (if (cdr x)
+ (if (> (length (cdr x)) 0)
(concat "[%s]: " (cdr x))
"%s")
(car x)))
@@ -703,6 +698,15 @@ result of `defhydra'."
(setq docstring "hydra"))
(when (keywordp (car body))
(setq body (cons nil (cons nil body))))
+ (dolist (h heads)
+ (cond ((< (length h) 2)
+ (error "Each head should have at least two items: %S" h))
+ ((= (length h) 2)
+ (setcdr (cdr h) '("")))
+ ((or (null (cl-caddr h))
+ (stringp (cl-caddr h))))
+ (t
+ (setcdr (cdr h) (cons "" (cddr h))))))
(let* ((keymap (copy-keymap hydra-base-map))
(body-name (intern (format "%S/body" name)))
(body-key (unless (hydra--callablep body)
- [elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings, (continued)
- [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
- [elpa] master eb1e0fc 58/72: Don't bind nil heads in outside keymaps, Oleh Krehel, 2015/03/06
- [elpa] master 41ec124 50/72: Avoid generating multiple defuns with same name, Oleh Krehel, 2015/03/06
- [elpa] master db0415e 49/72: hydra.el (hydra-keyboard-quit): Add, Oleh Krehel, 2015/03/06
- [elpa] master 55682e7 57/72: Improve handling of heads with duplicate cmd, Oleh Krehel, 2015/03/06
- [elpa] master 7de26d0 64/72: Add `hydra-repeat': hydra-specific `repeat', Oleh Krehel, 2015/03/06
- [elpa] master f231dc0 55/72: Simplify the hint part of each head,
Oleh Krehel <=
- [elpa] master 764f4b6 67/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master 8e90037 65/72: Add some features for generating tables, Oleh Krehel, 2015/03/06
- [elpa] master 3040f45 61/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master e1e2e3e 69/72: lv.el (lv-window): Bind `golden-ratio-mode' to nil, Oleh Krehel, 2015/03/06
- [elpa] master 8dec3cd 70/72: Allow for a %s(test) spec in docstring, Oleh Krehel, 2015/03/06
- [elpa] master 9fc928b 63/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master 989ed95 53/72: Rename compat toggle - :nonheads -> :foreign-keys, Oleh Krehel, 2015/03/06
- [elpa] master 9c68e0a 68/72: Add :timeout option to hydra body, Oleh Krehel, 2015/03/06
- [elpa] master e342c33 71/72: hydra-ox.el: Emulate org-mode export dispatch, Oleh Krehel, 2015/03/06
- [elpa] master 6d6bbd4 62/72: hydra.el (hydra-key-format-spec): set default to "%s", Oleh Krehel, 2015/03/06