Skip to content

Commit

Permalink
Add variable evil-lisp-state-default-state
Browse files Browse the repository at this point in the history
Allow to choose the state to activate when leaving the list state.
  • Loading branch information
syl20bnr committed Mar 13, 2016
1 parent f4da219 commit f692342
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion evil-lisp-state.el
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ If `evil-lisp-state-global' is non nil then this variable has no effect."
:type 'sexp
:group 'evil-lisp-state))

(defvar evil-lisp-state-default-state 'normal
"The state to activate when exiting lisp state")

(defmacro evil-lisp-state-enter-command (command)
"Wrap COMMAND to call evil-lisp-state before executing COMMAND."
(let ((funcname (if (string-match "lisp-state-"
Expand Down Expand Up @@ -180,8 +183,13 @@ If `evil-lisp-state-global' is non nil then this variable has no effect."
:evil-states (normal)
:major-modes ,evil-lisp-state-major-modes)))

(defun evil-lisp-state/quit ()
"Quit lisp state and set state `evil-lisp-state-default-state'."
(interactive)
(funcall (intern (format "evil-%S-state" evil-lisp-state-default-state))))

;; escape
(define-key evil-lisp-state-map [escape] 'evil-normal-state)
(define-key evil-lisp-state-map [escape] 'evil-lisp-state/quit)
;; toggle lisp state
(define-key evil-lisp-state-map "." 'lisp-state-toggle-lisp-state)
;; hjkl
Expand Down

0 comments on commit f692342

Please sign in to comment.