noctuid / lispyville

lispy + evil = lispyville

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can lispyville-< drag cursor back if closing paren passes over it?

sooheon opened this issue · comments

Say you have the following, with the cursor before :init

(defun soo-parens/init-lispyville ()
  (use-package lispyville
    :diminish lispyville-mode
    |:init
    (add-hook 'lispy-mode-hook #'lispyville-mode)
    (setq lispyville-key-theme '(operators
                                 (additional-movement normal)
                                 (escape insert hybrid emacs)
                                 slurp/barf-cp)
          lispyville-motions-put-into-special t)))

< three times puts closing paren at end of line 3, and cursor gets pushed to bol 4. I can't directly reverse the last < motion with >, I need to now move cursor up a line. If by muscle memory you press >, you will slurp the next top level sexp. Since calling < from the middle of a sexp is clearly acting on the closing paren, when the < operation takes the closing paren past the cursor, instead of leaving cursor point outside of sexp it was operating on, can it follow the closing paren? Then all such calls should be nicely reversible, and make more sense imo. This can be a customisation, of course.

I think I'll keep the current behavior as the default (which is how evil-cleverparens acts as well) and add this as an option.

For reversal you can always just undo, but I think you're right that it would be more consistent to allow reversal. Also, I think this could be useful/cosisent for more than just reversal. For example, if you wanted to keep slurping in the scope you started out with, 4< doesn't have the same behavior as <<<<.

Thanks for the suggestion.

On a side note, I like to diminish with shortcake diminish " 🍰". Or maybe that is better for lispy itself.

Okay it should be working with lispyville-barf-stay-with-closing true.

Haha shortcake is perfect for lispy, I'm going to have to use that :). Thanks for the quick feature!

Also, I noticed one other difference from evil-cp and paredit, which is calling slurp from within stacked up closing delims does not work. In the other packages, it slurps the outermost sexp.

e: actually, this seems like a saner default if you, like me, enjoy reversability; as automatically slurping the top-level sexp even from within many nested levels means you can't easily barf that back. Anyway, just a heads up

This is just how lispy does slurping, and I think it makes more sense. However, I've also sometimes wanted to slurp from within stacked delims and planned to add this functionality directly to lispy. I'm not sure what the best way to do this would be though. Originally I was thinking it should be an argument to lispy-slurp, but I'm not sure if there's a good way to make room for it. -2 and less are free, but -1 isn't. M-- and M--1 can be differentiated between though, so maybe that would be the way to go.