(interactive)
(hydra-default-pre)
(condition-case err
- (call-interactively
- (function first-error))
+ (progn
+ (setq this-command
+ (quote first-error))
+ (call-interactively
+ (function first-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote first-error)))
+ nil))
(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 next-error))
+ (progn
+ (setq this-command
+ (quote next-error))
+ (call-interactively
+ (function next-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote next-error)))
+ nil))
(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 previous-error))
+ (progn
+ (setq this-command
+ (quote previous-error))
+ (call-interactively
+ (function previous-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote previous-error)))
+ nil))
(unless (keymapp
(lookup-key
global-map
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
- (call-interactively
- (function
- toggle-truncate-lines))
- (setq this-command
- (quote toggle-truncate-lines)))
+ (progn
+ (setq this-command
+ (quote toggle-truncate-lines))
+ (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 auto-fill-mode))
- (setq this-command
- (quote auto-fill-mode)))
+ (progn
+ (setq this-command
+ (quote auto-fill-mode))
+ (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 abbrev-mode))
- (setq this-command
- (quote abbrev-mode)))
+ (progn
+ (setq this-command
+ (quote abbrev-mode))
+ (call-interactively
+ (function abbrev-mode))))
(defun hydra-toggle/nil nil
"Create a hydra with no body and the heads:
Call the head: `nil'."
(interactive)
(hydra-default-pre)
- (hydra-keyboard-quit)
- nil)
+ (hydra-keyboard-quit))
(set
(defvar hydra-toggle/hint nil
"Dynamic hint for hydra-toggle.")
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
- (call-interactively
- (function next-line))
+ (progn
+ (setq this-command
+ (quote next-line))
+ (call-interactively
+ (function next-line)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
- (quote warn))
- (setq this-command
- (quote next-line)))
+ (quote warn)))
(defun hydra-vi/previous-line nil
"Create a hydra with no body and the heads:
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
- (call-interactively
- (function previous-line))
+ (progn
+ (setq this-command
+ (quote previous-line))
+ (call-interactively
+ (function previous-line)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
- (quote warn))
- (setq this-command
- (quote previous-line)))
+ (quote warn)))
(defun hydra-vi/nil nil
"Create a hydra with no body and the heads:
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
- (hydra-keyboard-quit)
- nil)
+ (hydra-keyboard-quit))
(set
(defvar hydra-vi/hint nil
"Dynamic hint for hydra-vi.")
heads ",\n")
(format "The body can be accessed via `%S'." body-name)))
+(defun hydra--call-interactively (cmd name)
+ "Generate a `call-interactively' statement for CMD.
+Set `this-command' to NAME."
+ (if (and (symbolp name)
+ (not (memq name '(nil body))))
+ `(progn
+ (setq this-command ',name)
+ (call-interactively #',cmd))
+ `(call-interactively #',cmd)))
+
(defun hydra--make-defun (name body doc head
keymap body-pre body-before-exit
&optional body-after-exit)
,@(when body-pre (list body-pre))
,@(if (hydra--head-property head :exit)
`((hydra-keyboard-quit)
- ,(if body-after-exit
- `(unwind-protect
- ,(when cmd `(call-interactively #',cmd))
- ,body-after-exit)
- (when cmd `(call-interactively #',cmd))))
+ ,@(if body-after-exit
+ `((unwind-protect
+ ,(when cmd
+ (hydra--call-interactively cmd (cadr head)))
+ ,body-after-exit))
+ (when cmd
+ `(,(hydra--call-interactively cmd (cadr head))))))
(delq
nil
`(,(when cmd
`(condition-case err
- (call-interactively #',cmd)
+ ,(hydra--call-interactively cmd (cadr head))
((quit error)
(message "%S" err)
(unless hydra-lv
(list 'quote body-foreign-keys)))
,body-after-exit
,(when body-timeout
- `(hydra-timeout ,body-timeout)))))
- ,@(when (and (symbolp (cadr head))
- (not (memq (cadr head) '(nil body))))
- `((setq this-command ',(cadr head)))))))
+ `(hydra-timeout ,body-timeout))))))))
(defmacro hydra--make-funcall (sym)
"Transform SYM into a `funcall' to call it."