unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: 23655@debbugs.gnu.org
Subject: bug#23655: 25.0.92; Upcasing a rectangular region of text
Date: Tue, 31 May 2016 00:11:54 +0300	[thread overview]
Message-ID: <87inxv1c9x.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAH8Pv0hGUph9Rd91N_ZRQ2OTvuyx1HPHqFra04=mS4NHBYcbzQ@mail.gmail.com> (Dani Moncayo's message of "Mon, 30 May 2016 11:18:38 +0200")

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





  reply	other threads:[~2016-05-30 21:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  9:18 bug#23655: 25.0.92; Upcasing a rectangular region of text Dani Moncayo
2016-05-30 21:11 ` Juri Linkov [this message]
2016-06-05 21:23   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inxv1c9x.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=23655@debbugs.gnu.org \
    --cc=dmoncayo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).