[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c413b5f 54/72: Allow for a custom key format spec in docst
From: |
Oleh Krehel |
Subject: |
[elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings |
Date: |
Fri, 06 Mar 2015 13:04:20 +0000 |
branch: master
commit c413b5f745cda9f6d7f5f1ca1369168ac30d0a22
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow for a custom key format spec in docstrings
* hydra.el (hydra-key-format-spec): New defcustom.
(hydra--format): Use `hydra-key-format-spec'. Allow for 0-9 and / in key
bindings.
Here's an example of how to use a flexible format spec for each key:
(let (hydra-key-format-spec)
(defhydra hydra-zoom (global-map "<f2>")
"
zoom: _g_reater _ -5l_esser re_ 7c_enter zer_0_"
("g" text-scale-increase nil)
("l" text-scale-decrease nil)
("c" recenter-top-bottom nil)
("0" (text-scale-set 0) nil :exit t)))
Fixes #50.
---
hydra.el | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/hydra.el b/hydra.el
index fdf1b9f..658c710 100644
--- a/hydra.el
+++ b/hydra.el
@@ -121,6 +121,10 @@ It's possible to set this to nil.")
"When non-nil, hydra will issue some non-essential style warnings."
:type 'boolean)
+(defcustom hydra-key-format-spec "% 3s"
+ "Default `format'-style specifier for _a_ syntax in docstrings.
+When nil, you can specify your own at each location like this: _ 5a_.")
+
(defface hydra-face-red
'((t (:foreground "#FF0000" :bold t)))
"Red Hydra heads will persist indefinitely."
@@ -448,15 +452,20 @@ The expressions can be auto-expanded according to NAME."
offset)
(while (setq start
(string-match
- "\\(?:%\\(
?-?[0-9]*\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\([a-z-~A-Z]+\\)_\\)"
+ "\\(?:%\\(
?-?[0-9]*\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\(
?-?[0-9]*\\)\\([a-z-~A-Z0-9/]+\\)_\\)"
docstring start))
(cond ((eq ?_ (aref (match-string 0 docstring) 0))
- (let* ((key (match-string 3 docstring))
+ (let* ((key (match-string 4 docstring))
(head (assoc key heads)))
(if head
(progn
(push (hydra-fontify-head head body) varlist)
- (setq docstring (replace-match "% 3s" nil nil docstring)))
+ (setq docstring
+ (replace-match
+ (or
+ hydra-key-format-spec
+ (concat "%" (match-string 3 docstring) "s"))
+ nil nil docstring)))
(error "Unrecognized key: _%s_" key))))
((eq ?` (aref (match-string 2 docstring) 0))
- [elpa] master a71b76e 35/72: Intercept quit signals, (continued)
- [elpa] master a71b76e 35/72: Intercept quit signals, Oleh Krehel, 2015/03/06
- [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 <=
- [elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom, Oleh Krehel, 2015/03/06
- [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