expez / evil-smartparens

Evil integration for Smartparens
GNU General Public License v3.0
134 stars 17 forks source link

evil-sp-delete-line behavior #23

Closed cmccloud closed 9 years ago

cmccloud commented 9 years ago

Using spacemacs, with evil, smart-parens, smart-parens-strict, and evil-smartparens enabled in an emacs-lisp buffer

(defun test-sexp ()
   |(sexp-A
     (A-first-child))
    (sexp-B)
    (sexp-C
     (C-first-child)
     (C-second-child)))

My expectation is that "D" should delete sexp-A and it's child, but leave sexp-B and sexp-C, instead D results in:

(defun test-sexp ()
    |)

Is this intended? Others are noticing the same behavior, the discussion is located syl20bnr/spacemacs#2747

justbur commented 9 years ago

So the reason I see is here https://github.com/expez/evil-smartparens/blob/master/evil-smartparens.el#L80-L81. D goes up one sexp then backwards and down to find the deletion point.

justbur commented 9 years ago

I would think a simple sp-forward-sexp would work here, but I'm probably not appreciating all of the possibilities.

expez commented 9 years ago

The readme is actually out of sync. I try to do readme driven development and this is what I first wanted, so I get the confusion. The docstring is correct, though, and says: "Emulate `sp-kill-sexp' with universal prefix."

In the example in the OP I usually do da(, but you could also call sp-kill-sexp.

My goal was to make something that was greater than the sum of its parts (evil and smartparens) and not just duplicate existing behavior across new keybindings.

expez commented 9 years ago

There's also evil-cleverparens to consider, it's quite similar to this package and the author is a great guy.

cmccloud commented 9 years ago

thanks!

expez commented 9 years ago

To make it clear why I prefer to have it this way, and not like sp-kill-sexp:

(defun test-sexp () |(sexp-A (A-first-child)) (sexp-B) (sexp-C (C-first-child) (C-second-child)))

If I now it D I get:

(defun test-sexp () |)

which is quite handy!

justbur commented 9 years ago

@expez Just a thought. In evil-sp--get-endpoint-for-sp-kill-sexp, what if this were the rule?

  1. Move to the eol
  2. up a sexp
  3. backwards and down a sexp

I think that handles both cases.

justbur commented 9 years ago

Never mind. That would be weird in this case

  | (a (b 
)
)
cmccloud commented 9 years ago

@expez I agree, and definitely see the usefulness here.

expez commented 9 years ago

You can also delete the sexp in the OP by doing d<sp-forward-sexp>. With the keybindings I've set up for myself this equates to dM-l. This variant also supports prefixes so by doing 2dM-l I can delete the following two sexps. Isn't it lovely when commands compose in this way? :)