From 45209275259c71b1f68cce4760747fa0ccc93b9b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 26 Nov 2022 23:19:43 +0000 Subject: paredit-kill: Tweak rule for adding space if kill-whole-line is t. For now, disable the yank part of the test -- with kill-whole-line, killing and then yanking is not always a noop and it's not clear making it a noop is the right approach. I don't use kill-whole-line so I'm not sure what expectations are and I'm reluctant to change it, except to fix obviously-wrong outcomes like (x|(y)) that should be (x| (y)). While here, document the effect of kill-whole-line on paredit-kill. --- paredit.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'paredit.el') 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 -- cgit v1.2.1