noctuid / lispyville

lispy + evil = lispyville

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lispy-pair with positive numeric arg doesn't wrap in evil-normal state

bpstahlman opened this issue · comments

Consider the following sexp:
'(a b c d e f)
In evil-insert state, with point before symbol d, I can do C-u 3 ( to wrap 3 sexps like so:
'(a b c (d e f))

But it doesn't work in evil-normal state. Is that by design? Is there a configuration that would permit this sort of wrapping in evil-normal state as well?

Thanks,
Brett S.

lispy-pair is not aware of evil at all, but I don't think that should be a problem. I normally only use it in insert state, but it works for me in normal state as well. Make sure that you are binding lispy-parens and not lispy-pair directly:

(evil-define-key 'normal lispyville-mode-map
  "(" #'lispy-parens)

If that's not the problem, let me know what happens when you try this.

If you want this specifically for wrapping, I could maybe provide a command that wraps one sexp by default (or acts like lispy-parens-auto-wrap) and doesn't insert the space before the opening delimiter.

(evil-define-key 'normal lispyville-mode-map
  "(" #'lispy-parens)

That works, but if evil's evil-move-cursor-back option is at its default value of t, it isn't possible to jump past a parenthesized sexp at the end of a line (since the "move back" effectively puts point inside the sexp moved past), and this can result in a premature end to the traversal. Now that I know about evil-move-cursor-back, I'm considering setting it to nil, as I suspect the non-default setting would be less likely to cause breaking interactions with non-evil packages.

I haven't used Lispy/Lispyville long enough to have solidified my usage patterns yet, but I suspect that wrapping a non-parenthesized sexp is something I might want to do in normal mode. Of course, it's not hard to enter insert mode or mark the sexp, so it's just a nice-to-have...

Thanks for all your help. I'm sure I'll have more questions as I continue to use Lispy and Lispyville.

I'm not sure I understand what you mean. The point is only moved back when exiting insert state, so it shouldn't affect any of the provided commands. If you jump to a closing paren at the end of then line, and then exit insert state, you'll still be on the paren. Personally I see this behavior as a non-intuitive workaround for a vim limitation and set evil-move-cursor-back to nil.

Adding wrap commands was planned from the start. It's probably one of the more useful additions, so I'll work on it next when I have the time.

On a side note, you mentioned that you like lispy-backbut wished C-i behavior was also present. I could add an option to have all the points lispy saves added to the evil jump list as well. Would you find that useful? Of course, the jump list doesn't store regions/selections, but I could potentially add that functionality as another option.

I'm not sure I understand what you mean. The point is only moved back when exiting insert state, so it shouldn't affect any of the provided commands. If you jump to a closing paren at the end of then line, and then exit insert state, you'll still be on the paren.

Odd. I was commenting on a problem with C-M-f and Lispyville's L and H commands in normal state: specifically, they don't work as expected when evil-move-cursor-back is at its default value of t, since it's impossible for point to move past a closing paren at the end of the line in evil-normal-state. Not sure why I added it to that comment. I'd been talking about C-M-f on another issue, and perhaps I noticed it while looking into the wrap stuff. Sorry for the confusion...

The C-i behavior would definitely be nice to have (especially if it remembered the regions). Personally, I'm more likely to use a back button with reckless abandon if I know I have a forward button too... ;-) More wrapping functionality would be nice as well, though the current state of affairs isn't too bad, now that I know I can mark with v or V, then hit (. Were you thinking of adding the ability to wrap the current sexp (or multiple sexp's with a count) without marking first? I just noticed that v and V don't accept counts. That actually could be a useful feature: i.e., if I wanted to mark 3 sexps after point, I can always use Lispy's mark to mark the first one in the range, then slurp in the rest, but that's a fair number of keystrokes. Lispyville's v and V are so handy in evil-normal-state, it would be nice to be able simply to do (e.g.) 3 v. I notice lispy's M-m doesn't appear to support a count either. Ah well. Just thinking out loud...

Ah yes, I thought myabe there was some problem with the wrapping. I think that should only be an issue for forward-sexp. I can mention it in the readme.

Were you thinking of adding the ability to wrap the current sexp (or multiple sexp's with a count) without marking first?

Yes, the wrap commands will wrap the current sexp by default.

For lispy-mark-symbol/M-m it could make sense to support a count that would slurp count -1 times. It would make the most sense to add this functionality directly to lispy. Maybe make an issue suggesting it there.

Sounds good. Would be nice if the wrap commands supported a count as well, just like the existing lispy wrap commands.

And yes, I agree that lispy-mark-symbol is the most natural place for the mark count to be implemented.