all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region
@ 2011-05-19  8:07 Leo
  2011-05-25 22:49 ` Leo
  2011-05-26  5:38 ` Leo
  0 siblings, 2 replies; 3+ messages in thread
From: Leo @ 2011-05-19  8:07 UTC (permalink / raw)
  To: 8699

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-empty-regions-in-transpose-region.patch --]
[-- Type: text/x-diff, Size: 871 bytes --]

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region
  2011-05-19  8:07 bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region Leo
@ 2011-05-25 22:49 ` Leo
  2011-05-26  5:38 ` Leo
  1 sibling, 0 replies; 3+ messages in thread
From: Leo @ 2011-05-25 22:49 UTC (permalink / raw)
  To: 8699

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






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region
  2011-05-19  8:07 bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region Leo
  2011-05-25 22:49 ` Leo
@ 2011-05-26  5:38 ` Leo
  1 sibling, 0 replies; 3+ messages in thread
From: Leo @ 2011-05-26  5:38 UTC (permalink / raw)
  To: 8699-done

version 24.1





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-26  5:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-19  8:07 bug#8699: 23.3.50; [PATCH] Allow empty regions in transpose-region Leo
2011-05-25 22:49 ` Leo
2011-05-26  5:38 ` Leo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.