summaryrefslogtreecommitdiff
path: root/paredit.el
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2009-02-23 06:50:27 +0000
committerTaylor R Campbell <campbell@mumble.net>2009-02-23 06:50:27 +0000
commit43bf81fec70052b0be37109e27f76e968bb982e8 (patch)
tree61cdeb8cf14f38066e62e43e75f8b6a7cdd5ba8c /paredit.el
parentf7c26b9336361c368dfdaae278da3838d2879bc7 (diff)
Implement `paredit-copy-as-kill'.
Saves to the kill ring the text of the region that `paredit-kill' would kill. Suggested by Norman Werner <norman@norman-werner.de>. darcs-hash:20090223065027-00fcc-7cea5cd78e291f0e86450edc70665e0e26e36a40
Diffstat (limited to 'paredit.el')
-rw-r--r--paredit.el23
1 files changed, 23 insertions, 0 deletions
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