"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.
(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.")
(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"))
"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'."
(if (> (length (cdr x)) 0)
(concat "[%s]: " (cdr x))
"%s")
- (car x)))
+ (if (equal (car x) "%")
+ "%%"
+ (car x))))
(nreverse (mapcar #'cdr alist))
", ")))
(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