emacs-devel
[Top][All Lists]
Advanced

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

Re: case sensitive replacement doesn't seem to work


From: David Kastrup
Subject: Re: case sensitive replacement doesn't seem to work
Date: Thu, 10 Apr 2014 16:31:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Bogolisk <address@hidden> writes:

> Hi
>
> In this example, the "%s" replacement text is always upcased to "%S" 
> regardless
> of the value of case-fold-search or case-replace.
>
>
> (let ((case-fold-search nil)
>       (case-replace nil)
>       (orig-string "this is a FOO bar")
>       new-string)
>   (when (string-match "FOO" orig-string)
>     (setq new-string (replace-match "%s" nil t orig-string))
>     (message "orig:`%s' new:`%s'" orig-string new-string)))
>
>
> in both 23.1.1 and 24.3.50.1, the message is always:
>
> "orig:`this is a FOO bar' new:`this is a %S bar'"
>
>
> Is this a bug or expected behaviour?

replace-match is a built-in function in `C source code'.

(replace-match NEWTEXT &optional FIXEDCASE LITERAL STRING SUBEXP)

[...]

If optional second arg FIXEDCASE is non-nil, do not alter the case of
the 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.

[...]

So why are you setting FIXEDCASE to nil here?

-- 
David Kastrup




reply via email to

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