Intercept quit signals

* hydra.el (hydra--format): Make keys wider.
(hydra--make-defun): Catch quit.
(hydra-pink-fallback): Catch quit.

* hydra-test.el: Update tests.
master
Oleh Krehel 11 years ago
parent 1eebfed70e
commit a71b76e385
  1. 30
      hydra-test.el
  2. 8
      hydra.el

@ -49,9 +49,9 @@ Call the head: `first-error'."
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function first-error)))
(error (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
((quit error) (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last
(hydra-set-transient-map
@ -96,9 +96,9 @@ Call the head: `next-error'."
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function next-error)))
(error (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
((quit error) (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last
(hydra-set-transient-map
@ -143,9 +143,9 @@ Call the head: `previous-error'."
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function previous-error)))
(error (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
((quit error) (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last
(hydra-set-transient-map
@ -392,9 +392,9 @@ Call the head: `next-line'."
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function next-line)))
(error (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
((quit error) (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
(when hydra-is-helpful (hydra-vi/hint))
(setq hydra-last
(hydra-set-transient-map
@ -450,9 +450,9 @@ Call the head: `previous-line'."
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function previous-line)))
(error (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
((quit error) (message "%S" err)
(unless hydra-lv (sit-for 0.8))
nil))
(when hydra-is-helpful (hydra-vi/hint))
(setq hydra-last
(hydra-set-transient-map

@ -345,7 +345,7 @@ The expressions can be auto-expanded according to NAME."
varlist)
(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]+\\)\\)\\|\\(?:_\\([a-z-~A-Z]+\\)_\\)"
docstring start))
(if (eq ?_ (aref (match-string 0 docstring) 0))
(let* ((key (match-string 3 docstring))
@ -353,7 +353,7 @@ The expressions can be auto-expanded according to NAME."
(if head
(progn
(push (propertize key 'face (hydra--face head body)) varlist)
(setq docstring (replace-match "%s" nil nil docstring)))
(setq docstring (replace-match "% 3s" nil nil docstring)))
(error "Unrecognized key: _%s_" key)))
(push (hydra--unalias-var (match-string 2 docstring) prefix) varlist)
(setq docstring (replace-match (concat "%" (match-string 1 docstring) "S") nil nil docstring 0))))
@ -407,7 +407,7 @@ BODY-COLOR, BODY-PRE, BODY-POST, and OTHER-POST are used as well."
`(condition-case err
(prog1 t
(call-interactively #',cmd))
(error
((quit error)
(message "%S" err)
(unless hydra-lv
(sit-for 0.8))
@ -433,7 +433,7 @@ BODY-COLOR, BODY-PRE, BODY-POST, and OTHER-POST are used as well."
(if (commandp kb)
(condition-case err
(call-interactively kb)
(error
((quit error)
(message "%S" err)
(unless hydra-lv
(sit-for 0.8))))

Loading…
Cancel
Save