branch: externals/hydra commit 87cc74b2644daa2e9e660bc8a447c84a0ddeeab6 Author: Oleh Krehel <oleh.kre...@tomtom.com> Commit: Oleh Krehel <oleh.kre...@tomtom.com>
hydra.el (hydra--format): Make no docstring equivalent to :hint nil * hydra.el (defhydra): When no docstring is given, set it to "" instead of "hydra". * hydra-test.el (hydra-column-order): Update test. Fixes #291 --- hydra-test.el | 7 +++---- hydra.el | 28 ++++++++++++++++------------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/hydra-test.el b/hydra-test.el index ed9be35211..5799f781d1 100644 --- a/hydra-test.el +++ b/hydra-test.el @@ -1544,7 +1544,7 @@ o: ok | s: string (nth 3 (macroexpand '(defhydra hydra-window-order - (:color red :hint nil :timeout 4) + (:color red :timeout 4) ("z" ace-window "ace" :color blue :column "Switch") ("h" windmove-left "← window") ("j" windmove-down "↓ window") @@ -1559,9 +1559,8 @@ o: ok | s: string ("m" maximize-window "maximize current window") ("k" windmove-up "↑ window" :column "Switch") ("M" minimize-window "maximize current window" :column "1-Sizing") - ("q" nil "quit menu" :color blue :column nil))))))) - #("hydra: -Switch | Split Management | Undo/Redo | 1-Sizing + ("q" nil "quit menu" :color blue :column nil))))))) + #("Switch | Split Management | Undo/Redo | 1-Sizing ----------- | -------------------------- | ------------------- | -------------------------- z: ace | s: split window | u: undo window conf | b: balance window height h: ← window | v: split window vertically | r: redo window conf | m: maximize current window diff --git a/hydra.el b/hydra.el index e31f217963..febfcb1950 100644 --- a/hydra.el +++ b/hydra.el @@ -715,17 +715,21 @@ The expressions can be auto-expanded according to NAME." (substring docstring 0 start) "%" spec (substring docstring (+ start offset 1 lspec varp)))))))) - (if (eq ?\n (aref docstring 0)) - `(concat (format ,(substring docstring 1) ,@(nreverse varlist)) - ,rest) - (let ((r `(replace-regexp-in-string - " +$" "" - (concat ,docstring ": " - (replace-regexp-in-string - "\\(%\\)" "\\1\\1" ,rest))))) - (if (stringp rest) - `(format ,(eval r)) - `(format ,r))))))) + (cond + ((string= docstring "") + (substring rest 1)) + ((eq ?\n (aref docstring 0)) + `(concat (format ,(substring docstring 1) ,@(nreverse varlist)) + ,rest)) + (t + (let ((r `(replace-regexp-in-string + " +$" "" + (concat ,docstring ": " + (replace-regexp-in-string + "\\(%\\)" "\\1\\1" ,rest))))) + (if (stringp rest) + `(format ,(eval r)) + `(format ,r)))))))) (defun hydra--complain (format-string &rest args) "Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil." @@ -1179,7 +1183,7 @@ result of `defhydra'." (setq docstring (concat "\n" (eval docstring)))) (t (setq heads (cons docstring heads)) - (setq docstring "hydra"))) + (setq docstring ""))) (when (keywordp (car body)) (setq body (cons nil (cons nil body)))) (condition-case-unless-debug err