branch: elpa/evil-lisp-state
commit 45bbdfce7ffaea08ac9196c02133a302d911e2b3
Author: syl20bnr <[email protected]>
Commit: syl20bnr <[email protected]>
Insert sibling before/after bindings on `(` and `)` respectively
---
README.md | 3 ++-
evil-lisp-state.el | 31 +++++++++++++++++--------------
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index eebc032e01..d61f1c11b0 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,8 @@ to default `<tab>`):
Key Binding | Function
--------------|------------------------------------------------------------
-`(` | switch to `insert state` and insert "("
+`(` | insert sibling before sexp and switch to `insert state`
+`)` | insert sibling after sexp and switch to `insert state`
`%` | evil-jump-item (use it to go to the end of sexp)
`$` | sp-end-of-sexp
`0` | sp-beginning-of-sexp
diff --git a/evil-lisp-state.el b/evil-lisp-state.el
index 1a76af7595..3c2a8af5d7 100644
--- a/evil-lisp-state.el
+++ b/evil-lisp-state.el
@@ -93,7 +93,8 @@ of COMMAND.
(define-key evil-lisp-state-map (kbd bkey) bcmdsym)))))
;; key bindings
-(define-key evil-lisp-state-map "(" 'evil-lisp-state-insert-left-paren)
+(define-key evil-lisp-state-map "(" 'evil-lisp-state-insert-sexp-before)
+(define-key evil-lisp-state-map ")" 'evil-lisp-state-insert-sexp-after)
(define-key evil-lisp-state-map "1" 'digit-argument)
(define-key evil-lisp-state-map "2" 'digit-argument)
(define-key evil-lisp-state-map "3" 'digit-argument)
@@ -189,22 +190,24 @@ of COMMAND.
(defun evil-lisp-state-insert-sexp-after ()
"Insert sexp after the current one."
(interactive)
- (if (char-equal (char-after) ?\() (evil-lisp-state-forward-symbol))
- (sp-up-sexp)
- (evil-insert-state)
- (sp-newline)
- (sp-insert-pair "("))
+ (let ((sp-navigate-consider-symbols nil))
+ (if (char-equal (char-after) ?\() (evil-lisp-state-forward-symbol))
+ (sp-up-sexp)
+ (evil-insert-state)
+ (sp-newline)
+ (sp-insert-pair "(")))
(defun evil-lisp-state-insert-sexp-before ()
"Insert sexp before the current one."
(interactive)
- (if (char-equal (char-after) ?\() (evil-lisp-state-forward-symbol))
- (sp-backward-sexp)
- (evil-insert-state)
- (sp-newline)
- (evil-previous-visual-line)
- (evil-end-of-line)
- (sp-insert-pair "(")
- (indent-for-tab-command))
+ (let ((sp-navigate-consider-symbols nil))
+ (if (char-equal (char-after) ?\() (evil-lisp-state-forward-symbol))
+ (sp-backward-sexp)
+ (evil-insert-state)
+ (sp-newline)
+ (evil-previous-visual-line)
+ (evil-end-of-line)
+ (sp-insert-pair "(")
+ (indent-for-tab-command)))
(provide 'evil-lisp-state)