[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 92e1922 19/72: hydra.el (hydra--hint): Take same arguments
From: |
Oleh Krehel |
Subject: |
[elpa] master 92e1922 19/72: hydra.el (hydra--hint): Take same arguments as `defhydra' |
Date: |
Fri, 06 Mar 2015 13:04:06 +0000 |
branch: master
commit 92e1922d938ae6d349986895dadff9bffde3e0d6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra.el (hydra--hint): Take same arguments as `defhydra'
---
hydra.el | 72 +++++++++++++++++++++++++++++++-------------------------------
1 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/hydra.el b/hydra.el
index 3f547c5..e1eea08 100644
--- a/hydra.el
+++ b/hydra.el
@@ -101,8 +101,7 @@ It's the only other way to quit it besides though a blue
head.
It's possible to set this to nil.")
(defcustom hydra-lv t
- "When non-nil, `lv-message' will be used to display hints
-instead of `message'."
+ "When non-nil, `lv-message' (not `message') will be used to display hints."
:type 'boolean)
(defface hydra-face-red
@@ -236,37 +235,6 @@ BODY is the second argument to `defhydra'"
(pink 'hydra-face-pink)
(t (error "Unknown color for %S" h))))
-(defun hydra--hint (docstring heads body-color)
- "Generate a hint from DOCSTRING and HEADS and BODY-COLOR.
-It's intended for the echo area, when a Hydra is active."
- (let (alist)
- (dolist (h heads)
- (let ((val (assoc (cadr h) alist))
- (pstr (propertize (car h) 'face
- (hydra--face h body-color))))
- (unless (and (> (length h) 2)
- (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))))
- alist)))))
-
- (format "%s: %s."
- docstring
- (mapconcat
- (lambda (x)
- (format
- (if (cdr x)
- (concat "[%s]: " (cdr x))
- "%s")
- (car x)))
- (nreverse (mapcar #'cdr alist))
- ", "))))
-
(defun hydra-cleanup ()
"Clean up after a Hydra."
(when (window-live-p lv-wnd)
@@ -301,6 +269,38 @@ Otherwise, add PREFIX to the symbol name."
sym
(intern (concat prefix "/" str)))))
+(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)
+ (dolist (h heads)
+ (let ((val (assoc (cadr h) alist))
+ (pstr (propertize (car h) 'face
+ (hydra--face h body-color))))
+ (unless (and (> (length h) 2)
+ (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))))
+ alist)))))
+
+ (format "%s: %s."
+ docstring
+ (mapconcat
+ (lambda (x)
+ (format
+ (if (cdr x)
+ (concat "[%s]: " (cdr x))
+ "%s")
+ (car x)))
+ (nreverse (mapcar #'cdr alist))
+ ", "))))
+
(defun hydra--format (str name heads body-color)
"Generate a `format' statement from STR.
\"%`...\" expressions are extracted into \"%S\".
@@ -324,12 +324,12 @@ The expressions can be auto-expanded according to NAME."
`(format ,str ,@(nreverse varlist))))
(defun hydra--message (name body docstring heads)
- "Generate code to display STR in the preferred echo area.
+ "Generate code to display the hint in the preferred echo area.
Set `hydra-lv' to choose the echo area.
-NAME, HEADS and BODY-COLOR are parameters of `defhydra'."
+NAME, BODY, DOCSTRING, and HEADS are parameters of `defhydra'."
(let* ((body-color (hydra--body-color body))
(format-expr (hydra--format
- (hydra--hint docstring heads body-color) name heads
body-color)))
+ (hydra--hint name body docstring heads) name heads
body-color)))
`(if hydra-lv
(lv-message ,format-expr)
(message ,format-expr))))
- [elpa] master 0cda4ce 26/72: Fix typos, (continued)
- [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, 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 <=
- [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
- [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