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

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

bug#39376: closed ([PATCH] Throw error when calling reverse-region on a


From: GNU bug Tracking System
Subject: bug#39376: closed ([PATCH] Throw error when calling reverse-region on a single line)
Date: Sat, 15 Feb 2020 08:52:02 +0000

Your message dated Sat, 15 Feb 2020 10:51:54 +0200
with message-id <address@hidden>
and subject line Re: bug#39376: [PATCH] Throw error when calling reverse-region 
on a single line
has caused the debbugs.gnu.org bug report #39376,
regarding [PATCH] Throw error when calling reverse-region on a single line
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
39376: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=39376
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] Throw error when calling reverse-region on a single line Date: Fri, 31 Jan 2020 22:26:24 +0100
The current implementation of reverse region will delete everything
following the current line, if the region marks only a part of a
line. This is because the algorithm implemented below accidentally
deletes all following lines, and fails before being able to reinsert
them.

This patch sends an error (could be changed to an user-error) in that
case, as it makes no sense for a single line to be reversed.
---
 lisp/sort.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/sort.el b/lisp/sort.el
index 6ea1c44060..8848c5bf24 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -543,6 +543,8 @@ reverse-region
   (if (> beg end)
       (let (mid) (setq mid end end beg beg mid)))
   (save-excursion
+    (when (< (line-beginning-position) beg end (line-end-position))
+      (error "Cannot reverse a single line"))
     ;; 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)
-- 
2.20.1




--- End Message ---
--- Begin Message --- Subject: Re: bug#39376: [PATCH] Throw error when calling reverse-region on a single line Date: Sat, 15 Feb 2020 10:51:54 +0200
> From: Philip K <address@hidden>
> Date: Fri, 31 Jan 2020 22:26:24 +0100
> 
> The current implementation of reverse region will delete everything
> following the current line, if the region marks only a part of a
> line. This is because the algorithm implemented below accidentally
> deletes all following lines, and fails before being able to reinsert
> them.
> 
> This patch sends an error (could be changed to an user-error) in that
> case, as it makes no sense for a single line to be reversed.

Thanks.  I installed a slightly different change, because the command
would still delete the following lines if only BEG or END (bit not
both) was not at a line beginning/end.

I also fixed the doc string and the comments there.


--- End Message ---

reply via email to

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