]> code.delx.au - gnu-emacs-elpa/commitdiff
hydra.el (hydra-fontify-head-default): Add "%" exception
authorOleh Krehel <ohwoeowho@gmail.com>
Wed, 13 May 2015 05:25:41 +0000 (07:25 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 13 May 2015 05:25:41 +0000 (07:25 +0200)
* hydra.el (hydra--hint): Simplify.

Fixes #126

hydra.el

index 7e67b2cfdeb700785d28d2ff641dfbcdd2561ea8..67a345e14d668d37b81e46527e05786f98dc77df 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -425,17 +425,16 @@ BODY, and HEADS are parameters to `defhydra'."
              (cons (cadr h)
                    (cons pstr (cl-caddr h)))
              alist)))))
-    (mapconcat
-     (lambda (x)
-       (format
-        (if (> (length (cdr x)) 0)
-            (concat "[%s]: " (cdr x))
-          "%s")
-        (if (equal (car x) "%")
-            "%%"
-          (car x))))
-     (nreverse (mapcar #'cdr alist))
-     ", ")))
+    (let ((keys (nreverse (mapcar #'cdr alist))))
+      (mapconcat
+       (lambda (x)
+         (format
+          (if (> (length (cdr x)) 0)
+              (concat "[%s]: " (cdr x))
+            "%s")
+          (car x)))
+       keys
+       ", "))))
 
 (defvar hydra-fontify-head-function nil
   "Possible replacement for `hydra-fontify-head-default'.")
@@ -457,7 +456,9 @@ HEAD's binding is returned as a string with a colored face."
     (when (and (null (cadr head))
                (not head-exit))
       (hydra--complain "nil cmd can only be blue"))
-    (propertize (car head) 'face
+    (propertize (if (string= (car head) "%")
+                    "%%"
+                  (car head)) 'face
                 (cl-case head-color
                   (blue 'hydra-face-blue)
                   (red 'hydra-face-red)