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

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

bug#65347: 29.1; Underscore in query replace prevents case-matching


From: Eli Zaretskii
Subject: bug#65347: 29.1; Underscore in query replace prevents case-matching
Date: Fri, 18 Aug 2023 21:15:21 +0300

> From: Spencer Baugh <sbaugh@janestreet.com>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  65347@debbugs.gnu.org
> Date: Fri, 18 Aug 2023 12:30:48 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> >> There's `superword-mode`, but I suspect that query-replace does not
> >> honor it in this case.  Could be considered as a bug in
> >> `superword-mode`.
> >
> > Actually, I think it's a bug in replace-match: it doesn't honor
> > find-word-boundary-function-table.  I think it should.  Patches
> > welcome.
> 
> I suppose this is a bit of an XY problem - the real thing I (speaking
> for the user who reported this to me) want is to have case-matching for
> symbols instead of words.

We look at this from different angles.  As an Emacs maintainer, I
would like to see every place that deals with words to honor
find-word-boundary-function-table, instead of inventing its own ideas
about where a word begins and where it ends.

> e.g. if I have Foo-do-action and I do a replace of foo-do-action with
> bar-do-action, I want the replacement to be Bar-do-action.

Here, you look at the issue from a very narrow perspective: of words
separated by '-' or '_', because that just happens to be the case that
you bumped into.  But that is just one very particular use case; words
can be separated by a lot more characters.  I would actually begin
considering the simpler case of "Foo do action".

> Alternatively, much more simply, maybe the case-matching could just
> detect if the first word is capitalized, and then also capitalize the
> first word in the replacement?  That would work for this specific usage.

Given enough user options, we could support that as optional behavior.
But one thing is clear: we cannot simultaneously support all of the
possible interpretations of "capitalization pattern".  And another
thing is clear: this heuristic is confusing and rarely kept in mind as
it is, so imagine what will happen if we add half a dozen options to
support its variants...





reply via email to

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