Skip to content

Commit 54004d2

Browse files
committed
hydra.el (hydra-verbose): New defcustom
* hydra.el (hydra--head-color): Switch from `error' to `hydra--complain' in one case. (hydra--complain): New defun. Fixes #47.
1 parent ace99b3 commit 54004d2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

hydra.el

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ It's possible to set this to nil.")
117117
"When non-nil, `lv-message' (not `message') will be used to display hints."
118118
:type 'boolean)
119119

120+
(defcustom hydra-verbose nil
121+
"When non-nil, hydra will issue some non-essential style warnings."
122+
:type 'boolean)
123+
120124
(defface hydra-face-red
121125
'((t (:foreground "#FF0000" :bold t)))
122126
"Red Hydra heads will persist indefinitely."
@@ -284,9 +288,10 @@ Return DEFAULT if PROP is not in H."
284288
(let ((nonheads (plist-get (cddr body) :nonheads))
285289
(body-exit (plist-get (cddr body) :exit)))
286290
(cond ((null (cadr h))
287-
(if head-color
288-
(error "Extra properties for head with nil body: %S" h)
289-
'blue))
291+
(when head-color
292+
(hydra--complain
293+
"Doubly specified blue head - nil cmd is already blue: %S" h))
294+
'blue)
290295
((null head-color)
291296
(hydra--body-color body))
292297
((null nonheads)
@@ -477,6 +482,11 @@ NAME, BODY, DOCSTRING, and HEADS are parameters of `defhydra'."
477482
(lv-message ,format-expr)
478483
(message ,format-expr))))
479484

485+
(defun hydra--complain (format-string &rest args)
486+
"Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil."
487+
(when hydra-verbose
488+
(apply #'warn format-string args)))
489+
480490
(defun hydra--doc (body-key body-name heads)
481491
"Generate a part of Hydra docstring.
482492
BODY-KEY is the body key binding.

0 commit comments

Comments
 (0)