summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2010-09-18 18:16:20 +0000
committerTaylor R Campbell <campbell@mumble.net>2010-09-18 18:16:20 +0000
commit5bfc873de956a47ace140ee52919f6d1a9bc5a0f (patch)
treedf9a8aa14a5e37881e8cbbe3bef7efe35a1a6d1c
parent7b318649a3c01c2fc078f2bc98b6d340b245dc68 (diff)
Fix `paredit-copy-as-kill' within strings.
Ignore-this: 231e8737beaee81622c52d580adad339 darcs-hash:20100918181620-00fcc-5774d34b56be2f3af88b6a75506da39927197baf
-rw-r--r--paredit.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/paredit.el b/paredit.el
index 59de8fc..58dbf0f 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1551,6 +1551,28 @@ With a numeric prefix argument N, do `kill-line' that many times."
(defun paredit-copy-as-kill ()
"Save in the kill ring the region that `paredit-kill' would kill."
(interactive)
+ (cond ((paredit-in-string-p)
+ (paredit-copy-as-kill-in-string))
+ ((paredit-in-comment-p)
+ (copy-region-as-kill (point) (point-at-eol)))
+ ((save-excursion (paredit-skip-whitespace t (point-at-eol))
+ (or (eolp) (eq (char-after) ?\; )))
+ ;** Be careful about trailing backslashes.
+ (save-excursion
+ (if (paredit-in-char-p)
+ (backward-char))
+ (copy-region-as-kill (point) (point-at-eol))))
+ (t (paredit-copy-sexps-as-kill))))
+
+(defun paredit-copy-as-kill-in-string ()
+ (save-excursion
+ (if (paredit-in-string-escape-p)
+ (backward-char))
+ (copy-region-as-kill (point)
+ (min (point-at-eol)
+ (cdr (paredit-string-start+end-points))))))
+
+(defun paredit-copy-sexps-as-kill ()
(save-excursion
(if (paredit-in-char-p)
(backward-char 2))