Subject: Re: bug#20070: 24.3; have commands such as downcase-region act on a rectangle region

From: Juri Linkov <[email-masked]>
Date: Tue, 17 Mar 2015 21:38:06 +0200

>> A list of pairs would be much cleaner, indeed.  The problem is that
>> there are 2 arguments already in region-handling commands: BEG and END.
>> Using one of them for a list of pairs, and leaving another unused
>> is not a nice thing to do.
>
> I think this "lack of niceness" is not strong enough to override the
> advantage of using a list of pairs.

I still have doubts about the API, but anyway here is the implementation
that (ab)uses the first arg BEG:

diff --git a/src/casefiddle.c b/src/casefiddle.c
index 8755353..b77a0e6 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -306,14 +306,25 @@
   return Qnil;
 }
 
-DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r",
+DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2,
+       "(list (funcall region-extract-function 'positions) nil)",
        doc: /* Convert the region to lower case.  In programs, wants two arguments.
 These arguments specify the starting and ending character numbers of
 the region to operate on.  When used as a command, the text between
 point and the mark is operated on.  */)
   (Lisp_Object beg, Lisp_Object end)
 {
-  casify_region (CASE_DOWN, beg, end);
+  if (CONSP (beg))
+    {
+      while (CONSP (beg))
+	{
+	  casify_region (CASE_DOWN, XCAR (XCAR (beg)), XCDR (XCAR (beg)));
+	  beg = XCDR (beg);
+	}
+    }
+  else
+    casify_region (CASE_DOWN, beg, end);
+
   return Qnil;
 }