branch: elpa/paredit
commit 43bf81fec70052b0be37109e27f76e968bb982e8
Author: Taylor R Campbell <[email protected]>
Commit: Taylor R Campbell <[email protected]>

    Implement `paredit-copy-as-kill'.
    
    Saves to the kill ring the text of the region that `paredit-kill'
    would kill.  Suggested by Norman Werner <[email protected]>.
    
    darcs-hash:20090223065027-00fcc-7cea5cd78e291f0e86450edc70665e0e26e36a40
---
 paredit.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/paredit.el b/paredit.el
index d6d527b..dc084dc 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1461,6 +1461,29 @@ With a numeric prefix argument N, do `kill-line' that 
many times."
 ;;                              nil nil parse-state)
          )
         (t parse-state)))
+
+(defun paredit-copy-as-kill ()
+  "Save in the kill ring the region that `paredit-kill' would kill."
+  (interactive)
+  (save-excursion
+    (if (paredit-in-char-p)
+        (backward-char 2))
+    (let ((beginning (point))
+          (eol (point-at-eol)))
+      (let ((end-of-list-p (paredit-forward-sexps-to-kill beginning eol)))
+        (if end-of-list-p (progn (up-list) (backward-char)))
+        (copy-region-as-kill beginning
+                             (cond (kill-whole-line
+                                    (or (save-excursion
+                                          (paredit-skip-whitespace t)
+                                          (and (not (eq (char-after) ?\; ))
+                                               (point)))
+                                        (point-at-eol)))
+                                   ((and (not end-of-list-p)
+                                         (eq (point-at-eol) eol))
+                                    eol)
+                                   (t
+                                    (point))))))))
 
 ;;;; Cursor and Screen Movement
 

Reply via email to