mikavilpas / evil-lispy

precision Lisp editing with Evil and Lispy
79 stars 5 forks source link

Need a natural way of slurping #7

Open mikavilpas opened 8 years ago

mikavilpas commented 8 years ago

Here is a sample use case:

I start with this (point is at |):

(some-function-call "hello")|

Now I want to create a let form and give the return value a name. So I start to write this:

(let ((return-value-of-function|)))(some-function-call "hello")

Now I would obviously like to have the function call after the variable name, so in other words I want to slurp three times. Here is the end result:

(let ((return-value-of-function (some-function-call "hello"))))

Question: what is a natural way of doing this?

mikavilpas commented 8 years ago

Also: have this in a FAQ, others might wonder this too.

sooheon commented 8 years ago

I have three patterns:

  1. Start out with a wrapped sexp with 2( in lispy. If it's multiple nested, it's not as effective
  2. From:
(let ((return-value-of-function|)))(some-function-call "hello")

Just call slurp the paredit way (C-)) three times. Even though it's a chord, it's simple and easy.

  1. From same point as above, ESC > > >, using evil cleverparens binds.
mikavilpas commented 8 years ago

These are good suggestions. I've been using the 2nd way myself, but the third I didn't know about. It's definitely more evil-like.

At the moment I think a paredit-like binding could be a good compromise between comfort and "the evil way". But I'll have to look at evil cleverparens as well, to see if they have more good ideas that could be used.

sooheon commented 8 years ago

Ah there's another way which I forgot, but I actually use a bit, which is M-( mapping for lispy-wrap-round. Successive calls to this each time you'd open a paren gives the result we'd want.