Lisp State

The lisp state commands are provided by the Evil Lisp State package.

Lisp state provides and Evil mode for structural editing Clojure code and for other lisps too. This mode provides a fast an convienient way to manipulate the structure of your Clojure whist keeping it valid (i.e avoiding unbalanced parenthesis)

When you are in Lisp State you do not need to use the leader key, you can use the character commands directly.

Using Lisp State

In a buffer containing a Clojure file, open the lisp-state using SPC k .

In Lisp state the window number has a pink background.

In the leader key, SPC, is not currently recongnised. However, you can use M-m for the Spacemacs menu

I am still learning lisp state myself, so in the mean time here is an interesting video from Spacemacs ABC

Moving around

lisp-state Description
j Next closing delimiter parenthesis
k Previous opening parenthesis
h Backward symbol
H Backward sexp
l Forward symbol
L Forward sexp

Lisp State Commands

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

To execute a command while in normal state, a leader key is used. By default any command when executed sets the current state to lisp state.

Examples:

  • to slurp three times while in normal state: 3 s
  • to wrap a symbol in parenthesis then slurping two times: w 2 s

Key Bindings

Keybindings from the original lisp-state mode

bindings need to be checked that they are available in Spacemacs and also put into their own sections

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

Manual Configuration (optional)

Spacemacs binding comes with the package, you have to explicitly bind the lisp state to a key with the function evil-lisp-state-leader For instance:

(evil-lisp-state-leader ", SPC k")

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 setting evil-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 variable evil-lisp-state-enter-lisp-state-on-command to nil. Then use the . to enter manually in lisp state

results matching ""

    No results matching ""