bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Juri Linkov
Subject: bug#20070: 24.3; have commands such as downcase-region act on a rectangle region
Date: Tue, 17 Mar 2015 21:38:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu)

>> 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;
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]