Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rgkirch opened this issue Mar 27, 2021 · 1 comment · May be fixed by #622
Open

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

rgkirch opened this issue Mar 27, 2021 · 1 comment · May be fixed by #622

Comments

@rgkirch
Copy link

rgkirch commented Mar 27, 2021

[[: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 38a7df4 Thu Jan 21.

@ComedyTomedy
Copy link

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.

paulapatience added a commit to paulapatience/lispy that referenced this issue Feb 4, 2022
* lispy.el (lispy-backward-kill-word): When looking back at ") ", we
would take the first if's then branch because the char before is
whitespace. However, this branch would call backward-kill-word which
doesn't skip over delimiters. Prevent this situation by taking the then
branch only if we're looking back at a word or symbol constituent
followed by whitespace, in which case backward-kill-word behaves
correctly. If we're not looking back at such a pattern, we end up in the
else branch, which does skip over delimiters.

Fixes abo-abo#584
@paulapatience paulapatience linked a pull request Feb 4, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants