summaryrefslogtreecommitdiff
path: root/paredit.el
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2011-05-08 17:56:37 +0000
committerTaylor R Campbell <campbell@mumble.net>2011-05-08 17:56:37 +0000
commit6f2677b1a97e4d0a6e0e823eed9cd714ba700266 (patch)
tree6995fd3ac9bb29117cb09601728f8ae7f67132c6 /paredit.el
parentfc7c6aabb6d9efa5aa11dc036cfd97519a3abd48 (diff)
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
Diffstat (limited to 'paredit.el')
-rw-r--r--paredit.el18
1 files changed, 13 insertions, 5 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))