AmaiKinono / puni

Structured editing (soft deletion, expression navigating & manipulating) that supports many major modes out of the box.
GNU General Public License v3.0
403 stars 21 forks source link

Numeric arguments support for puni-slurp/barf #23

Closed daanturo closed 2 years ago

AmaiKinono commented 2 years ago

Thanks. However, I don't quite understand the necessity of numeric argument.

For slurp/barf, I think we usually

  1. slurp/barf once
  2. check if we've reached the desired state
  3. if not, go to step 1

Is it really common that we know the number of sexps to slurp/barf beforehand?

daanturo commented 2 years ago

While I also usually just slurp, barf one sexp at a time, prefix arg works quite well in tandem with relative line number mode when we have written a long list:

64 (do |)
 1 (something-a)
 2 (something-b)
 3 (something-c)
 4 (something-d)
 5 (something-e)
 6 (something-f)
 7 (something-g)
 8 (something-h)
 9 (something-i)

Then decide to wrap the list by slurping. Or do the opposite: release them from the current sexp by barfing.

64 (do |
 1   (something-a)
 2   (something-b)
 3   (something-c))

In those cases, having prefix numeric arguments is really helpful

(Also after using evil for some time, the others users (I think) and I find the concept of numeric prefix quite ingrained.)

Further discussion: if prefix numbers get accepted, how should we act when they are negative?

Forparedit the opposite of forward-slurp is forward-barf, while for smartparens it's backward-slurp, both are reasonable at the same time a bit confusing.

IMO we ought to just no-op when a negative argument is passed, that will greatly simplify the added code.

AmaiKinono commented 2 years ago

Ah, that makes much sense. I don't use line number (or evil) so I didn't realize it's convenient.

if prefix numbers get accepted, how should we act when they are negative...

I'd say you can do whichever you like, or just leave it until some user tell us about their preference.

AmaiKinono commented 2 years ago

Thanks!