GNU bug report logs - #65347
29.1; Underscore in query replace prevents case-matching

Previous Next

Package: emacs;

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


Message #46 received at 65347 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65347 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#65347: 29.1; Underscore in query replace prevents
 case-matching
Date: Fri, 18 Aug 2023 17:00:12 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 65347 <at> debbugs.gnu.org,  monnier <at> iro.umontreal.ca
>> Date: Fri, 18 Aug 2023 15:14:46 -0400
>> 
>> > 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.
>
> Then you are talking about something very different from "words".
>
>> > 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.
>
> That's profoundly not true!  Emacs is used with human-readable text
> not less, and maybe more, than with program source code.  I'm typing
> this email in Emacs; I'm routinely making changes to our documentation
> in Emacs -- these and others are all frequent text-editing activities.
>
>> So features which make query-replace work better with code are still
>> useful.
>
> No, we need a real refactoring in Emacs!  Using M-% as poor-man's
> refactoring is fine, but pretending that it _is_ refactoring, and
> adding minor extensions to it that are motivated by refactoring, is
> simply wrong!  It will likely complicate the text-oriented replacement
> we have already, and will always fall short of decent refactoring
> capabilities.
>
> We should work on adding refactoring instead of tweaking M-% and M-*
> in these directions.

Okay, I'm convinced.  I'll defer this functionality to the future
refactoring support in Emacs, built with project.el and eglot no doubt.

>> 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.
>
> IMO, this makes little or no sense in human-readable text; it does
> make sense in the refactoring context.  So let's add refactoring
> capabilities to Emacs, and leave M-% for text.




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.