[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c8b4749 09/22: Allow binding heads to "%"
From: |
Oleh Krehel |
Subject: |
[elpa] master c8b4749 09/22: Allow binding heads to "%" |
Date: |
Fri, 16 Oct 2015 10:06:56 +0000 |
branch: master
commit c8b4749e851e78d9b09d084d6fed4b2fd1a51301
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow binding heads to "%"
* hydra.el (hydra--format): Update regex. Make sure that there's a
proper amount of escapes for %, since:
- it first gets evaled via `hydra-test/hint'
- it gets passed to `lv-message'
So to get 1 in the end, the initial amount can be 4.
* hydra-test.el (hydra-format-7): Add tests.
---
hydra-test.el | 24 ++++++++++++++++++++++++
hydra.el | 5 +++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index a770435..d20e353 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -1113,6 +1113,30 @@ _f_ auto-fill-mode: %`auto-fill-function
hydra-face-red)))
""))))
+(ert-deftest hydra-format-7 ()
+ (should
+ (equal
+ (hydra--format nil nil "test"
+ '(("%" forward-char "" :exit nil)
+ ("b" backward-char "" :exit nil)))
+ '(format
+ #("test: %%%%, b."
+ 6 7 (face hydra-face-red)
+ 7 8 (face hydra-face-red)
+ 8 9 (face hydra-face-red)
+ 9 10 (face hydra-face-red)
+ 12 13 (face hydra-face-red)))))
+ (should
+ (equal
+ (hydra--format nil nil "\n_%_ forward\n"
+ '(("%" forward-char nil :exit nil)))
+ '(concat
+ (format
+ "%s forward\n"
+ #("%%"
+ 0 2 (face hydra-face-red)))
+ ""))))
+
(ert-deftest hydra-format-with-sexp-1 ()
(should (equal
(let ((hydra-fontify-head-function
diff --git a/hydra.el b/hydra.el
index 5a823ff..80b1a23 100644
--- a/hydra.el
+++ b/hydra.el
@@ -513,7 +513,7 @@ The expressions can be auto-expanded according to NAME."
offset)
(while (setq start
(string-match
- "\\(?:%\\(
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\(
?-?[0-9]*?\\)\\(\\[\\|]\\|[-[:alnum:] ~.,;:/|?<>={}*+#]+?\\)_\\)"
+ "\\(?:%\\(
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\(
?-?[0-9]*?\\)\\(\\[\\|]\\|[-[:alnum:] ~.,;:/|?<>={}*+#%]+?\\)_\\)"
docstring start))
(cond ((eq ?_ (aref (match-string 0 docstring) 0))
(let* ((key (match-string 4 docstring))
@@ -551,7 +551,8 @@ The expressions can be auto-expanded according to NAME."
(if (eq ?\n (aref docstring 0))
`(concat (format ,(substring docstring 1) ,@(nreverse varlist))
,rest)
- `(format ,(concat docstring ": " rest ".")))))
+ `(format ,(concat docstring ": " (replace-regexp-in-string
+ "\\(%\\)" "\\1\\1" rest) ".")))))
(defun hydra--complain (format-string &rest args)
"Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil."
- [elpa] master updated (2eb4c54 -> bfeccce), Oleh Krehel, 2015/10/16
- [elpa] master fd8e1b9 02/22: hydra.el (hydra-fontify-head-default): Add "%" exception, Oleh Krehel, 2015/10/16
- [elpa] master a2f8a23 01/22: Allow to escape ^ in docstrings, Oleh Krehel, 2015/10/16
- [elpa] master 2d45839 03/22: lv-window: split-window ignores window parameters, Oleh Krehel, 2015/10/16
- [elpa] master fca56c3 07/22: targets/hydra-init.el: Move, Oleh Krehel, 2015/10/16
- [elpa] master 1a13273 06/22: Allow to pause arbitrary hydras to the stack, Oleh Krehel, 2015/10/16
- [elpa] master adc2997 08/22: Allow for "_[_" and "_]_" in docs, Oleh Krehel, 2015/10/16
- [elpa] master 1acd5f6 05/22: hydra.el (hydra-face-blue): Customize for dark themes, Oleh Krehel, 2015/10/16
- [elpa] master c8b4749 09/22: Allow binding heads to "%",
Oleh Krehel <=
- [elpa] master 7aa8187 13/22: Allow to specify :face for each head, Oleh Krehel, 2015/10/16
- [elpa] master df7b079 10/22: hydra.el (hydra-head-format): Customize the key formatting, Oleh Krehel, 2015/10/16
- [elpa] master 900ca34 04/22: Allow access to the current hydra body, Oleh Krehel, 2015/10/16
- [elpa] master 1e9276a 12/22: Remove trailing whitespace from :columns docstring, Oleh Krehel, 2015/10/16
- [elpa] master 852ae26 14/22: Use quote instead of function to prevent compiler warnings, Oleh Krehel, 2015/10/16
- [elpa] master ea36afc 19/22: Allow "_", "!", and "&" as keys in docstrings, Oleh Krehel, 2015/10/16
- [elpa] master f58d356 17/22: Allow #'command syntax for heads, just to have it, Oleh Krehel, 2015/10/16
- [elpa] master 27b7f40 15/22: Make find-function work with defhydra, Oleh Krehel, 2015/10/16
- [elpa] master 3fb3168 18/22: hydra.el (hydra--format): Allow "@" key in the docs, Oleh Krehel, 2015/10/16
- [elpa] master 336602f 11/22: Add :columns option for hydra body, Oleh Krehel, 2015/10/16