all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* case-replace
@ 2011-03-17  2:17 John Yates
  2011-03-17  7:00 ` case-replace Leo
  2011-03-17 20:20 ` case-replace Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: John Yates @ 2011-03-17  2:17 UTC (permalink / raw)
  To: emacs-devel

Here is a description of case-replace as it behaves today:

| Replacement transfers the case
| pattern of the old text to the new text, if `case-replace' and
| `case-fold-search' are non-nil and FROM-STRING has no uppercase
| letters.  (Transferring the case pattern means that if the old text
| matched is all caps, or capitalized, then its replacement is upcased
| or capitalized.)

Thus we give a request to replace 'ab' by 'xyz' we get

ab -> xyz
Ab -> Xyz
AB -> XYZ
aB -> xyz    <<<<

These rules make sense when FROM and TO differ in length.

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    <<<<

/john



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-17  2:17 case-replace John Yates
@ 2011-03-17  7:00 ` Leo
  2011-03-17 14:54   ` case-replace John Yates
  2011-03-17 20:20 ` case-replace Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Leo @ 2011-03-17  7:00 UTC (permalink / raw)
  To: emacs-devel

On 2011-03-17 10:17 +0800, John Yates wrote:
> Here is a description of case-replace as it behaves today:
>
> | Replacement transfers the case
> | pattern of the old text to the new text, if `case-replace' and
> | `case-fold-search' are non-nil and FROM-STRING has no uppercase
> | letters.  (Transferring the case pattern means that if the old text
> | matched is all caps, or capitalized, then its replacement is upcased
> | or capitalized.)

Is this a feature request?

Leo




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-17  7:00 ` case-replace Leo
@ 2011-03-17 14:54   ` John Yates
  2011-03-18  9:06     ` case-replace Leo
  0 siblings, 1 reply; 7+ messages in thread
From: John Yates @ 2011-03-17 14:54 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel

On Thu, Mar 17, 2011 at 3:00 AM, Leo <sdl.web@gmail.com> wrote:

> Is this a feature request?

Yes.  Is there a more formal means of submission?  I was hoping to see
some reaction either pro or con.

/john



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-17  2:17 case-replace John Yates
  2011-03-17  7:00 ` case-replace Leo
@ 2011-03-17 20:20 ` Stefan Monnier
  2011-03-18 12:42   ` case-replace John Yates
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-03-17 20:20 UTC (permalink / raw)
  To: John Yates; +Cc: emacs-devel

> 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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-17 14:54   ` case-replace John Yates
@ 2011-03-18  9:06     ` Leo
  0 siblings, 0 replies; 7+ messages in thread
From: Leo @ 2011-03-18  9:06 UTC (permalink / raw)
  To: emacs-devel

On 2011-03-17 22:54 +0800, John Yates wrote:
> Is there a more formal means of submission?

Probably the bug tracker.

,----[ C-h f report-emacs-bug RET ]
| report-emacs-bug is an interactive autoloaded Lisp function in
| `emacsbug.el'.
| 
| It is bound to <menu-bar> <help-menu> <send-emacs-bug-report>.
| 
| (report-emacs-bug TOPIC &optional RECENT-KEYS)
| 
| Report a bug in GNU Emacs.
| Prompts for bug subject.  Leaves you in a mail buffer.
`----

Leo




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-17 20:20 ` case-replace Stefan Monnier
@ 2011-03-18 12:42   ` John Yates
  2011-03-18 15:23     ` case-replace Andreas Röhler
  0 siblings, 1 reply; 7+ messages in thread
From: John Yates @ 2011-03-18 12:42 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thu, Mar 17, 2011 at 4:20 PM, Stefan Monnier
<monnier@iro.umontreal.ca> 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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: case-replace
  2011-03-18 12:42   ` case-replace John Yates
@ 2011-03-18 15:23     ` Andreas Röhler
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-03-18 15:23 UTC (permalink / raw)
  To: emacs-devel

[ ... ]
>
> 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
>
>

1+

Would call it "position-sensitive case-replace".

Andreas

--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-18 15:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17  2:17 case-replace John Yates
2011-03-17  7:00 ` case-replace Leo
2011-03-17 14:54   ` case-replace John Yates
2011-03-18  9:06     ` case-replace Leo
2011-03-17 20:20 ` case-replace Stefan Monnier
2011-03-18 12:42   ` case-replace John Yates
2011-03-18 15:23     ` case-replace Andreas Röhler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.