[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7010772 32/72: hydra.el (hydra--head-color): Improve
From: |
Oleh Krehel |
Subject: |
[elpa] master 7010772 32/72: hydra.el (hydra--head-color): Improve |
Date: |
Fri, 06 Mar 2015 13:04:11 +0000 |
branch: master
commit 7010772be1f7dc9e67673cac53c7f9b305f4e89f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra.el (hydra--head-color): Improve
* hydra.el (hydra--face): Second arg should be BODY.
(hydra--head-color): Second arg should be BODY.
---
hydra.el | 45 +++++++++++++++++++--------------------------
1 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/hydra.el b/hydra.el
index 67fe34c..6b73627 100644
--- a/hydra.el
+++ b/hydra.el
@@ -223,24 +223,24 @@ Return DEFAULT if PROP is not in H."
(plist-get plist prop)
default)))
-(defun hydra--head-color (h body-color)
- "Return the color of a Hydra head H with BODY-COLOR."
+(defun hydra--head-color (h body)
+ "Return the color of a Hydra head H with BODY."
(let ((color (hydra--head-property h :color))
- (exit (hydra--head-property h :exit 'default))
+ (exit (or (plist-get (cddr body) :exit)
+ (hydra--head-property h :exit 'default)))
(nonheads (plist-get (cddr body) :nonheads)))
(cond ((null (cadr h))
'blue)
((eq exit t)
'blue)
- ((null exit)
- (cond ((eq nonheads 'warn)
- 'amaranth)
- ((eq nonheads 'run)
- 'pink)
- (t
- 'red)))
+ ((eq nonheads 'run)
+ 'pink)
+ ((eq nonheads 'warn)
+ (if (eq exit t)
+ 'teal
+ 'amaranth))
((null color)
- body-color)
+ (hydra--body-color body))
(t
color))))
@@ -257,9 +257,9 @@ BODY is the second argument to `defhydra'"
(color color)
(t 'red))))
-(defun hydra--face (h body-color)
- "Return the face for a Hydra head H with BODY-COLOR."
- (cl-case (hydra--head-color h body-color)
+(defun hydra--face (h body)
+ "Return the face for a Hydra head H with BODY."
+ (cl-case (hydra--head-color h body)
(blue 'hydra-face-blue)
(red 'hydra-face-red)
(amaranth 'hydra-face-amaranth)
@@ -304,12 +304,11 @@ Otherwise, add PREFIX to the symbol name."
(defun hydra--hint (name body docstring heads)
"Generate a hint for the echo area.
NAME, BODY, DOCSTRING and HEADS are parameters to `defhydra'."
- (let ((body-color (hydra--body-color body))
- alist)
+ (let (alist)
(dolist (h heads)
(let ((val (assoc (cadr h) alist))
(pstr (propertize (car h) 'face
- (hydra--face h body-color))))
+ (hydra--face h body))))
(unless (and (> (length h) 2)
(null (cl-caddr h)))
(if val
@@ -354,7 +353,7 @@ The expressions can be auto-expanded according to NAME."
(head (assoc key heads)))
(if head
(setq str (replace-match
- (propertize key 'face (hydra--face head body-color))
+ (propertize key 'face (hydra--face head body))
nil nil str))
(error "Unrecognized key: _%s_" key))))
`(format ,str ,@(nreverse varlist))))
@@ -442,15 +441,9 @@ BODY-COLOR, BODY-PRE, BODY-POST, and OTHER-POST are used
as well."
(body-post (plist-get (cddr body) :post)))
(when (memq body-color '(amaranth pink teal))
(if (cl-some `(lambda (h)
- (eq (hydra--head-color h ',body-color) 'blue))
+ (eq (hydra--head-color h body) 'blue))
heads)
(progn
- ;; (when (cl-some `(lambda (h)
- ;; (eq (hydra--head-color h ',body-color) 'red))
- ;; heads)
- ;; (warn
- ;; "%S body color: upgrading all red heads to %S"
- ;; body-color body-color))
(define-key keymap [t]
`(lambda ()
(interactive)
@@ -568,7 +561,7 @@ result of `defhydra'."
(lambda (head name)
(hydra--make-defun
name (hydra--make-callable
- (cadr head)) (hydra--head-color head body-color)
+ (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))
- [elpa] master c7281e9 17/72: Minor refactoring, (continued)
- [elpa] master c7281e9 17/72: Minor refactoring, Oleh Krehel, 2015/03/06
- [elpa] master 06b35f7 08/72: Remove obsoletes, Oleh Krehel, 2015/03/06
- [elpa] master 806e04b 09/72: Don't clutter Echo Area, Oleh Krehel, 2015/03/06
- [elpa] master 4f0ef62 27/72: hydra.el (hydra-pink-fallback): Add, Oleh Krehel, 2015/03/06
- [elpa] master 4aa8826 18/72: hydra.el (hydra--message): Take same arguments as `defhydra', Oleh Krehel, 2015/03/06
- [elpa] master b81d078 29/72: Generate a global resetter in `defhydradio', Oleh Krehel, 2015/03/06
- [elpa] master 42cb833 21/72: hydra.el (hydra--hint): Take same arguments as `defhydra', Oleh Krehel, 2015/03/06
- [elpa] master 0a3cc60 30/72: Add compat color-less syntax, Oleh Krehel, 2015/03/06
- [elpa] master 92e1922 19/72: hydra.el (hydra--hint): Take same arguments as `defhydra', Oleh Krehel, 2015/03/06
- [elpa] master 6f7cef2 22/72: Add teal body color, Oleh Krehel, 2015/03/06
- [elpa] master 7010772 32/72: hydra.el (hydra--head-color): Improve,
Oleh Krehel <=
- [elpa] master d0e8d57 33/72: hydra.el (hydra-add-font-lock): Add `defhydradio', Oleh Krehel, 2015/03/06
- [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