Update the tests for the new `hydra-set-transient-map'

* hydra-test.el (hydra-red-error): Update.
(hydra-blue-toggle): Update.
(hydra-amaranth-vi): Update.
(hydra-zoom-duplicate-1): Update.
(hydra-zoom-duplicate-2): Update.

Re #90
master
Oleh Krehel 11 years ago
parent fa5643f318
commit cb630dfacc
  1. 855
      hydra-test.el

@ -38,13 +38,14 @@
("k" previous-error "prev")
("SPC" hydra-repeat "rep" :bind nil)))
'(progn
(set (defvar hydra-error/keymap nil "Keymap for hydra-error.")
(quote (keymap (7 . hydra-keyboard-quit)
(32 . hydra-repeat)
(set
(defvar hydra-error/keymap nil
"Keymap for hydra-error.")
(quote (keymap (32 . hydra-repeat)
(107 . hydra-error/previous-error)
(106 . hydra-error/next-error)
(104 . hydra-error/first-error)
(switch-frame . hydra--handle-switch-frame)
(7 . hydra-keyboard-quit)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
@ -68,7 +69,8 @@
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-error/first-error nil "Create a hydra with a \"M-g\" body and the heads:
(defun hydra-error/first-error nil
"Create a hydra with a \"M-g\" body and the heads:
\"h\": `first-error',
\"j\": `next-error',
@ -78,18 +80,24 @@
The body can be accessed via `hydra-error/body'.
Call the head: `first-error'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function first-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-error/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-error/next-error nil "Create a hydra with a \"M-g\" body and the heads:
(interactive)
(hydra-default-pre)
(condition-case err
(call-interactively
(function first-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-error/hint))
(hydra-set-transient-map
hydra-error/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil))
(defun hydra-error/next-error nil
"Create a hydra with a \"M-g\" body and the heads:
\"h\": `first-error',
\"j\": `next-error',
@ -99,18 +107,24 @@ Call the head: `first-error'."
The body can be accessed via `hydra-error/body'.
Call the head: `next-error'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function next-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-error/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-error/previous-error nil "Create a hydra with a \"M-g\" body and the heads:
(interactive)
(hydra-default-pre)
(condition-case err
(call-interactively
(function next-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-error/hint))
(hydra-set-transient-map
hydra-error/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil))
(defun hydra-error/previous-error nil
"Create a hydra with a \"M-g\" body and the heads:
\"h\": `first-error',
\"j\": `next-error',
@ -120,36 +134,55 @@ Call the head: `next-error'."
The body can be accessed via `hydra-error/body'.
Call the head: `previous-error'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function previous-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-error/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(unless (keymapp (lookup-key global-map (kbd "M-g")))
(interactive)
(hydra-default-pre)
(condition-case err
(call-interactively
(function previous-error))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-error/hint))
(hydra-set-transient-map
hydra-error/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil))
(unless (keymapp
(lookup-key
global-map
(kbd "M-g")))
(define-key global-map (kbd "M-g")
nil))
(define-key global-map [134217831 104]
(function hydra-error/first-error))
(function
hydra-error/first-error))
(define-key global-map [134217831 106]
(function hydra-error/next-error))
(function
hydra-error/next-error))
(define-key global-map [134217831 107]
(function hydra-error/previous-error))
(function
hydra-error/previous-error))
(defun hydra-error/hint nil
(if hydra-lv (lv-message (format #("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep." 8 9 (face hydra-face-red)
20 21 (face hydra-face-red)
31 32 (face hydra-face-red)
42 45 (face hydra-face-red))))
(message (format #("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep." 8 9 (face hydra-face-red)
20 21 (face hydra-face-red)
31 32 (face hydra-face-red)
42 45 (face hydra-face-red))))))
(defun hydra-error/body nil "Create a hydra with a \"M-g\" body and the heads:
(if hydra-lv
(lv-message
(format
#("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep."
8 9 (face hydra-face-red)
20 21 (face hydra-face-red)
31 32 (face hydra-face-red)
42 45 (face hydra-face-red))))
(message
(format
#("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep."
8 9 (face hydra-face-red)
20 21 (face hydra-face-red)
31 32 (face hydra-face-red)
42 45 (face hydra-face-red))))))
(defun hydra-error/body nil
"Create a hydra with a \"M-g\" body and the heads:
\"h\": `first-error',
\"j\": `next-error',
@ -157,14 +190,18 @@ Call the head: `previous-error'."
\"SPC\": `hydra-repeat'
The body can be accessed via `hydra-error/body'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-error/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-error/keymap)
t (lambda nil (hydra-keyboard-quit))))
(setq prefix-arg current-prefix-arg)))))))
(interactive)
(hydra-default-pre)
(when hydra-is-helpful
(hydra-error/hint))
(hydra-set-transient-map
hydra-error/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil)
(setq prefix-arg
current-prefix-arg))))))
(ert-deftest hydra-blue-toggle ()
(should
@ -177,13 +214,14 @@ The body can be accessed via `hydra-error/body'."
("a" abbrev-mode "abbrev")
("q" nil "cancel")))
'(progn
(set (defvar hydra-toggle/keymap nil "Keymap for hydra-toggle.")
(quote (keymap (7 . hydra-keyboard-quit)
(113 . hydra-toggle/nil)
(set
(defvar hydra-toggle/keymap nil
"Keymap for hydra-toggle.")
(quote (keymap (113 . hydra-toggle/nil)
(97 . hydra-toggle/abbrev-mode-and-exit)
(102 . hydra-toggle/auto-fill-mode-and-exit)
(116 . hydra-toggle/toggle-truncate-lines-and-exit)
(switch-frame . hydra--handle-switch-frame)
(7 . hydra-keyboard-quit)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
@ -207,7 +245,8 @@ The body can be accessed via `hydra-error/body'."
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-toggle/toggle-truncate-lines-and-exit nil "Create a hydra with no body and the heads:
(defun hydra-toggle/toggle-truncate-lines-and-exit nil
"Create a hydra with no body and the heads:
\"t\": `toggle-truncate-lines',
\"f\": `auto-fill-mode',
@ -217,13 +256,15 @@ The body can be accessed via `hydra-error/body'."
The body can be accessed via `hydra-toggle/body'.
Call the head: `toggle-truncate-lines'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function toggle-truncate-lines))))
(defun hydra-toggle/auto-fill-mode-and-exit nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
(call-interactively
(function
toggle-truncate-lines))
nil)
(defun hydra-toggle/auto-fill-mode-and-exit nil
"Create a hydra with no body and the heads:
\"t\": `toggle-truncate-lines',
\"f\": `auto-fill-mode',
@ -233,13 +274,14 @@ Call the head: `toggle-truncate-lines'."
The body can be accessed via `hydra-toggle/body'.
Call the head: `auto-fill-mode'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function auto-fill-mode))))
(defun hydra-toggle/abbrev-mode-and-exit nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
(call-interactively
(function auto-fill-mode))
nil)
(defun hydra-toggle/abbrev-mode-and-exit nil
"Create a hydra with no body and the heads:
\"t\": `toggle-truncate-lines',
\"f\": `auto-fill-mode',
@ -249,13 +291,14 @@ Call the head: `auto-fill-mode'."
The body can be accessed via `hydra-toggle/body'.
Call the head: `abbrev-mode'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function abbrev-mode))))
(defun hydra-toggle/nil nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
(call-interactively
(function abbrev-mode))
nil)
(defun hydra-toggle/nil nil
"Create a hydra with no body and the heads:
\"t\": `toggle-truncate-lines',
\"f\": `auto-fill-mode',
@ -265,21 +308,29 @@ Call the head: `abbrev-mode'."
The body can be accessed via `hydra-toggle/body'.
Call the head: `nil'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)))
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
nil
nil)
(defun hydra-toggle/hint nil
(if hydra-lv (lv-message (format #("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel." 9 10 (face hydra-face-blue)
24 25 (face hydra-face-blue)
35 36 (face hydra-face-blue)
48 49 (face hydra-face-blue))))
(message (format #("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel." 9 10 (face hydra-face-blue)
24 25 (face hydra-face-blue)
35 36 (face hydra-face-blue)
48 49 (face hydra-face-blue))))))
(defun hydra-toggle/body nil "Create a hydra with no body and the heads:
(if hydra-lv
(lv-message
(format
#("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel."
9 10 (face hydra-face-blue)
24 25 (face hydra-face-blue)
35 36 (face hydra-face-blue)
48 49 (face hydra-face-blue))))
(message
(format
#("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel."
9 10 (face hydra-face-blue)
24 25 (face hydra-face-blue)
35 36 (face hydra-face-blue)
48 49 (face hydra-face-blue))))))
(defun hydra-toggle/body nil
"Create a hydra with no body and the heads:
\"t\": `toggle-truncate-lines',
\"f\": `auto-fill-mode',
@ -287,14 +338,18 @@ Call the head: `nil'."
\"q\": `nil'
The body can be accessed via `hydra-toggle/body'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-toggle/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-toggle/keymap)
t (lambda nil (hydra-keyboard-quit))))
(setq prefix-arg current-prefix-arg)))))))
(interactive)
(hydra-default-pre)
(when hydra-is-helpful
(hydra-toggle/hint))
(hydra-set-transient-map
hydra-toggle/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil)
(setq prefix-arg
current-prefix-arg))))))
(ert-deftest hydra-amaranth-vi ()
(should
@ -311,17 +366,13 @@ The body can be accessed via `hydra-toggle/body'."
("k" previous-line)
("q" nil "quit")))
'(progn
(set (defvar hydra-vi/keymap nil "Keymap for hydra-vi.")
(quote (keymap (t lambda nil (interactive)
(message "An amaranth Hydra can only exit through a blue head")
(hydra-set-transient-map hydra-curr-map t)
(when hydra-is-helpful (unless hydra-lv (sit-for 0.8))
(hydra-vi/hint)))
(113 . hydra-vi/nil)
(set
(defvar hydra-vi/keymap nil
"Keymap for hydra-vi.")
(quote (keymap (113 . hydra-vi/nil)
(107 . hydra-vi/previous-line)
(106 . hydra-vi/next-line)
(7 . hydra-vi/hydra-keyboard-quit-and-exit)
(switch-frame . hydra--handle-switch-frame)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
@ -345,7 +396,8 @@ The body can be accessed via `hydra-toggle/body'."
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-vi/hydra-keyboard-quit-and-exit nil "Create a hydra with no body and the heads:
(defun hydra-vi/hydra-keyboard-quit-and-exit nil
"Create a hydra with no body and the heads:
\"\": `hydra-keyboard-quit',
\"j\": `next-line',
@ -355,15 +407,15 @@ The body can be accessed via `hydra-toggle/body'."
The body can be accessed via `hydra-vi/body'.
Call the head: `hydra-keyboard-quit'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function hydra-keyboard-quit))
(set-cursor-color "#ffffff")))
(defun hydra-vi/next-line nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-keyboard-quit)
(call-interactively
(function hydra-keyboard-quit))
(set-cursor-color "#ffffff"))
(defun hydra-vi/next-line nil
"Create a hydra with no body and the heads:
\"\": `hydra-keyboard-quit',
\"j\": `next-line',
@ -373,19 +425,25 @@ Call the head: `hydra-keyboard-quit'."
The body can be accessed via `hydra-vi/body'.
Call the head: `next-line'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function next-line))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-vi/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-vi/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-vi/previous-line nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
(call-interactively
(function next-line))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-vi/hint))
(hydra-set-transient-map
hydra-vi/keymap
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
(quote warn)))
(defun hydra-vi/previous-line nil
"Create a hydra with no body and the heads:
\"\": `hydra-keyboard-quit',
\"j\": `next-line',
@ -395,19 +453,25 @@ Call the head: `next-line'."
The body can be accessed via `hydra-vi/body'.
Call the head: `previous-line'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function previous-line))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-vi/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-vi/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-vi/nil nil "Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
(call-interactively
(function previous-line))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-vi/hint))
(hydra-set-transient-map
hydra-vi/keymap
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
(quote warn)))
(defun hydra-vi/nil nil
"Create a hydra with no body and the heads:
\"\": `hydra-keyboard-quit',
\"j\": `next-line',
@ -417,21 +481,28 @@ Call the head: `previous-line'."
The body can be accessed via `hydra-vi/body'.
Call the head: `nil'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(set-cursor-color "#ffffff")))
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-keyboard-quit)
nil
(set-cursor-color "#ffffff"))
(defun hydra-vi/hint nil
(if hydra-lv (lv-message (format #("vi: j, k, [q]: quit." 4 5 (face hydra-face-amaranth)
7 8 (face hydra-face-amaranth)
11 12 (face hydra-face-blue))))
(message (format #("vi: j, k, [q]: quit." 4 5 (face hydra-face-amaranth)
7 8 (face hydra-face-amaranth)
11 12 (face hydra-face-blue))))))
(defun hydra-vi/body nil "Create a hydra with no body and the heads:
(if hydra-lv
(lv-message
(format
#("vi: j, k, [q]: quit."
4 5 (face hydra-face-amaranth)
7 8 (face hydra-face-amaranth)
11 12 (face hydra-face-blue))))
(message
(format
#("vi: j, k, [q]: quit."
4 5 (face hydra-face-amaranth)
7 8 (face hydra-face-amaranth)
11 12 (face hydra-face-blue))))))
(defun hydra-vi/body nil
"Create a hydra with no body and the heads:
\"\": `hydra-keyboard-quit',
\"j\": `next-line',
@ -439,15 +510,257 @@ Call the head: `nil'."
\"q\": `nil'
The body can be accessed via `hydra-vi/body'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-vi/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-vi/keymap)
t (lambda nil (hydra-keyboard-quit))))
(setq prefix-arg current-prefix-arg)))))))
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
(when hydra-is-helpful
(hydra-vi/hint))
(hydra-set-transient-map
hydra-vi/keymap
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
(quote warn))
(setq prefix-arg
current-prefix-arg))))))
(ert-deftest hydra-zoom-duplicate-1 ()
(should
(equal
(macroexpand
'(defhydra hydra-zoom ()
"zoom"
("r" (text-scale-set 0) "reset")
("0" (text-scale-set 0) :bind nil :exit t)
("1" (text-scale-set 0) nil :bind nil :exit t)))
'(progn
(set
(defvar hydra-zoom/keymap nil
"Keymap for hydra-zoom.")
(quote (keymap (114 . hydra-zoom/lambda-r)
(7 . hydra-keyboard-quit)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
(kp-7 . hydra--digit-argument)
(kp-6 . hydra--digit-argument)
(kp-5 . hydra--digit-argument)
(kp-4 . hydra--digit-argument)
(kp-3 . hydra--digit-argument)
(kp-2 . hydra--digit-argument)
(kp-1 . hydra--digit-argument)
(kp-0 . hydra--digit-argument)
(57 . hydra--digit-argument)
(56 . hydra--digit-argument)
(55 . hydra--digit-argument)
(54 . hydra--digit-argument)
(53 . hydra--digit-argument)
(52 . hydra--digit-argument)
(51 . hydra--digit-argument)
(50 . hydra--digit-argument)
(49 . hydra-zoom/lambda-0-and-exit)
(48 . hydra-zoom/lambda-0-and-exit)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-zoom/lambda-r nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(condition-case err
(call-interactively
(function
(lambda nil
(interactive)
(text-scale-set 0))))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-zoom/hint))
(hydra-set-transient-map
hydra-zoom/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil))
(defun hydra-zoom/lambda-0-and-exit nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
(call-interactively
(function
(lambda nil
(interactive)
(text-scale-set 0))))
nil)
(defun hydra-zoom/hint nil
(if hydra-lv
(lv-message
(format
#("zoom: [r 0]: reset."
7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))
(message
(format
#("zoom: [r 0]: reset."
7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))))
(defun hydra-zoom/body nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
(when hydra-is-helpful
(hydra-zoom/hint))
(hydra-set-transient-map
hydra-zoom/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil)
(setq prefix-arg
current-prefix-arg))))))
(ert-deftest hydra-zoom-duplicate-2 ()
(should
(equal
(macroexpand
'(defhydra hydra-zoom ()
"zoom"
("r" (text-scale-set 0) "reset")
("0" (text-scale-set 0) :bind nil :exit t)
("1" (text-scale-set 0) nil :bind nil)))
'(progn
(set
(defvar hydra-zoom/keymap nil
"Keymap for hydra-zoom.")
(quote (keymap (114 . hydra-zoom/lambda-r)
(7 . hydra-keyboard-quit)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
(kp-7 . hydra--digit-argument)
(kp-6 . hydra--digit-argument)
(kp-5 . hydra--digit-argument)
(kp-4 . hydra--digit-argument)
(kp-3 . hydra--digit-argument)
(kp-2 . hydra--digit-argument)
(kp-1 . hydra--digit-argument)
(kp-0 . hydra--digit-argument)
(57 . hydra--digit-argument)
(56 . hydra--digit-argument)
(55 . hydra--digit-argument)
(54 . hydra--digit-argument)
(53 . hydra--digit-argument)
(52 . hydra--digit-argument)
(51 . hydra--digit-argument)
(50 . hydra--digit-argument)
(49 . hydra-zoom/lambda-r)
(48 . hydra-zoom/lambda-0-and-exit)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-zoom/lambda-r nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(condition-case err
(call-interactively
(function
(lambda nil
(interactive)
(text-scale-set 0))))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful
(hydra-zoom/hint))
(hydra-set-transient-map
hydra-zoom/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil))
(defun hydra-zoom/lambda-0-and-exit nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
(call-interactively
(function
(lambda nil
(interactive)
(text-scale-set 0))))
nil)
(defun hydra-zoom/hint nil
(if hydra-lv
(lv-message
(format
#("zoom: [r 0]: reset."
7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))
(message
(format
#("zoom: [r 0]: reset."
7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))))
(defun hydra-zoom/body nil
"Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
(when hydra-is-helpful
(hydra-zoom/hint))
(hydra-set-transient-map
hydra-zoom/keymap
(lambda nil
(hydra-keyboard-quit)
nil)
nil)
(setq prefix-arg
current-prefix-arg))))))
(ert-deftest defhydradio ()
(should (equal
@ -726,196 +1039,6 @@ _f_ auto-fill-mode: %`auto-fill-function
("e" fun-e)
("f" fun-f))))))
(ert-deftest hydra-zoom-duplicate-1 ()
(should
(equal
(macroexpand
'(defhydra hydra-zoom ()
"zoom"
("r" (text-scale-set 0) "reset")
("0" (text-scale-set 0) :bind nil :exit t)
("1" (text-scale-set 0) nil :bind nil :exit t)))
'(progn
(set (defvar hydra-zoom/keymap nil "Keymap for hydra-zoom.")
(quote (keymap (7 . hydra-keyboard-quit)
(114 . hydra-zoom/lambda-r)
(switch-frame . hydra--handle-switch-frame)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
(kp-7 . hydra--digit-argument)
(kp-6 . hydra--digit-argument)
(kp-5 . hydra--digit-argument)
(kp-4 . hydra--digit-argument)
(kp-3 . hydra--digit-argument)
(kp-2 . hydra--digit-argument)
(kp-1 . hydra--digit-argument)
(kp-0 . hydra--digit-argument)
(57 . hydra--digit-argument)
(56 . hydra--digit-argument)
(55 . hydra--digit-argument)
(54 . hydra--digit-argument)
(53 . hydra--digit-argument)
(52 . hydra--digit-argument)
(51 . hydra--digit-argument)
(50 . hydra--digit-argument)
(49 . hydra-zoom/lambda-0-and-exit)
(48 . hydra-zoom/lambda-0-and-exit)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-zoom/lambda-r nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function (lambda nil (interactive)
(text-scale-set 0))))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-zoom/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-zoom/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-zoom/lambda-0-and-exit nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function (lambda nil (interactive)
(text-scale-set 0))))))
(defun hydra-zoom/hint nil
(if hydra-lv (lv-message (format #("zoom: [r 0]: reset." 7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))
(message (format #("zoom: [r 0]: reset." 7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))))
(defun hydra-zoom/body nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-zoom/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-zoom/keymap)
t (lambda nil (hydra-keyboard-quit))))
(setq prefix-arg current-prefix-arg)))))))
(ert-deftest hydra-zoom-duplicate-2 ()
(should
(equal
(macroexpand
'(defhydra hydra-zoom ()
"zoom"
("r" (text-scale-set 0) "reset")
("0" (text-scale-set 0) :bind nil :exit t)
("1" (text-scale-set 0) nil :bind nil)))
'(progn
(set (defvar hydra-zoom/keymap nil "Keymap for hydra-zoom.")
(quote (keymap (7 . hydra-keyboard-quit)
(114 . hydra-zoom/lambda-r)
(switch-frame . hydra--handle-switch-frame)
(kp-subtract . hydra--negative-argument)
(kp-9 . hydra--digit-argument)
(kp-8 . hydra--digit-argument)
(kp-7 . hydra--digit-argument)
(kp-6 . hydra--digit-argument)
(kp-5 . hydra--digit-argument)
(kp-4 . hydra--digit-argument)
(kp-3 . hydra--digit-argument)
(kp-2 . hydra--digit-argument)
(kp-1 . hydra--digit-argument)
(kp-0 . hydra--digit-argument)
(57 . hydra--digit-argument)
(56 . hydra--digit-argument)
(55 . hydra--digit-argument)
(54 . hydra--digit-argument)
(53 . hydra--digit-argument)
(52 . hydra--digit-argument)
(51 . hydra--digit-argument)
(50 . hydra--digit-argument)
(49 . hydra-zoom/lambda-r)
(48 . hydra-zoom/lambda-0-and-exit)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
(defun hydra-zoom/lambda-r nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (call-interactively (function (lambda nil (interactive)
(text-scale-set 0))))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(when hydra-is-helpful (hydra-zoom/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-zoom/keymap)
t (lambda nil (hydra-keyboard-quit))))))
(defun hydra-zoom/lambda-0-and-exit nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(hydra-keyboard-quit)
(catch (quote hydra-disable)
(call-interactively (function (lambda nil (interactive)
(text-scale-set 0))))))
(defun hydra-zoom/hint nil
(if hydra-lv (lv-message (format #("zoom: [r 0]: reset." 7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))
(message (format #("zoom: [r 0]: reset." 7 8 (face hydra-face-red)
9 10 (face hydra-face-blue))))))
(defun hydra-zoom/body nil "Create a hydra with no body and the heads:
\"r\": `(text-scale-set 0)',
\"0\": `(text-scale-set 0)',
\"1\": `(text-scale-set 0)'
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-zoom/hint))
(setq hydra-last (hydra-set-transient-map (setq hydra-curr-map hydra-zoom/keymap)
t (lambda nil (hydra-keyboard-quit))))
(setq prefix-arg current-prefix-arg)))))))
(ert-deftest hydra--pad ()
(should (equal (hydra--pad '(a b c) 3)
'(a b c)))

Loading…
Cancel
Save