[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom
From: |
Oleh Krehel |
Subject: |
[elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom |
Date: |
Fri, 06 Mar 2015 13:04:19 +0000 |
branch: master
commit 54004d21a276ba3d1b88f5f6182f7badb778f91e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
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.
---
hydra.el | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/hydra.el b/hydra.el
index e9fdc5c..afe59b7 100644
--- a/hydra.el
+++ b/hydra.el
@@ -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."
@@ -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)
@@ -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.
- [elpa] master ae70e9a 41/72: Fix pink and teal Hydras running :post, (continued)
- [elpa] master ae70e9a 41/72: Fix pink and teal Hydras running :post, Oleh Krehel, 2015/03/06
- [elpa] master 71d70f6 46/72: Add :body-pre switch, Oleh Krehel, 2015/03/06
- [elpa] master cb28124 44/72: Allow sexps in Ruby-style docstrings, Oleh Krehel, 2015/03/06
- [elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master efcffc0 45/72: hydra-examples.el: Add example 9, Oleh Krehel, 2015/03/06
- [elpa] master ef1f61d 40/72: hydra.el (hydra--handle-nonhead): Fix bug, Oleh Krehel, 2015/03/06
- [elpa] master 2eddb83 43/72: hydra-test.el (hydra-format): New test, Oleh Krehel, 2015/03/06
- [elpa] master 5242aad 48/72: Fix :exit t / :exit nil inheritance issue, Oleh Krehel, 2015/03/06
- [elpa] master 0f733d8 37/72: Add an option to fontify heads in a custom way, Oleh Krehel, 2015/03/06
- [elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings, Oleh Krehel, 2015/03/06
- [elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom,
Oleh Krehel <=
- [elpa] master 0d9c95e 47/72: Update README.md, Oleh Krehel, 2015/03/06
- [elpa] master 3c06695 56/72: Amend the key regex in docstring to include <>, Oleh Krehel, 2015/03/06
- [elpa] master e567bd6 59/72: lv.el (lv-window): set-window-parameter 'no-other-window, Oleh Krehel, 2015/03/06
- [elpa] master eb1e0fc 58/72: Don't bind nil heads in outside keymaps, Oleh Krehel, 2015/03/06
- [elpa] master 41ec124 50/72: Avoid generating multiple defuns with same name, Oleh Krehel, 2015/03/06
- [elpa] master db0415e 49/72: hydra.el (hydra-keyboard-quit): Add, Oleh Krehel, 2015/03/06
- [elpa] master 55682e7 57/72: Improve handling of heads with duplicate cmd, Oleh Krehel, 2015/03/06
- [elpa] master 7de26d0 64/72: Add `hydra-repeat': hydra-specific `repeat', Oleh Krehel, 2015/03/06
- [elpa] master f231dc0 55/72: Simplify the hint part of each head, Oleh Krehel, 2015/03/06
- [elpa] master 764f4b6 67/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06