[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c7281e9 17/72: Minor refactoring
From: |
Oleh Krehel |
Subject: |
[elpa] master c7281e9 17/72: Minor refactoring |
Date: |
Fri, 06 Mar 2015 13:04:05 +0000 |
branch: master
commit c7281e905cdad0dc787bb337e2b90c79f9d8c290
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Minor refactoring
* hydra.el (hydra--head-color): Rename from `hydra--color'.
(hydra--body-color): New defun.
(hydra--message): First arg isn't pre-processed by `hydra--hint'.
(defhydra): Update call to `hydra-message'.
---
hydra.el | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/hydra.el b/hydra.el
index bdd2570..6c54902 100644
--- a/hydra.el
+++ b/hydra.el
@@ -216,15 +216,20 @@ Return DEFAULT if PROP is not in H."
(plist-get plist prop)
default)))
-(defun hydra--color (h body-color)
+(defun hydra--head-color (h body-color)
"Return the color of a Hydra head H with BODY-COLOR."
(if (null (cadr h))
'blue
(or (hydra--head-property h :color) body-color)))
+(defun hydra--body-color (body)
+ "Return the color of BODY.
+BODY is the second argument to `defhydra'"
+ (or (plist-get (cddr body) :color) 'red))
+
(defun hydra--face (h body-color)
"Return the face for a Hydra head H with BODY-COLOR."
- (cl-case (hydra--color h body-color)
+ (cl-case (hydra--head-color h body-color)
(blue 'hydra-face-blue)
(red 'hydra-face-red)
(amaranth 'hydra-face-amaranth)
@@ -322,7 +327,7 @@ The expressions can be auto-expanded according to NAME."
"Generate code to display STR in the preferred echo area.
Set `hydra-lv' to choose the echo area.
NAME, HEADS and BODY-COLOR are parameters of `defhydra'."
- (let ((format-expr (hydra--format str name heads body-color)))
+ (let ((format-expr (hydra--format (hydra--hint str heads body-color) name
heads body-color)))
`(if hydra-lv
(lv-message ,format-expr)
(message ,format-expr))))
@@ -451,15 +456,11 @@ result of `defhydra'."
(hint-name (intern (format "%S/hint" name)))
(body-key (unless (hydra--callablep body)
(cadr body)))
- (body-color (if (hydra--callablep body)
- 'red
- (or (plist-get (cddr body) :color)
- 'red)))
+ (body-color (hydra--body-color body))
(body-pre (plist-get (cddr body) :pre))
(body-post (plist-get (cddr body) :post))
(method (or (plist-get body :bind)
(car body)))
- (hint (hydra--hint docstring heads body-color))
(doc (hydra--doc body-key body-name heads)))
(when (and (or body-pre body-post)
(version< emacs-version "24.4"))
@@ -470,11 +471,11 @@ result of `defhydra'."
(setq body-post `(funcall #',body-post)))
(when (memq body-color '(amaranth pink))
(if (cl-some `(lambda (h)
- (eq (hydra--color h ',body-color) 'blue))
+ (eq (hydra--head-color h ',body-color) 'blue))
heads)
(progn
(when (cl-some `(lambda (h)
- (eq (hydra--color h ',body-color) 'red))
+ (eq (hydra--head-color h ',body-color) 'red))
heads)
(warn
"%S body color: upgrading all red heads to %S"
@@ -511,7 +512,7 @@ result of `defhydra'."
(lambda (head name)
(hydra--make-defun
name (hydra--make-callable
- (cadr head)) (hydra--color head body-color)
+ (cadr head)) (hydra--head-color head body-color)
(format "%s\n\nCall the head: `%S'." doc (cadr head))
hint-name keymap
body-color body-pre body-post))
@@ -550,7 +551,7 @@ result of `defhydra'."
(error "Invalid :bind property %S" head))))))
heads names))
(defun ,hint-name ()
- ,(hydra--message hint name heads body-color))
+ ,(hydra--message docstring name heads body-color))
,(hydra--make-defun body-name nil nil doc hint-name keymap
body-color body-pre body-post
'(setq prefix-arg current-prefix-arg)))))
- [elpa] master d04ef9b 12/72: hydra.el (hydra-cleanup): reorder, (continued)
- [elpa] master d04ef9b 12/72: hydra.el (hydra-cleanup): reorder, Oleh Krehel, 2015/03/06
- [elpa] master 926d9a4 15/72: Add pink body color, Oleh Krehel, 2015/03/06
- [elpa] master d25e560 03/72: Fix head color for heads with nil as HINT, Oleh Krehel, 2015/03/06
- [elpa] master abb76e8 13/72: lv.el (lv-message): Don't deactivate mark, Oleh Krehel, 2015/03/06
- [elpa] master 81ffca0 20/72: Update faces, Oleh Krehel, 2015/03/06
- [elpa] master 9769143 25/72: hydra-examples.el: Add example 7, Oleh Krehel, 2015/03/06
- [elpa] master c049a33 16/72: Allow for Ruby-style Hydra docstrings, Oleh Krehel, 2015/03/06
- [elpa] master 688e8fd 23/72: hydra.el (hydra--head-color): fix for teal color, Oleh Krehel, 2015/03/06
- [elpa] master 0cda4ce 26/72: Fix typos, Oleh Krehel, 2015/03/06
- [elpa] master caf114a 11/72: Fix unintentional recursion in Emacs 25, Oleh Krehel, 2015/03/06
- [elpa] master c7281e9 17/72: Minor refactoring,
Oleh Krehel <=
- [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, 2015/03/06