aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJuri Linkov2019-09-22 02:00:01 +0300
committerJuri Linkov2019-09-22 02:00:01 +0300
commit2879c3ec1b91bcf3276c979155dd05494de20a0d (patch)
tree087891f436857beada09c60fa0bdb5c86b40f2f8 /src
parenta34216351f28dec2e592ce169eabea55715930f8 (diff)
downloademacs-2879c3ec1b91bcf3276c979155dd05494de20a0d.tar.gz
emacs-2879c3ec1b91bcf3276c979155dd05494de20a0d.zip
Support rectangular regions in capitalize-region and capitalize-dwim.
* lisp/simple.el (capitalize-dwim): Add arg region-noncontiguous-p in capitalize-region call. * src/casefiddle.c (Fcapitalize_region): Add arg region-noncontiguous-p. If non-nil, operate on multiple chunks. (Bug#37477) (Fdowncase_region): Use builtin symbol Qregion_extract_function rather than calling intern.
Diffstat (limited to 'src')
-rw-r--r--src/casefiddle.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c
index ee292dda9b3..3a1724b306d 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -556,7 +556,7 @@ point and the mark is operated on. */)
556 556
557 if (!NILP (region_noncontiguous_p)) 557 if (!NILP (region_noncontiguous_p))
558 { 558 {
559 bounds = call1 (Fsymbol_value (intern ("region-extract-function")), 559 bounds = call1 (Fsymbol_value (Qregion_extract_function),
560 intern ("bounds")); 560 intern ("bounds"));
561 561
562 while (CONSP (bounds)) 562 while (CONSP (bounds))
@@ -571,15 +571,31 @@ point and the mark is operated on. */)
571 return Qnil; 571 return Qnil;
572} 572}
573 573
574DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 2, "r", 574DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 3,
575 "(list (region-beginning) (region-end) (region-noncontiguous-p))",
575 doc: /* Convert the region to capitalized form. 576 doc: /* Convert the region to capitalized form.
576This means that each word's first character is converted to either 577This means that each word's first character is converted to either
577title case or upper case, and the rest to lower case. 578title case or upper case, and the rest to lower case.
578In programs, give two arguments, the starting and ending 579In programs, give two arguments, the starting and ending
579character positions to operate on. */) 580character positions to operate on. */)
580 (Lisp_Object beg, Lisp_Object end) 581 (Lisp_Object beg, Lisp_Object end, Lisp_Object region_noncontiguous_p)
581{ 582{
582 casify_region (CASE_CAPITALIZE, beg, end); 583 Lisp_Object bounds = Qnil;
584
585 if (!NILP (region_noncontiguous_p))
586 {
587 bounds = call1 (Fsymbol_value (Qregion_extract_function),
588 intern ("bounds"));
589
590 while (CONSP (bounds))
591 {
592 casify_region (CASE_CAPITALIZE, XCAR (XCAR (bounds)), XCDR (XCAR (bounds)));
593 bounds = XCDR (bounds);
594 }
595 }
596 else
597 casify_region (CASE_CAPITALIZE, beg, end);
598
583 return Qnil; 599 return Qnil;
584} 600}
585 601