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

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

Loading…
Cancel
Save