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

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

[elpa] master a85a617 03/36: Allow to use e.g. "↑" in place of "<up>" i


From: Oleh Krehel
Subject: [elpa] master a85a617 03/36: Allow to use e.g. "↑" in place of "<up>" in the docstring
Date: Sat, 22 Jul 2017 11:22:20 -0400 (EDT)

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

    Allow to use e.g. "↑" in place of "<up>" in the docstring
    
    * hydra.el (hydra-docstring-keys-translate-alist): New defvar.
    (hydra--format): Add "↑" to the regex, modify the head accordingly for
    the `hydra-fontify-head' call.
    
    Re #186
---
 hydra.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/hydra.el b/hydra.el
index d624581..a048df8 100644
--- a/hydra.el
+++ b/hydra.el
@@ -581,6 +581,9 @@ HEAD's binding is returned as a string wrapped with [] or 
{}."
         (setq str (replace-match "" nil nil str))))
     str))
 
+(defvar hydra-docstring-keys-translate-alist
+  '(("↑" . "<up>")))
+
 (defun hydra--format (_name body docstring heads)
   "Generate a `format' statement from STR.
 \"%`...\" expressions are extracted into \"%S\".
@@ -594,7 +597,7 @@ 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&^]+?\\)[_?]\\)"
+                  "\\(?:%\\( 
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:[_?]\\( 
?-?[0-9]*?\\)\\(\\[\\|]\\|[-[:alnum:] ~.,;:/|?<>address@hidden&^↑]+?\\)[_?]\\)"
                   docstring start))
       (cond ((eq ?? (aref (match-string 0 docstring) 0))
              (let* ((key (match-string 4 docstring))
@@ -612,10 +615,19 @@ The expressions can be auto-expanded according to NAME."
             ((eq ?_ (aref (match-string 0 docstring) 0))
              (let* ((key (match-string 4 docstring))
                     (key (if (equal key "β") "_" key))
-                    (head (assoc key heads)))
+                    normal-key
+                    (head (or (assoc key heads)
+                              (when (setq normal-key
+                                          (cdr (assoc
+                                                key 
hydra-docstring-keys-translate-alist)))
+                                (assoc normal-key heads)))))
                (if head
                    (progn
-                     (push (hydra-fontify-head head body) varlist)
+                     (push (hydra-fontify-head (if normal-key
+                                                   (cons key (cdr head))
+                                                 head)
+                                               body)
+                           varlist)
                      (setq docstring
                            (replace-match
                             (or



reply via email to

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