summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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