evil-god-state icon indicating copy to clipboard operation
evil-god-state copied to clipboard

Support wrapping `evil-execute-in-god-state'.

Open fishyfriend opened this issue 5 years ago • 0 comments

This PR makes it possible to wrap evil-execute-in-god-state in another command.

God state's post-command hook checks the name of the last-run command to know whether to exit the state. If I wrap evil-execute-in-god-state inside another command, the last-run command is no longer evil-execute-in-god-state, but rather the name of the command that wraps it. This would break the check as it currently exists. So I have simply updated evil-execute-in-god-state to set the name of the current command in a variable. The check now looks at this variable instead of hardcoding the command name.

I am currently using this feature to make normal-mode keybindings usable via God state. So I can have , bound to regular evil-execute-in-god-state and ' bound to this:

(defun evil-execute-in-god-state-with-evil-bindings ()
  (interactive)
  ;; evil-god-set-transient-bindings sets up an Evil intercept keymap
  ;; that makes the specified keybindings available in god state.
  ;; elsewhere i ensure the intercept map is cleaned up after leaving the state.
  (evil-god-set-transient-bindings
   (make-composed-keymap (current-active-maps)))
  (evil-execute-in-god-state))

Happy to share the full code for the above but it's dirty so not posting for the moment. Perhaps will make another PR for it later.

fishyfriend avatar Apr 04 '20 00:04 fishyfriend