[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23655: 25.0.92; Upcasing a rectangular region of text
From: |
Juri Linkov |
Subject: |
bug#23655: 25.0.92; Upcasing a rectangular region of text |
Date: |
Tue, 31 May 2016 00:11:54 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (x86_64-pc-linux-gnu) |
> 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));