GNU bug report logs - #8699
23.3.50; [PATCH] Allow empty regions in transpose-region

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Thu, 19 May 2011 08:09:02 UTC

Severity: minor

Tags: patch

Found in version 23.3.50

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8699 in the body.
You can then email your comments to 8699 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8699; Package emacs. (Thu, 19 May 2011 08:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 19 May 2011 08:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3.50; [PATCH] Allow empty regions in transpose-region
Date: Thu, 19 May 2011 16:07:57 +0800
[Message part 1 (text/plain, inline)]
I found this odd primitive transpose-regions (which has not seen much
use anywhere). I tried to use it a bit and found the annoying error when
one of the two regions is empty.

I wonder if the attached patch makes sense. Thanks.

Leo

[0001-Allow-empty-regions-in-transpose-region.patch (text/x-diff, inline)]
From 56cee3783dd30eaaf0b36f2fd8fa85525b6c4f2c Mon Sep 17 00:00:00 2001
Date: Sat, 14 May 2011 19:27:33 +0800
Subject: [PATCH] Allow empty regions in transpose-region

---
 src/editfns.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index feae8316..1022b944 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4411,8 +4411,9 @@ Transposing beyond buffer boundaries is an error.  */)
 
   if (start2 < end1)
     error ("Transposed regions overlap");
-  else if (start1 == end1 || start2 == end2)
-    error ("Transposed region has length 0");
+  /* Nothing to change for adjacent regions with one being empty */
+  else if ((start1 == end1 || start2 == end2) && end1 == start2)
+    return Qnil;
 
   /* The possibilities are:
      1. Adjacent (contiguous) regions, or separate but equal regions
-- 
1.7.5-rc2


Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8699; Package emacs. (Wed, 25 May 2011 22:51:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region
Date: Thu, 26 May 2011 06:49:58 +0800
On 2011-05-19 16:07 +0800, Leo wrote:
> Date: Sat, 14 May 2011 19:27:33 +0800
> Subject: [PATCH] Allow empty regions in transpose-region
>
> ---
>  src/editfns.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)

No one seems to object to this patch. So I will put it in trunk later
today.

Thanks.
Leo





Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Thu, 26 May 2011 05:39:02 GMT) Full text and rfc822 format available.

Notification sent to Leo <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Thu, 26 May 2011 05:39:02 GMT) Full text and rfc822 format available.

Message #13 received at 8699-done <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: 8699-done <at> debbugs.gnu.org
Subject: Re: bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region
Date: Thu, 26 May 2011 13:38:16 +0800
version 24.1




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Jun 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 4 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.