[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f3c4dd7 02/72: hydra.el (hydra--hint): allow duplicate fun
From: |
Oleh Krehel |
Subject: |
[elpa] master f3c4dd7 02/72: hydra.el (hydra--hint): allow duplicate functions in heads |
Date: |
Fri, 06 Mar 2015 13:03:59 +0000 |
branch: master
commit f3c4dd7a026e49110a280dba9e0173d86ecdf9d4
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra.el (hydra--hint): allow duplicate functions in heads
* hydra.el (hydra--hint): Duplicate functions will be concatenated.
Example:
(defhydra hydra-zoom (global-map "<f2>")
"zoom"
("g" text-scale-increase "in")
("l" text-scale-decrease "out")
("0" (text-scale-set 0) "reset")
("1" (text-scale-set 0) :bind nil)
("2" (text-scale-set 0) :bind nil :color blue))
Here, the hint will be: "zoom: [g]: in, [l]: out, [0 1 2]: reset."
And "2" will be colored blue.
Fixes #26
---
hydra.el | 44 +++++++++++++++++++++++++++-----------------
1 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/hydra.el b/hydra.el
index a1bc9e9..95a34af 100644
--- a/hydra.el
+++ b/hydra.el
@@ -214,23 +214,33 @@ Return DEFAULT if PROP is not in 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."
- (format "%s: %s."
- docstring
- (mapconcat
- (lambda (h)
- (format
- (if (stringp (cl-caddr h))
- (concat "[%s]: " (cl-caddr h))
- "%s")
- (propertize
- (car h) 'face
- (hydra--face h body-color))))
- (cl-remove-if
- (lambda (x)
- (and (> (length x) 2)
- (null (cl-caddr x))))
- heads)
- ", ")))
+ (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-disable ()
"Disable the current Hydra."
- [elpa] master updated (ffa5405 -> 3222b0c), Oleh Krehel, 2015/03/06
- [elpa] master bb38641 05/72: hydra.el (hydra--make-defun): simplify, Oleh Krehel, 2015/03/06
- [elpa] master 614e1f7 07/72: `defhydra' should be indented as `defun', Oleh Krehel, 2015/03/06
- [elpa] master 8bca51b 04/72: Warn about explict red heads on amaranth body, Oleh Krehel, 2015/03/06
- [elpa] master 216550e 06/72: Add option to font-lock `defhydra', Oleh Krehel, 2015/03/06
- [elpa] master f3c4dd7 02/72: hydra.el (hydra--hint): allow duplicate functions in heads,
Oleh Krehel <=
- [elpa] master 62f9b05 01/72: Allow some heads with no hints, Oleh Krehel, 2015/03/06
- [elpa] master f04f14c 14/72: hydra.el (defhydra): Update doc, Oleh Krehel, 2015/03/06
- [elpa] master 2086614 10/72: hydra.el (defhydradio): New macro, Oleh Krehel, 2015/03/06
- [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