From: Leo Liu Date: Thu, 26 May 2011 05:36:55 +0000 (+0800) Subject: Allow empty regions in transpose-regions X-Git-Tag: emacs-pretest-24.0.90~104^2~618^2~156 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0f4aebc0ebc91099461f5af63f3034709336f233;p=emacs.git Allow empty regions in transpose-regions See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8699. --- diff --git a/src/ChangeLog b/src/ChangeLog index e98cb2848a9..c4f5ef4b920 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-05-26 Leo Liu + + * editfns.c (Ftranspose_regions): Allow empty regions. (Bug#8699) + 2011-05-25 YAMAMOTO Mitsuharu * dispextern.h (struct glyph_row): New member fringe_bitmap_periodic_p. diff --git a/src/editfns.c b/src/editfns.c index 5e1dcce0275..881e0c7f3e2 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -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