Allow empty regions in transpose-regions
authorLeo Liu <sdl.web@gmail.com>
Thu, 26 May 2011 05:36:55 +0000 (13:36 +0800)
committerLeo Liu <sdl.web@gmail.com>
Thu, 26 May 2011 05:36:55 +0000 (13:36 +0800)
See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8699.

src/ChangeLog
src/editfns.c

index e98cb28..c4f5ef4 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-26  Leo Liu  <sdl.web@gmail.com>
+
+       * editfns.c (Ftranspose_regions): Allow empty regions.  (Bug#8699)
+
 2011-05-25  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * dispextern.h (struct glyph_row): New member fringe_bitmap_periodic_p.
index 5e1dcce..881e0c7 100644 (file)
@@ -4353,8 +4353,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