abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 130 forks source link

lispy-backward-kill-word does not balance parens, quotes, brackets, or braces #584

Open rgkirch opened 3 years ago

rgkirch commented 3 years ago
[[:a]
 ]

If I have the point on the second line after the space and before the close bracket then lispy-backward-kill-word will create

[[:]

another example

[{:a :b}
 ]

gives

[{:a :]

I'm on the latest emacs in master c24766c4d59bc7d9f583f299b1558e2356fba933 from Tue Mar 23 and the latest from lispy 38a7df4cbb16cfe3d62dc8ea98b50e2d9a572e58 Thu Jan 21.

ComedyTomedy commented 3 years ago

It affects anything where point begins after a space. So another example:

(((:x))) |

gives

(((:x

The problem is the "else" section of:

(if (lispy-looking-back "\\_<\\s_+") 
  ...
  (backward-kill-word 1)

That final line should just fall through to the following (if (setq bnd (lispy--bounds-string)) ... block.

But that whole function is too hairy to understand; it's clearly grown over time. So this part… deletes a single backslash after the killed word, but only if point is in a string and immediately following a space (?!) If I tried to fix it I'd be too afraid of breaking something else.