[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 6f2677b 148/224: Tweak `paredit-convolute-sexp' a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 6f2677b 148/224: Tweak `paredit-convolute-sexp' a little and add some tests for it. |
Date: |
Sat, 7 Aug 2021 09:22:38 -0400 (EDT) |
branch: elpa/paredit
commit 6f2677b1a97e4d0a6e0e823eed9cd714ba700266
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Tweak `paredit-convolute-sexp' a little and add some tests for it.
Ignore-this: 61dbcae678e46499873949c68cc78fbf
Thanks to Leo Liu for the nudge about some of its rough corners (and
for pointing out the screw case recently fixed). It's still pretty
rough around the edges.
darcs-hash:20110508175637-00fcc-265b11688b79f4d01211d798fec7e9dd3fe4748f
---
paredit.el | 18 +++++++++++++-----
test.el | 10 +++++++++-
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/paredit.el b/paredit.el
index c8b82ca..d137743 100644
--- a/paredit.el
+++ b/paredit.el
@@ -423,7 +423,7 @@ Paredit behaves badly if parentheses are unbalanced, so
exercise
"|body"))
("M-?" paredit-convolute-sexp
("(let ((x 5) (y 3)) (frob |(zwonk)) (wibblethwop))"
- "|(frob (let ((x 5) (y 3)) (zwonk) (wibblethwop)))"))
+ "(frob |(let ((x 5) (y 3)) (zwonk) (wibblethwop)))"))
"Barfage & Slurpage"
(("C-)" "C-<right>")
@@ -2124,6 +2124,9 @@ If the point is on an S-expression, such as a string or a
symbol, not
(let* ((indent-start (point))
(indent-end (save-excursion (insert sexps) (point))))
(indent-region indent-start indent-end nil)))))
+
+;;; The effects of convolution on the surrounding whitespace are pretty
+;;; random. If you have better suggestions, please let me know.
(defun paredit-convolute-sexp (&optional n)
"Convolute S-expressions.
@@ -2134,7 +2137,7 @@ With a prefix argument N, move up N lists before
wrapping."
(interactive "p")
(paredit-lose-if-not-in-sexp 'paredit-convolute-sexp)
;; Make sure we can move up before destroying anything.
- (save-excursion (backward-up-list) (backward-up-list))
+ (save-excursion (backward-up-list n) (backward-up-list))
(let (open close) ;++ Is this a good idea?
(let ((prefix
(let ((end (point)))
@@ -2146,12 +2149,17 @@ With a prefix argument N, move up N lists before
wrapping."
(setq close (char-before))
(backward-delete-char 1))
(setq open (char-after))
- (delete-region (point) end)))))
+ (delete-region (point) end)
+ ;; I'm not sure this makes sense...
+ (if (not (eolp)) (just-one-space))))))
(backward-up-list n)
(paredit-insert-pair 1 open close 'goto-char)
(insert prefix)
- (backward-up-list)
- (paredit-ignore-sexp-errors (indent-sexp)))))
+ ;; I'm not sure this makes sense either...
+ (if (not (eolp)) (just-one-space))
+ (save-excursion
+ (backward-up-list)
+ (paredit-ignore-sexp-errors (indent-sexp))))))
(defun paredit-splice-string (argument)
(let ((original-point (point))
diff --git a/test.el b/test.el
index 4d83010..3bb389a 100644
--- a/test.el
+++ b/test.el
@@ -359,4 +359,12 @@ Four arguments: the paredit command, the text of the buffer
("(paredit-canary| ;\n)\n(lose)")))
(paredit-test 'paredit-convolute-sexp
- '(("(let ((x 5) (y 3)) |(frob (zwonk)) (wibblethwop))" error)))
+ '(("(let ((x 5) (y 3)) |(frob (zwonk)) (wibblethwop))" error)
+ ("(let ((x 0)) (progn| x))" "(progn |(let ((x 0)) x))")
+ ;; Should the space be left inside the LET? In both cases?
+ ("(let ((x 0)) (progn| ))" "(progn |(let ((x 0)) ))")
+ ("(let ((x 0)) (progn|))" "(progn |(let ((x 0)) ))")
+ ;; One space should definitely be left between A and B here.
+ ("(let ((x 0)) a (progn|) b)" "(progn |(let ((x 0)) a b))")
+ ("(let ((x 0)) a (progn| ) b)" "(progn |(let ((x 0)) a b))")
+ ("(let ((x 0)) a (progn |) b)" "(progn |(let ((x 0)) a b))")))
- [nongnu] elpa/paredit 8ee8f13 118/224: Fix `paredit-insert-pair' when buffer ends with no-newline comment., (continued)
- [nongnu] elpa/paredit 8ee8f13 118/224: Fix `paredit-insert-pair' when buffer ends with no-newline comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit fc78011 121/224: Tweak `paredit-check-region' and `paredit-region-ok-p'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 621be23 124/224: Add some tests for recent changes to deletion and killing commands., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit fac925d 125/224: Tweak safe region deletion., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 8d87576 129/224: Fix logic in checking region deletion across comment boundaries., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4723fb3 132/224: Add and fix some tests for `(' and `)' while in a character literal., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5558fd0 137/224: Make `paredit-in-char-p' work recursively., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 88a5cf7 139/224: Be explicit about Transient Mark Mode in `paredit-wrap-*' tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d80a9db 141/224: Fail early in `paredit-convolute-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2ec6000 145/224: Fix error message in `paredit-test'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6f2677b 148/224: Tweak `paredit-convolute-sexp' a little and add some tests for it.,
ELPA Syncer <=
- [nongnu] elpa/paredit d54ea28 149/224: Add a trivial shell script to generate paredit.html., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 540bc9c 153/224: Remove unnecessarily nasty text about reporting bugs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b02f509 156/224: New file NEWS from paredit.release., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b647a1a 158/224: Bump copyright year on test.el to 2013., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f25cd3b 159/224: Add a zillion paredit-kill tests. Fix a tiny bug they revealed., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 460254d 162/224: Fix paredit-doublequote inside a string escape., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit db82936 163/224: Make `paredit-forward' and `paredit-backward' move out of strings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 18cf19f 164/224: Implement `paredit-preserving-column'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5840f55 165/224: Preserve column better in `paredit-join'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 9838fe2 174/224: In check.sh, use $EMACS if set, defaulting to `emacs'., ELPA Syncer, 2021/08/07