diff options
author | Taylor R Campbell <campbell@mumble.net> | 2013-07-09 19:21:12 +0000 |
---|---|---|
committer | Taylor R Campbell <campbell@mumble.net> | 2013-07-09 19:21:12 +0000 |
commit | 5114a626d0ee62d4afb10633df1dad934b793e13 (patch) | |
tree | c86a1eb32cc4da014121cc41e751f9ceac3e3cf4 /paredit.el | |
parent | f8bf24c8fb45bf0b9919be61ee9b30caae53d782 (diff) |
If in a string, slurp into the enclosing list if necessary.
Diffstat (limited to 'paredit.el')
-rw-r--r-- | paredit.el | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -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))))) |