GNU bug report logs - #23655
25.0.92; Upcasing a rectangular region of text

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Mon, 30 May 2016 09:19:02 UTC

Severity: normal

Tags: patch

Found in version 25.0.92

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 23655 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 23655 <at> debbugs.gnu.org
Subject: Re: bug#23655: 25.0.92; Upcasing a rectangular region of text
Date: Tue, 31 May 2016 00:11:54 +0300
> 0.  emacs -Q
> 1.  Eval: (put 'upcase-region 'disabled nil)
>           (put 'downcase-region 'disabled nil)
> 2.  Visit the attached file.
> 3.  Move point to just after the comma.
> 4.  Define a *rectanguar* region: C-x <SPC> C-n C-e
> 5.  Downcase the rectangular region: C-x C-l
> 6.  Repeat steps #3 to #5, but this time for upcasing the region
>     instead of downcasing it ('C-x C-u' instead of 'C-x C-l').
>
> The upcased text in the last step is not only the one marked by the
> rectangular region.  The upcasing command acts as if a linear
> (i.e. non-rectangular) region was active at that moment.

Thanks for the request.  Since we were unable to find a way to support
rectangular regions for all region-selecting commands en masse, here
is a patch to implement this individually for ‘upcase-region’:

diff --git a/src/casefiddle.c b/src/casefiddle.c
index c5bfa36..0a237d5 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -294,15 +294,31 @@
     }
 }
 
-DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 2, "r",
+DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 3,
+       "(list (region-beginning) (region-end) (region-noncontiguous-p))",
        doc: /* Convert the region to upper 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.
 See also `capitalize-region'.  */)
-  (Lisp_Object beg, Lisp_Object end)
+  (Lisp_Object beg, Lisp_Object end, Lisp_Object region_noncontiguous_p)
 {
-  casify_region (CASE_UP, beg, end);
+  Lisp_Object bounds = Qnil;
+
+  if (!NILP (region_noncontiguous_p))
+    {
+      bounds = call1 (Fsymbol_value (intern ("region-extract-function")),
+		      intern ("bounds"));
+
+      while (CONSP (bounds))
+	{
+	  casify_region (CASE_UP, XCAR (XCAR (bounds)), XCDR (XCAR (bounds)));
+	  bounds = XCDR (bounds);
+	}
+    }
+  else
+    casify_region (CASE_UP, beg, end);
+
   return Qnil;
 }
 
diff --git a/src/search.c b/src/search.c
index f39df67..7cb18a2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2691,7 +2691,8 @@ STRING that was matched (the original STRING itself is not altered).
 
   if (case_action == all_caps)
     Fupcase_region (make_number (search_regs.start[sub]),
-		    make_number (newpoint));
+		    make_number (newpoint),
+		    Qnil);
   else if (case_action == cap_initial)
     Fupcase_initials_region (make_number (search_regs.start[sub]),
 			     make_number (newpoint));




This bug report was last modified 9 years and 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.