bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case conversion by replace-match


From: Kevin Rodgers
Subject: Re: case conversion by replace-match
Date: Fri, 16 May 2003 15:32:48 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Andreas Schwab wrote:

Roland Winkler <roland.winkler@physik.uni-erlangen.de> writes:

|> Start a fresh emacs --no-init-file
|> |> define the following function |> |> (defun foo ()
|>   (interactive)
|>   (let (case-fold-search)
|>     (while (search-forward "=FC" nil t)
|>       (replace-match (string 252) nil t))))
|> |> `(string 252)' gives a lowercase umlaut-u (iso-latin-1) |> |> However, when foo is run in a buffer containing the string "=FC",
|> this string will be replaced with an uppercase umlaut-U.

Exactly as documented.


That's what I thought at first.  Then I thought the "=" obviously means that
not all the characters in the replacement text are capital letters, so NEXTEXT
should not be uppercase'd.  But then I thought the "=" divides the replacement
text into 2 words, an empty word and an uppercase word; so if the empty word is
ignored and an uppercase word is considered to be capitalized, then (each word
in) the replacement text should be capitalized.

But  really, that's all just a rationalization to support the observed behavior.
The user should specify FIXEDCASE as t if he/she knows that NEWTEXT is is case-
precise.  And Emacs should not consider "=FC" to be a sequence of capitalized
words.

If you don't want this, pass a non-nil second
argument to replace-match:

    If second arg FIXEDCASE is non-nil, do not alter case of replacement text.
    Otherwise maybe capitalize the whole text, or maybe just word initials,
    based on the replaced text.
    If the replaced text has only capital letters
    and has at least one multiletter word, convert NEWTEXT to all caps.
    Otherwise if all words are capitalized in the replaced text,
    capitalize each word in NEWTEXT.


--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]