GNU bug report logs -
#65347
29.1; Underscore in query replace prevents case-matching
Previous Next
Reported by: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Wed, 16 Aug 2023 21:28:02 UTC
Severity: normal
Found in version 29.1
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, 65347 <at> debbugs.gnu.org
>> Date: Thu, 17 Aug 2023 22:04:53 -0400
>>
>> > Although, a further relevant question: is there some way to make _ not
>> > be a word separator, in this specific context? Without changing the
>> > syntax table of the buffer overall? So that foo_bar is interpreted as
>> > one word?
>>
>> 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.
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.
That seems like a reasonable customization... I could add support for
this to replace-match - it would just be a matter of teaching it to
conditionally use symbol boundaries instead of word boundaries.
Alternatively, much more interestingly, the case-matching could *always*
detect case patterns both for symbols and for words. And if there's no
case pattern for words, but there is a case pattern for symbols, apply
that case pattern to symbols in the replacement. We could even turn
that on by default. Does that sound like a good change? I can make
that change if it sounds desirable.
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.
This bug report was last modified 1 year and 277 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.