willghatch / emacs-on-parens

smartparens wrapper to fit with evil-normal-state
10 stars 2 forks source link

Use C-u for "infinity" prefix #3

Open PythonNut opened 8 years ago

PythonNut commented 8 years ago

I'm not sure if this is possible, but if it is, I think it would be great.

smartparens defines a C-u prefix to mean infinity (see the documentation here for more info.)

So, for example (let the character before the | be the character the cursor is on) let's that with this:

(|this is a test involving smartparens)

C-u M-x sp-kill-sexp RET produces:

()

C-u M-x on-parens-kill-sexp RET produces:

(| involving smartparens)

This can be ridiculously handy, and I'd love to see support in on-parens.

Likewise C-u C-u is meant to mean "operate on the enclosing expression," which is definitely handy as well.

willghatch commented 8 years ago

I wouldn't mind having this feature (correct smart-parens style prefix handling), but it's unlikely that I'll get around to it any time soon. For your specific use case, I always use di), using evil's support for nice text object manipulation. In fact, I never even use on-parens-kill-sexp -- adding it just seemed fun the day I made the package. It is really a pass-through to sp-kill-sexp... So I guess one fix would just be to pass arguments through correctly. But frankly I should probably just take on-parens-kill-sexp out.

When I made this package, it was really just a minimal hack to be able to use smartparens with evil mode, and have the movements and barf/slurp work the way I felt they should with evil-normal-state (if you look at the repo history, basically everything was written in one day, just because I really wanted to start using smartparens). I would really like to go back and improve a lot of things about the package, but I have too many other things to do, so I probably won't soon.

I appreciate you opening issues, though. I hope you enjoy the functionality that is there, at least.

PythonNut commented 8 years ago

For your specific use case, I always use di), using evil's support for nice text object manipulation.

The infinite prefix also comes in handy when you aren't at the beginning of the sexp.

(setq |a 1
      b 3
      c 4)

C-u M-x sp-kill-sexp RET produces:

(setq|)

It's true that you could sometimes do dt) (t may not scan across lines), but smartparens is cool because it's more generic and can operate on many different type of delimiters and expressions.

When I made this package, it was really just a minimal hack to be able to use smartparens with evil mode, and have the movements and barf/slurp work the way I felt they should with evil-normal-state (if you look at the repo history, basically everything was written in one day, just because I really wanted to start using smartparens). I would really like to go back and improve a lot of things about the package, but I have too many other things to do, so I probably won't soon.

Absolutely understood. I don't expect little niggles in an emacs package to be anyone's top priority. :)

I appreciate you opening issues, though.

Thanks for making this clear. Sometimes I feel a little annoying for filing bugs. I think there's at least one more discrepancy I found, but it'll take a little more investigation.

I hope you enjoy the functionality that is there, at least.

Oh yes, it's pretty great to see smartparens and evil finally getting along. I've been using the two since practically day one and I really appreciate your taking the time to solve this!

willghatch commented 8 years ago

For this use case (killing to the end of the s-exp), I use deg, which makes sense if you know that I have eg bound to on-parens-up-sexp-end. It works beautifully. Killing to the beginning of the s-exp with on-parens-up-sexp isn't so great as it goes one character too far... fixing the one-offs with evil operators is probably the next thing I'll actually fix with this package, when I get around to it.

PythonNut commented 8 years ago

For this use case (killing to the end of the s-exp), I use deg, which makes sense if you know that I have eg bound to on-parens-up-sexp-end. It works beautifully.

Yes, indeed it does. Thanks for the tip!

Fixing the one-offs with evil operators is probably the next thing I'll actually fix with this package, when I get around to it.

Indeed, that would be great.