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: Spencer Baugh
Subject: bug#65347: 29.1; Underscore in query replace prevents case-matching
Date: Fri, 18 Aug 2023 15:14:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@janestreet.com>
>> Cc: 65347@debbugs.gnu.org,  monnier@iro.umontreal.ca
>> Date: Fri, 18 Aug 2023 14:31:46 -0400
>> 
>> > 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".
>> 
>> But no, this use case very specifically is about replacing symbols
>> (sexps) while matching case.
>
> What are "symbols" in this context?

Strings made up of symbol constituents as defined by the current
major-mode's syntax table.  The normal definition of symbols.

>> I don't much care about the word boundary or superword-mode, because I'm
>> not dealing with words - I'm very deliberately dealing with symbols.
>
> Capitalization issues with program code are conceptually different
> from those with human-readable text.  You are basically talking about
> refactoring, not about text replacement.  So the use cases that are of
> interest to you are not well supported by query-replace, because it
> doesn't target them.  It could well mean that you will need a custom
> replace-match function.  Insisting on replace-match to support these
> cases is not necessarily wise, from where I stand.

Hm, that's fair.  Although I would bet that the majority of usage of
query-replace is with program code, since the majority of Emacs usage is
with program code.  So features which make query-replace work better
with code are still useful.

Another feature that could support this would be to allow defining
multiple query/replacement pairs, and applying them together across the
file or across multiple files, querying as we go.  Then "foo" could be
replaced with "bar" and "Foo" with "Bar".  That kind of simultaneous
replacement is something I've definitely wanted before.

>> What about the other thing I proposed?  That's what I'm more interested
>> in, because this is a problem of replacing symbols.  And it's much more
>> elegant.  Repeated here:
>> 
>> >>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.
>
> I don't understand the proposal.  Again, what are "symbols" in this
> context, and how are they different from "words"?

The normal definition of symbols in Emacs, as defined by the syntax
table.





reply via email to

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