GitHub - syl20bnr/evil-lisp-state: An evil state to navigate Lisp code and modify it with smartparens (original) (raw)

evil-lisp-state

MELPA

Adds a new evil state to navigate lisp code and edit sexp trees using mnemonic key bindings.

Table of Contents

Install

Package manager

You can either install evil-lisp-state from MELPA:

 M-x package-install evil-lisp-state

Or add it to your Cask file:

(source melpa)

(depends-on "evil-lisp-state")

Manually

Add evil-lisp-state.el to your load path. evil-lisp-state requires both evil, bind-map and smartparens to be installed.

Principle

To execute a command while in normal state, a leader key is used. The leader has to be defined with the function evil-lisp-state-leader. By default any command when executed sets the current state to lisp state.

Examples:

Key Bindings

Key Binding Function
. switch to lisp state
% evil jump item
: ex command
( insert expression before (same level as current one)
) insert expression after (same level as current one)
$ go to the end of current sexp
` k hybrid version of kill sexp (can be used in non lisp dialects)
` p hybrid version of push sexp (can be used in non lisp dialects)
` s hybrid version of slurp sexp (can be used in non lisp dialects)
` t hybrid version of transpose sexp (can be used in non lisp dialects)
0 go to the beginning of current sexp
a absorb expression
b forward barf expression
B backward barf expression
c convolute expression
ds delete symbol
Ds backward delete symbol
dw delete word
Dw backward delete word
dx delete expression
Dx backward delete expression
e unwrap current expression and kill all symbols after point
E unwrap current expression and kill all symbols before point
h previous symbol
H go to previous sexp
i switch to insert state
I go to beginning of current expression and switch to insert state
j next closing parenthesis
J join expression
k previous opening parenthesis
l next symbol
L go to next sexp
p paste after
P paste before
r raise expression (replace parent expression by current one)
s forwared slurp expression
S backward slurp expression
t transpose expression
u undo
U got to parent sexp backward
C-r redo
v switch to visual state
V switch to visual line state
C-v switch to visual block state
w wrap expression with parenthesis
W unwrap expression
y copy expression

Configuration

No default binding comes with the package, you have to explicitly bind the lisp state to a key with the function evil-lisp-state-leaderFor instance:

(evil-lisp-state-leader ", l")

Key bindings are set only for emacs-lisp-mode by default. It is possible to add major modes with the variable `evil-lisp-state-major-modes'.

It is also possible to define the key bindings globally by settingevil-lisp-state-global to t. In this case `evil-lisp-state-major-modes' has no effect.

If you don't want commands to enter in lisp state by default set the variableevil-lisp-state-enter-lisp-state-on-command to nil. Then use the . to enter manually in lisp state