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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master f01f4a4 04/36: hydra.el (hydra-key-regex): Extract from hy


From: Oleh Krehel
Subject: [elpa] master f01f4a4 04/36: hydra.el (hydra-key-regex): Extract from hydra--format
Date: Sat, 22 Jul 2017 11:22:20 -0400 (EDT)

branch: master
commit f01f4a46f227961cd2a1571a45a174cfcfbfa81c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    hydra.el (hydra-key-regex): Extract from hydra--format
    
    * hydra.el (hydra-width-spec-regex): Extract from hydra--format.
    
    Now the user can configure the key regex more precisely.
    
    Fixes #187
---
 hydra.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hydra.el b/hydra.el
index a048df8..a1f7a8d 100644
--- a/hydra.el
+++ b/hydra.el
@@ -584,6 +584,12 @@ HEAD's binding is returned as a string wrapped with [] or 
{}."
 (defvar hydra-docstring-keys-translate-alist
   '(("↑" . "<up>")))
 
+(defconst hydra-width-spec-regex " ?-?[0-9]*s?"
+  "Regex for the width spec in keys and %` quoted sexps.")
+
+(defvar hydra-key-regex "\\[\\|]\\|[-[:alnum:] 
~.,;:/|?<>address@hidden&^↑'`()\"]+?"
+  "Regex for the key quoted in the docstring.")
+
 (defun hydra--format (_name body docstring heads)
   "Generate a `format' statement from STR.
 \"%`...\" expressions are extracted into \"%S\".
@@ -597,7 +603,11 @@ The expressions can be auto-expanded according to NAME."
         offset)
     (while (setq start
                  (string-match
-                  "\\(?:%\\( 
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:[_?]\\( 
?-?[0-9]*?\\)\\(\\[\\|]\\|[-[:alnum:] ~.,;:/|?<>address@hidden&^↑]+?\\)[_?]\\)"
+                  (format
+                   
"\\(?:%%\\(%s\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:[_?]\\(%s\\)\\(%s\\)[_?]\\)"
+                   hydra-width-spec-regex
+                   hydra-width-spec-regex
+                   hydra-key-regex)
                   docstring start))
       (cond ((eq ?? (aref (match-string 0 docstring) 0))
              (let* ((key (match-string 4 docstring))



reply via email to

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