Skip to content

Commit

Permalink
Fix lispy-backward-kill-word delimiter-balancing
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
paulapatience committed Feb 4, 2022
1 parent 80a4f6e commit 7b22379
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lispy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,9 @@ If position isn't special, move to previous or error."
(lispy-dotimes arg
(when (lispy--in-comment-p)
(skip-chars-backward " \n"))
(if (memq (char-syntax (char-before))
'(?w ?_ ?\s))
(if (and (memq (char-syntax (char-before))
'(?w ?_ ?\s))
(lispy-looking-back "\\(?:\\sw\\|\\s_\\)\\s-+"))
(if (lispy-looking-back "\\_<\\s_+")
(delete-region (match-beginning 0)
(match-end 0))
Expand Down

0 comments on commit 7b22379

Please sign in to comment.