Commit 73dc8771 authored by Karl Heuer's avatar Karl Heuer
Browse files

(Freplace_match): Improve capitalization heuristics.

parent 026e8330
......@@ -1174,6 +1174,7 @@ Leaves point at end of replacement text.")
register int pos, last;
int some_multiletter_word;
int some_lowercase;
int some_uppercase;
int some_lowercase_initial;
register int c, prevc;
int inslen;
......@@ -1205,6 +1206,7 @@ Leaves point at end of replacement text.")
some_multiletter_word = 0;
some_lowercase = 0;
some_lowercase_initial = 0;
some_uppercase = 0;
for (pos = search_regs.start[0]; pos < last; pos++)
{
......@@ -1221,6 +1223,7 @@ Leaves point at end of replacement text.")
}
else if (!NOCASEP (c))
{
some_uppercase = 1;
if (SYNTAX (prevc) != Sword)
;
else
......@@ -1235,11 +1238,12 @@ Leaves point at end of replacement text.")
if (! some_lowercase && some_multiletter_word)
case_action = all_caps;
/* Capitalize each word, if the old text has all capitalized words. */
/* We used to insist on some_multiletter_word here,
but that screwed query replacing x with y, acting on X.
Even what we have now is more strict than what 19.22 had. */
else if (!some_lowercase_initial)
else if (!some_lowercase_initial && some_multiletter_word)
case_action = cap_initial;
else if (!some_lowercase_initial && some_uppercase)
/* Should x -> yz, operating on X, give Yz or YZ?
We'll assume the latter. */
case_action = all_caps;
else
case_action = nochange;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment