summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--paredit.el17
-rw-r--r--test.el27
3 files changed, 27 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index 59659bb..29f9ca8 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,11 @@ https://paredit.org
Latest release: https://paredit.org/paredit.el
Current development version: https://paredit.org/paredit-beta.el
+** Version 27 (beta)
+
+*** Improved some edge cases in paredit-kill with kill-whole-line enabled.
+**** Many other edge cases are slightly broken; patches welcome!
+
** Version 26 -- 2022-11-26
Minor bug fix release, mainly to set a new branch scheme:
diff --git a/paredit.el b/paredit.el
index 8522421..ea14a15 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1509,7 +1509,12 @@ On a line with no S-expressions on it starting after the point or
within a comment, act exactly as `kill-line'.
Otherwise, kill all S-expressions that start after the point.
With a `C-u' prefix argument, just do the standard `kill-line'.
-With a numeric prefix argument N, do `kill-line' that many times."
+With a numeric prefix argument N, do `kill-line' that many times.
+
+If `kill-whole-line' is true, kills the newline character and
+ indentation on the next line as well.
+In that case, ensure there is at least one space between the
+ preceding S-expression and whatever follows on the next line."
(interactive "P")
(cond (argument
(kill-line (if (integerp argument) argument 1)))
@@ -1623,13 +1628,9 @@ With a numeric prefix argument N, do `kill-line' that many times."
;; Insert a space to avoid invalid joining if necessary.
((let ((syn-before (char-syntax (char-before)))
(syn-after (char-syntax (char-after))))
- (or (and (eq syn-before ?\) ) ; Separate opposing
- (eq syn-after ?\( )) ; parentheses,
- (and (eq syn-before ?\" ) ; string delimiter
- (eq syn-after ?\" )) ; pairs,
- (and (memq syn-before '(?_ ?w)) ; or word or symbol
- (memq syn-after '(?_ ?w))))) ; constituents.
- (insert " "))))
+ (and (memq syn-before '(?\) ?\" ?_ ?w))
+ (memq syn-after '(?\( ?\" ?_ ?w))))
+ (save-excursion (insert " ")))))
;;;;; Killing Words
diff --git a/test.el b/test.el
index 9e1b50c..ca85187 100644
--- a/test.el
+++ b/test.el
@@ -752,13 +752,14 @@ Four arguments: the paredit command, the text of the buffer
(";f\n(b\n z|)\n" ";f\n(b\n z|)\n")))
(let ((kill-whole-line t))
- (paredit-test (defun paredit-test-kill ()
+ (paredit-test (defun paredit-test-kill-whole-line ()
(interactive)
- ;; Horrible kludge. Do it once, and then yank to make
- ;; sure we get back what we expect. Then do it again,
- ;; to get the effects on the buffer the automatic test
- ;; framework will check.
- (save-excursion
+ ;; For now the check to see that we yanked the
+ ;; correct string is disabled, because it isn't quite
+ ;; right: with kill-whole-line enabled, sometimes it
+ ;; inserts an extra space to avoid joining two
+ ;; expressions.
+ '(save-excursion
(let ((kill-ring nil))
(let ((text (buffer-string)))
(call-interactively 'paredit-kill)
@@ -819,9 +820,8 @@ Four arguments: the paredit command, the text of the buffer
("\"\n\"\n|" error)
("|(a (b) (c)\n (d) (e))" "|" error)
- (xfail
- "(a| (b) (c)\n (d) (e))"
- "(a| (d) (e))"
+ ("(a| (b) (c)\n (d) (e))"
+ "(a| (d) (e))"
"(a|)"
"(a|)")
(xfail
@@ -885,7 +885,7 @@ Four arguments: the paredit command, the text of the buffer
("|(a ((b) (c)\n (d) (e)) (f))" "|" error)
(xfail "(|a ((b) (c)\n (d) (e)) (f))" "(| (f))" "(|)" "(|)")
- (xfail "(a| ((b) (c)\n (d) (e)) (f))" "(a| (f))" "(a|)" "(a|)")
+ ("(a| ((b) (c)\n (d) (e)) (f))" "(a| (f))" "(a|)" "(a|)")
(xfail "(a |((b) (c)\n (d) (e)) (f))" "(a | (f))" "(a |)" "(a |)")
(xfail
"(a (|(b) (c)\n (d) (e)) (f))"
@@ -968,8 +968,7 @@ Four arguments: the paredit command, the text of the buffer
"(| (f))"
"(|)"
"(|)")
- (xfail
- "(a| \"(b) (c)\n ) { ;;;; \n\n\n(d)( (e);\" (f))"
+ ("(a| \"(b) (c)\n ) { ;;;; \n\n\n(d)( (e);\" (f))"
"(a| (f))"
"(a|)"
"(a|)")
@@ -1006,7 +1005,7 @@ Four arguments: the paredit command, the text of the buffer
"(a \"(b) (c)\n ) { ;;;; \n\n\n|\" (f))")
("|x(\n)(z)" "|(z)" "|" error)
- ("x|(\n)(z)" "x|(z)" "x|" error)
+ ("x|(\n)(z)" "x| (z)" "x|" error)
("x(|\n)(z)" "x(|)(z)" "x(|)(z)")
(xfail "x(\n|)(z)" "x(\n|)(z)")
("x(\n)|(z)" "x(\n)|" error)
@@ -1015,7 +1014,7 @@ Four arguments: the paredit command, the text of the buffer
("x(\n)(z)|" error)
("|x\"\n\"(z)" "|(z)" "|" error)
- ("x|\"\n\"(z)" "x|(z)" "x|" error)
+ ("x|\"\n\"(z)" "x| (z)" "x|" error)
("x\"|\n\"(z)" "x\"|\"(z)" "x\"|\"(z)")
("x\"\n|\"(z)" "x\"\n|\"(z)")
("x\"\n\"|(z)" "x\"\n\"|" error)