From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#65347: 29.1; Underscore in query replace prevents case-matching Date: Thu, 17 Aug 2023 08:42:35 -0400 Message-ID: References: <838raa6syr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34787"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65347@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 17 14:43:41 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qWcLj-0008o8-Si for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Aug 2023 14:43:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWcLP-0003ao-M8; Thu, 17 Aug 2023 08:43:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWcLB-0003aV-Im for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 08:43:06 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qWcL8-0006t4-GW for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 08:43:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qWcL8-0001vY-3E for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 08:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Aug 2023 12:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65347 X-GNU-PR-Package: emacs Original-Received: via spool by 65347-submit@debbugs.gnu.org id=B65347.16922761647383 (code B ref 65347); Thu, 17 Aug 2023 12:43:02 +0000 Original-Received: (at 65347) by debbugs.gnu.org; 17 Aug 2023 12:42:44 +0000 Original-Received: from localhost ([127.0.0.1]:42926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWcKp-0001v0-Ku for submit@debbugs.gnu.org; Thu, 17 Aug 2023 08:42:44 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:57467) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWcKn-0001um-7P for 65347@debbugs.gnu.org; Thu, 17 Aug 2023 08:42:42 -0400 In-Reply-To: <838raa6syr.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 17 Aug 2023 10:14:36 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267656 Archived-At: Eli Zaretskii writes: >> From: Spencer Baugh >> Date: Wed, 16 Aug 2023 17:27:34 -0400 >>=20 >>=20 >> 1. emacs -Q >> 2. (insert "Foo_bar") >> 3. M-% foo RET quux RET >> 4. Observe the buffer contains Quux_bar >> 5. Undo, so the buffer contains Foo_bar again >> 6. M-% foo_bar RET quux RET >> 7. Observe the buffer contains quux >>=20 >> Expected behavior: >> 7. Observe the buffer contains Quux >>=20 >> It seems to me that this would match the docstring better: >>=20 >> Replacement transfers the case pattern of the old text to the >> new text, if both =E2=80=98case-fold-search=E2=80=99 and =E2=80=98case= -replace=E2=80=99 are >> non-nil and FROM-STRING has no uppercase letters. > > This is a documentation issue: the complex heuristics used by > replace-match to decide whether and how to "transfer the case pattern" > depend on whether _all_ the words in the replaced text use the same > case pattern. In your example, Foo_bar is 2 words (what is a "word" > is determined by the buffer's syntax table), and only one of them is > capitalized. So Emacs does not capitalize the replacement. Try doing > the same with Foo_Bar, and you will see Quux in the replacement. > > These subtleties come up from time to time, so I think it's high time > we documented that (in the hope this will stop this from popping up), > so I've now done so on the emacs-29 branch. > > I think this is all we should do here, as the behavior is correct and > justified, has been like that since time immemoriam, and we should not > change it, therefore. Ah, that makes sense! I have no further complaint then and we should be able to close the bug. 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? Maybe some kind of escaping?