[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a2f8a23 01/22: Allow to escape ^ in docstrings
From: |
Oleh Krehel |
Subject: |
[elpa] master a2f8a23 01/22: Allow to escape ^ in docstrings |
Date: |
Fri, 16 Oct 2015 10:06:54 +0000 |
branch: master
commit a2f8a23850294f7c6621ccceb6bb7d03db6e692e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to escape ^ in docstrings
* hydra.el (hydra-deactivate): Fix doc.
(hydra--ignore): Fix doc.
(hydra-amaranth-warn): Add doc.
(hydra--work-around-dedicated): Fix doc.
(hydra--hint): Work around a key being "%".
(hydra--strip-align-markers): New defun.
(hydra--format): Use `hydra--strip-align-markers'.
Fixes #126
---
hydra.el | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/hydra.el b/hydra.el
index f50cbf8..7e67b2c 100644
--- a/hydra.el
+++ b/hydra.el
@@ -89,8 +89,8 @@
"The current :foreign-keys behavior.")
(defvar hydra-deactivate nil
- "If a Hydra head sets this to t, exit the Hydra even if the
- head wasn't designated for exiting.")
+ "If a Hydra head sets this to t, exit the Hydra.
+This will be done even if the head wasn't designated for exiting.")
(defun hydra-set-transient-map (keymap on-exit &optional foreign-keys)
"Set KEYMAP to the highest priority.
@@ -127,7 +127,7 @@ warn: keep KEYMAP and issue a warning instead of running
the command."
(hydra-disable)))
(defvar hydra--ignore nil
- "When non-nil, don't call `hydra-curr-on-exit'")
+ "When non-nil, don't call `hydra-curr-on-exit'.")
(defvar hydra--input-method-function nil
"Store overridden `input-method-function' here.")
@@ -172,6 +172,7 @@ warn: keep KEYMAP and issue a warning instead of running
the command."
(set symbol tail))))))
(defun hydra-amaranth-warn ()
+ "Issue a warning that the current input was ignored."
(interactive)
(message "An amaranth Hydra can only exit through a blue head"))
@@ -393,8 +394,8 @@ Return DEFAULT if PROP is not in H."
"Timer for the hint.")
(defvar hydra--work-around-dedicated t
- "When non-nil, assume there's no bug in `pop-to-buffer'
- selecting a dedicated window.")
+ "When non-nil, assume there's no bug in `pop-to-buffer'.
+`pop-to-buffer' should not select a dedicated window.")
(defun hydra-keyboard-quit ()
"Quitting function similar to `keyboard-quit'."
@@ -430,7 +431,9 @@ BODY, and HEADS are parameters to `defhydra'."
(if (> (length (cdr x)) 0)
(concat "[%s]: " (cdr x))
"%s")
- (car x)))
+ (if (equal (car x) "%")
+ "%%"
+ (car x))))
(nreverse (mapcar #'cdr alist))
", ")))
@@ -476,12 +479,23 @@ HEAD's binding is returned as a string wrapped with [] or
{}."
(funcall (or hydra-fontify-head-function 'hydra-fontify-head-default)
head body))
+(defun hydra--strip-align-markers (str)
+ "Remove ^ from STR, unless they're escaped: \\^."
+ (let ((start 0))
+ (while (setq start (string-match "\\\\?\\^" str start))
+ (if (eq (- (match-end 0) (match-beginning 0)) 2)
+ (progn
+ (setq str (replace-match "^" nil nil str))
+ (cl-incf start))
+ (setq str (replace-match "" nil nil str))))
+ str))
+
(defun hydra--format (_name body docstring heads)
"Generate a `format' statement from STR.
\"%`...\" expressions are extracted into \"%S\".
_NAME, BODY, DOCSTRING and HEADS are parameters of `defhydra'.
The expressions can be auto-expanded according to NAME."
- (setq docstring (replace-regexp-in-string "\\^" "" docstring))
+ (setq docstring (hydra--strip-align-markers docstring))
(let ((rest (hydra--hint body heads))
(start 0)
varlist
- [elpa] master updated (2eb4c54 -> bfeccce), Oleh Krehel, 2015/10/16
- [elpa] master fd8e1b9 02/22: hydra.el (hydra-fontify-head-default): Add "%" exception, Oleh Krehel, 2015/10/16
- [elpa] master a2f8a23 01/22: Allow to escape ^ in docstrings,
Oleh Krehel <=
- [elpa] master 2d45839 03/22: lv-window: split-window ignores window parameters, Oleh Krehel, 2015/10/16
- [elpa] master fca56c3 07/22: targets/hydra-init.el: Move, Oleh Krehel, 2015/10/16
- [elpa] master 1a13273 06/22: Allow to pause arbitrary hydras to the stack, Oleh Krehel, 2015/10/16
- [elpa] master adc2997 08/22: Allow for "_[_" and "_]_" in docs, Oleh Krehel, 2015/10/16
- [elpa] master 1acd5f6 05/22: hydra.el (hydra-face-blue): Customize for dark themes, Oleh Krehel, 2015/10/16
- [elpa] master c8b4749 09/22: Allow binding heads to "%", Oleh Krehel, 2015/10/16
- [elpa] master 7aa8187 13/22: Allow to specify :face for each head, Oleh Krehel, 2015/10/16
- [elpa] master df7b079 10/22: hydra.el (hydra-head-format): Customize the key formatting, Oleh Krehel, 2015/10/16
- [elpa] master 900ca34 04/22: Allow access to the current hydra body, Oleh Krehel, 2015/10/16
- [elpa] master 1e9276a 12/22: Remove trailing whitespace from :columns docstring, Oleh Krehel, 2015/10/16