expez / evil-smartparens

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

Unexpected register behavior with full line commands (dd cc yy) #40

Closed mattt-b closed 7 years ago

mattt-b commented 7 years ago

When performing full line commands like dd, cc, and yy, the value that is placed into the register is inconsistent depending on whether there was 'extra' data on the line.

(+
  |(+ 1 2)
  (+ 3 4))

In this situation dd will place (+ 1 2)^J in the register so it will be pasted on a newline when hitting p.

(+
  (+ 1 2)
  |(+ 3 4))

In this situation dd will not add the ^J in the register leading to unexpected results when hitting p afterwards.

expez commented 7 years ago

Hi, thanks for reaching out!

This is working as intended.

In the first example a whole line is killed, so the register contains a newline.

In the second example only (+ 3 4) is killed and the remaining )^J is left in the buffer and thus never enters the register.

The whole point of evil-smartparens is to leave the delimiters balanced, so in the second example we can't include the remaining characters as that would leave the buffer with a ( without a matching ).

I realize this changes the semantic of the operation from 'act on the whole line' to 'act on as much of the line as possible', but that's what I want 100% of the time when I'm coding lisp. If you only want it 99% of the time, then you can use the escape hatch (bound to o in the visual map by default) to perform unbalancing operations on your buffer.

mattt-b commented 7 years ago

I'm not expecting it to unbalance, I would just expect a ^J to always be placed on the end of any line wise operation. So in my second example I would expect the register to be (+ 3 4)^J, not (+ 3 4))^J. Using the escape hatch will leave things unbalanced.

I respect that you like the way this works, just wanted to make sure you understood what I was getting at.

For anyone bothered by this issue who comes across this, I have found the evil-cleverparens package to work as described in the initial post.