emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/paredit 52be50188e 1/3: paredit-raise-sexp: Handle active


From: ELPA Syncer
Subject: [nongnu] elpa/paredit 52be50188e 1/3: paredit-raise-sexp: Handle active mark in transient mark mode.
Date: Thu, 24 Nov 2022 14:59:14 -0500 (EST)

branch: elpa/paredit
commit 52be50188ef8c49d8c1a5ef71cb0a963c6a05f09
Author: Taylor R Campbell <campbell+paredit@mumble.net>
Commit: Taylor R Campbell <campbell+paredit@mumble.net>

    paredit-raise-sexp: Handle active mark in transient mark mode.
---
 paredit.el | 23 ++++++++++++++---------
 test.el    | 12 ++++++++++++
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/paredit.el b/paredit.el
index d8d01d697a..b67b1bda11 100644
--- a/paredit.el
+++ b/paredit.el
@@ -2158,17 +2158,22 @@ If the point is on an S-expression, such as a string or 
a symbol, not
   between them, that S-expression is considered to follow the point."
   (interactive "P")
   (save-excursion
-    (cond ((paredit-in-string-p)
-           (goto-char (car (paredit-string-start+end-points))))
-          ((paredit-in-char-p)
-           (backward-sexp))
-          ((paredit-in-comment-p)
-           (error "No S-expression to raise in comment.")))
     ;; Select the S-expressions we want to raise in a buffer substring.
-    (let* ((n (prefix-numeric-value argument))
-           (bound (scan-sexps (point) n))
+    (let* ((bound
+            (if (and (not argument) (paredit-region-active-p))
+                (progn (if (< (mark) (point))
+                           (paredit-check-region (mark) (point))
+                           (paredit-check-region (point) (mark)))
+                       (mark))
+              (cond ((paredit-in-string-p)
+                     (goto-char (car (paredit-string-start+end-points))))
+                    ((paredit-in-char-p)
+                     (backward-sexp))
+                    ((paredit-in-comment-p)
+                     (error "No S-expression to raise in comment.")))
+              (scan-sexps (point) (prefix-numeric-value argument))))
            (sexps
-            (if (< n 0)
+            (if (< bound (point))
                 (buffer-substring bound (paredit-point-at-sexp-end))
                 (buffer-substring (paredit-point-at-sexp-start) bound))))
       ;; Move up to the list we're raising those S-expressions out of and
diff --git a/test.el b/test.el
index a1df058dca..bd8ae37b06 100644
--- a/test.el
+++ b/test.el
@@ -1481,6 +1481,18 @@ Four arguments: the paredit command, the text of the 
buffer
      "(let ((x 5))\n  |(foo bar\n       baz)\n   (wrong indent))")
     ("(define (f x #!optional\n (|wrong indent))\n  (+ 1 2))"
      "(define (f x #!optional\n |wrong)\n  (+ 1 2))")))
+
+(let ((transient-mark-mode t))
+  (paredit-test 'paredit-raise-sexp
+    '(("(a |b c_ d)" "|b c")
+      ("(a (b |c d_ e) f)" "(a |c d f)")
+      ("(a \"|b\" c_ d)" error))))
+
+(let ((transient-mark-mode nil))
+  (paredit-test 'paredit-raise-sexp
+    '(("(a |b c_ d)" "|b")
+      ("(a (b |c d_ e) f)" "(a |c f)")
+      ("(a \"|b\" c_ d)" "|\"b\""))))
 
 (let ((paredit-comment-prefix-toplevel ";;;T ")
       (paredit-comment-prefix-code ";;C ")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]