[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case-replace
From: |
John Yates |
Subject: |
Re: case-replace |
Date: |
Fri, 18 Mar 2011 08:42:49 -0400 |
On Thu, Mar 17, 2011 at 4:20 PM, Stefan Monnier
<address@hidden> wrote:
>> I often find myself replacing a FROM string with a TO of identical
>> length. In such a case I would really appreciate it if case were
>> preserved at each character position. E.g. replacing 'ab' by 'xy'
>> would give me:
>
>> ab -> xy
>> Ab -> Xy
>> AB -> XY
>> aB -> xY <<<<
>
> If you replace foobar with mrtoto, it would then replace FooBar with
> MrtOto whereas you probably wanted MrToto instead.
> There's no way for Emacs to know what you really mean here, so the only
> solution I can see is to somehow let the user tell Emacs what she wants,
> but I'm not sure how best to do that:
> - prompt the user when encountering a new mixed-case word.
> - let the user specify a case-insensitive replacement of FooBar by MrToto
> (currently if you specify such a replacement, Emacs will do it is
> a case-sensitive way).
> - something else?
Stefan,
I find your counter example somewhat unconvincing. In order to run
into a problem all of the following need to coincide:
- the user must specify both FROM and TO entirely in lower case
- the two string must be the same length
- the replacement site needs a capital letter in some position beyond
the first without being entirely caps
- the desired resulting capitalization need to be different between TO and FROM
Finally, and from my POV most importantly, our user must enter the TO
string entirely in lower case expecting to trigger case-replace
functionality. Returning to your example this means that along with
replacing CamelCase FooBar with MrToto she must also expect that at
least one of the following will occur:
foobar -> mrtoto
Foobar -> Mrtoto
FOOBAR -> MRTOTO
Absent of any of those cases she can achieve an entirely correct
replacement simply by entering the TO string with proper case. I
submit that this is pretty much what we all do today.
Might it be possible to make this change tentative and wait for feedback?
/john