summaryrefslogtreecommitdiff
path: root/paredit.el
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2013-07-09 19:21:12 +0000
committerTaylor R Campbell <campbell@mumble.net>2013-07-09 19:21:12 +0000
commit5114a626d0ee62d4afb10633df1dad934b793e13 (patch)
treec86a1eb32cc4da014121cc41e751f9ceac3e3cf4 /paredit.el
parentf8bf24c8fb45bf0b9919be61ee9b30caae53d782 (diff)
If in a string, slurp into the enclosing list if necessary.
Diffstat (limited to 'paredit.el')
-rw-r--r--paredit.el22
1 files changed, 20 insertions, 2 deletions
diff --git a/paredit.el b/paredit.el
index 6f88eef..225dc05 100644
--- a/paredit.el
+++ b/paredit.el
@@ -2233,7 +2233,16 @@ If in a string, move the opening double-quote forward by one
(cond ((paredit-in-comment-p)
(error "Invalid context for slurping S-expressions."))
((paredit-in-string-p)
- (paredit-forward-slurp-into-string))
+ ;; If there is anything to slurp into the string, take that.
+ ;; Otherwise, try to slurp into the enclosing list.
+ (if (save-excursion
+ (goto-char (paredit-enclosing-string-end))
+ (paredit-handle-sexp-errors (progn (forward-sexp) nil)
+ t))
+ (progn
+ (goto-char (paredit-enclosing-string-end))
+ (paredit-forward-slurp-into-list))
+ (paredit-forward-slurp-into-string)))
(t
(paredit-forward-slurp-into-list)))))
@@ -2318,7 +2327,16 @@ If in a string, move the opening double-quote backward by one
(cond ((paredit-in-comment-p)
(error "Invalid context for slurping S-expressions."))
((paredit-in-string-p)
- (paredit-backward-slurp-into-string))
+ ;; If there is anything to slurp into the string, take that.
+ ;; Otherwise, try to slurp into the enclosing list.
+ (if (save-excursion
+ (goto-char (paredit-enclosing-string-start))
+ (paredit-handle-sexp-errors (progn (backward-sexp) nil)
+ t))
+ (progn
+ (goto-char (paredit-enclosing-string-start))
+ (paredit-backward-slurp-into-list))
+ (paredit-backward-slurp-into-string)))
(t
(paredit-backward-slurp-into-list)))))