branch: elpa/evil-lisp-state
commit 13fc1def920ac8e816549e380656614fe92fd113
Author: syl20bnr <[email protected]>
Commit: syl20bnr <[email protected]>
Add variable evil-lisp-state-enter-lisp-state-on-command
---
README.md | 6 +++++-
evil-lisp-state.el | 27 +++++++++++++++++++--------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index fdf9f6d2d4..e3426b6f5c 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ both `evil`, `bind-map` and `smartparens` to be installed.
To execute a command while in normal state, a leader key is used.
By default, the leader for each command is `SPC l`.
-Any command when executed sets the current state to `lisp state`.
+By default any command when executed sets the current state to `lisp state`.
Examples:
@@ -119,6 +119,10 @@ effect.
The leader key is `SPC l` by default, it is possible to change it with the
variable `evil-lisp-state-leader'.
+If you don't want commands to enter in `lisp state` by default set the variable
+`evil-lisp-state-enter-lisp-state-on-command` to nil. Then use the
+<kbd>,,</kbd> to enter manually in `lisp state`
+
[evil-link]: https://gitorious.org/evil/pages/Home
[smartparens-link]: https://github.com/Fuco1/smartparens/wiki
[melpa-link]: http://melpa.org/
diff --git a/evil-lisp-state.el b/evil-lisp-state.el
index bcc8023481..ffedf1d648 100644
--- a/evil-lisp-state.el
+++ b/evil-lisp-state.el
@@ -34,7 +34,8 @@
;; To execute a command while in normal state, a leader is used.
;; By default, the leader for each command is `SPC l`.
-;; Any command when executed sets the current state to `lisp state`.
+;; By default, any command when executed sets the current state to
+;; `lisp state`.
;; By example, to slurp three times while in normal state:
;; <leader> 3 s
@@ -101,6 +102,10 @@
;; The leader key is `SPC l' by default, it is possible to
;; change it with the variable `evil-lisp-state-leader'.
+;; If you don't want commands to enter in `lisp state' by default
+;; set the variable `evil-lisp-state-enter-lisp-state-on-command'
+;; to nil. Then use the `,,' to enter manually in `lisp state'
+
;;; Code:
(require 'evil)
@@ -134,6 +139,11 @@
(defcustom evil-lisp-state-major-modes '(emacs-lisp-mode)
"Major modes where evil leader key bindings are defined.
If `evil-lisp-state-global' is non nil then this variable has no effect."
+ :type 'sexp
+ :group 'evil-lisp-state)
+
+ (defcustom evil-lisp-state-enter-lisp-state-on-command nil
+ "If non nil, enter evil-lisp-state before executing command."
:type 'sexp
:group 'evil-lisp-state))
@@ -146,7 +156,8 @@ If `evil-lisp-state-global' is non nil then this variable
has no effect."
`(progn
(defun ,funcname ()
(interactive)
- (evil-lisp-state)
+ (when evil-lisp-state-enter-lisp-state-on-command
+ (evil-lisp-state))
(call-interactively ',command))
',funcname)))
@@ -241,17 +252,17 @@ If `evil-lisp-state-global' is non nil then this variable
has no effect."
(eval
`(progn
(if evil-lisp-state-global
- (define-key evil-lisp-state-map ,(kbd key) ',cmd)
- (define-key evil-lisp-state-major-mode-map ,(kbd key) ',cmd))))))
+ (define-key evil-lisp-state-map ,(kbd key)
+ (evil-lisp-state-enter-command ,cmd))
+ (define-key evil-lisp-state-major-mode-map ,(kbd key)
+ (evil-lisp-state-enter-command ,cmd)))))))
(defun lisp-state-toggle-lisp-state ()
"Toggle the lisp state."
(interactive)
+ (message "state: %s" evil-state)
(if (eq 'lisp evil-state)
- (progn
- (message "state: lisp -> normal")
- (evil-normal-state))
- (message "state: %s -> lisp" evil-state)
+ (evil-normal-state)
(evil-lisp-state)))
(defun lisp-state-wrap (&optional arg)