emacs-elpa-diffs
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]