abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 132 forks source link

What is the "lispy" way to insert at beginning/end of sexp? #566

Open bpstahlman opened 3 years ago

bpstahlman commented 3 years ago

Unless I've overlooked something, there doesn't appear to be an easy way to begin inserting something at the beginning/end of a list. With cursor in special position as indicated, what is the idiomatic lispy way to insert 4 at the end of the following list? |(foobar 1 2 3)

I realize I could hit d \C-b 4, but that feels awkward for such a common use case. And it isn't just that one of the keys is a key-chord... Having to "back up" like that just feels forced and unnatural, like a violation of list structure. Is there something analogous to I or A in Vim for inserting at the beginning or end of a sexp?

rprimus commented 3 years ago

Sun Feb 7 05:48:11 GMT 2021

|(foobar 1 2 3)

In the above scenario:

a d <SPC> 4

Key:

a     : `special-lispy-ace-symbol`
d     :  choose letter representing the last symbol: 3
<SPC> : `lispy-space`
4     : self-insert 4
bpstahlman commented 3 years ago

Ah. I suppose I could also have done 4 m <SPC> 4. I think one of the biggest adjustments for someone coming to lispy (or emacs, for that matter) from Vim is thinking of the visual selection/region as an integral part of an effective text editing workflow. Notwithstanding, I do think dedicated lispy commands for insert-at-bol and insert-at-eol would be useful...

...Especially since there doesn't really seem to be a natural way to insert at the beginning of the sexp. If I use m i to mark the car, subsequently hitting <SPC> moves point past the car, even if I've used d to position point at the start of the car before hitting <SPC>. With point on the open bracket, I can hit \C-f to move inside the list and insert a new car, but this just feels wrong, as though I'm violating list structure by treating the paren as text.

yuhan0 commented 3 years ago

You may be interested in https://github.com/noctuid/lispyville/, the insert at beginning/end of sexp commands are simply M-i/M-a with the additional-insert key theme activated.

bpstahlman commented 3 years ago

Thanks. I'm familiar with Lispyville, but had been considering disabling it and using only Lispy. Under the new setup, I'd use a key-chord to toggle between evil modes for text editing and emacs mode for Lispy commands. The conclusion I'm coming to is that Lispyville really does add a lot of useful functionality that I'd rather not do without...