bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#41934: reverse-region no longer works


From: Eli Zaretskii
Subject: bug#41934: reverse-region no longer works
Date: Thu, 18 Jun 2020 21:20:26 +0300

> From: Richard Copley <rcopley@gmail.com>
> Date: Thu, 18 Jun 2020 18:52:48 +0100
> Cc: 41934@debbugs.gnu.org
> 
> No, that fails on this example:
> 
> [mark]abc
> def
> [point]abcdefghi

How about this:

diff --git a/lisp/sort.el b/lisp/sort.el
index de0e1b9..8a4a56c 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -554,9 +554,18 @@ reverse-region
   (if (> beg end)
       (let (mid) (setq mid end end beg beg mid)))
   (save-excursion
-    (when (or (< (line-beginning-position) beg)
-              (< end (line-end-position)))
-      (user-error "There are no full lines in the region"))
+    (let ((lbeg (save-excursion
+                  (goto-char beg)
+                  (if (bolp)
+                      beg
+                    (line-beginning-position 2))))
+          (lend (save-excursion
+                  (goto-char end)
+                  (if (bolp)
+                      end
+                    (line-beginning-position)))))
+      (when (>= lbeg lend)
+        (user-error "There are no full lines in the region")))
     ;; Put beg at the start of a line and end and the end of one --
     ;; the largest possible region which fits this criteria.
     (goto-char beg)





reply via email to

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