[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 2879c3e: Support rectangular regions in capitalize-
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] master 2879c3e: Support rectangular regions in capitalize-region and capitalize-dwim. |
Date: |
Sat, 21 Sep 2019 19:00:08 -0400 (EDT) |
branch: master
commit 2879c3ec1b91bcf3276c979155dd05494de20a0d
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>
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.
---
etc/NEWS | 4 ++--
lisp/simple.el | 2 +-
src/casefiddle.c | 24 ++++++++++++++++++++----
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 6a4a6e6..20d2e62 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -487,8 +487,8 @@ interface that's more like functions like 'search-forward'.
---
** More commands support noncontiguous rectangular regions, namely
-'upcase-dwim', 'downcase-dwim', 'replace-string', 'replace-regexp',
-and 'delimit-columns-region'.
+'upcase-dwim', 'downcase-dwim', 'capitalize-dwim', 'capitalize-region',
+'replace-string', 'replace-regexp', and 'delimit-columns-region'.
+++
** When asked to visit a large file, Emacs now offers visiting it literally.
diff --git a/lisp/simple.el b/lisp/simple.el
index a267200..31e3b2b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9074,7 +9074,7 @@ Otherwise, it calls `capitalize-word', with prefix
argument passed to it
to capitalize ARG words."
(interactive "*p")
(if (use-region-p)
- (capitalize-region (region-beginning) (region-end))
+ (capitalize-region (region-beginning) (region-end)
(region-noncontiguous-p))
(capitalize-word arg)))
;;; Accessors for `decode-time' values.
diff --git a/src/casefiddle.c b/src/casefiddle.c
index ee292dd..3a1724b 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -556,7 +556,7 @@ point and the mark is operated on. */)
if (!NILP (region_noncontiguous_p))
{
- bounds = call1 (Fsymbol_value (intern ("region-extract-function")),
+ bounds = call1 (Fsymbol_value (Qregion_extract_function),
intern ("bounds"));
while (CONSP (bounds))
@@ -571,15 +571,31 @@ point and the mark is operated on. */)
return Qnil;
}
-DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 2, "r",
+DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 3,
+ "(list (region-beginning) (region-end) (region-noncontiguous-p))",
doc: /* Convert the region to capitalized form.
This means that each word's first character is converted to either
title case or upper case, and the rest to lower case.
In programs, give two arguments, the starting and ending
character positions to operate on. */)
- (Lisp_Object beg, Lisp_Object end)
+ (Lisp_Object beg, Lisp_Object end, Lisp_Object region_noncontiguous_p)
{
- casify_region (CASE_CAPITALIZE, beg, end);
+ Lisp_Object bounds = Qnil;
+
+ if (!NILP (region_noncontiguous_p))
+ {
+ bounds = call1 (Fsymbol_value (Qregion_extract_function),
+ intern ("bounds"));
+
+ while (CONSP (bounds))
+ {
+ casify_region (CASE_CAPITALIZE, XCAR (XCAR (bounds)), XCDR (XCAR
(bounds)));
+ bounds = XCDR (bounds);
+ }
+ }
+ else
+ casify_region (CASE_CAPITALIZE, beg, end);
+
return Qnil;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 2879c3e: Support rectangular regions in capitalize-region and capitalize-dwim.,
Juri Linkov <=