branch: master commit d2aaf869ecba10664e1fa8abd69689f941e3b8f8 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Fix e.g. _f_(foo) in format string The "_f_" was getting replaced with "%s", which was subsequently interpreted as "%s(foo)". * hydra-test.el (hydra-format-9): New test. Fixes #197 --- hydra-test.el | 11 +++++++++++ hydra.el | 9 +++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hydra-test.el b/hydra-test.el index 88d12a8..4c61ea1 100644 --- a/hydra-test.el +++ b/hydra-test.el @@ -1114,6 +1114,17 @@ _f_ auto-fill-mode: %`auto-fill-function #("test: [b]: back." 7 8 (face hydra-face-red)))))) +(ert-deftest hydra-format-9 () + (should + (equal + (hydra--format nil '(nil nil :hint nil) "\n_f_(foo)" + '(("f" forward-char nil :exit nil))) + '(concat + (format + "%s(foo)" + #("f" 0 1 (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 3322abd..1ec80ea 100644 --- a/hydra.el +++ b/hydra.el @@ -651,12 +651,13 @@ The expressions can be auto-expanded according to NAME." head) body) varlist) - (setq docstring - (replace-match + (let ((replacement (or hydra-key-format-spec - (concat "%" (match-string 3 docstring) "s")) - t nil docstring))) + (concat "%" (match-string 3 docstring) "s")))) + (setq docstring + (replace-match replacement t nil docstring)) + (setq start (+ start (length replacement))))) (setq start (match-end 0)) (warn "Unrecognized key: _%s_" key))))