Skip to content

Commit

Permalink
hydra.el (hydra-verbose): New defcustom
Browse files Browse the repository at this point in the history
* hydra.el (hydra--head-color): Switch from `error' to `hydra--complain'
  in one case.
(hydra--complain): New defun.

Fixes #47.
  • Loading branch information
abo-abo committed Feb 23, 2015
1 parent ace99b3 commit 54004d2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hydra.el
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ It's possible to set this to nil.")
"When non-nil, `lv-message' (not `message') will be used to display hints."
:type 'boolean)

(defcustom hydra-verbose nil
"When non-nil, hydra will issue some non-essential style warnings."
:type 'boolean)

(defface hydra-face-red
'((t (:foreground "#FF0000" :bold t)))
"Red Hydra heads will persist indefinitely."
Expand Down Expand Up @@ -284,9 +288,10 @@ Return DEFAULT if PROP is not in H."
(let ((nonheads (plist-get (cddr body) :nonheads))
(body-exit (plist-get (cddr body) :exit)))
(cond ((null (cadr h))
(if head-color
(error "Extra properties for head with nil body: %S" h)
'blue))
(when head-color
(hydra--complain
"Doubly specified blue head - nil cmd is already blue: %S" h))
'blue)
((null head-color)
(hydra--body-color body))
((null nonheads)
Expand Down Expand Up @@ -477,6 +482,11 @@ NAME, BODY, DOCSTRING, and HEADS are parameters of `defhydra'."
(lv-message ,format-expr)
(message ,format-expr))))

(defun hydra--complain (format-string &rest args)
"Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil."
(when hydra-verbose
(apply #'warn format-string args)))

(defun hydra--doc (body-key body-name heads)
"Generate a part of Hydra docstring.
BODY-KEY is the body key binding.
Expand Down

0 comments on commit 54004d2

Please sign in to comment.