From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65347: 29.1; Underscore in query replace prevents case-matching Date: Thu, 17 Aug 2023 10:14:36 +0300 Message-ID: <838raa6syr.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27099"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65347@debbugs.gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 17 09:15:27 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 1qWXE7-0006nb-F0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Aug 2023 09:15:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWXDr-0007SY-2s; Thu, 17 Aug 2023 03:15:11 -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 1qWXDi-0007RL-OF for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 03:15:02 -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 1qWXDi-0001YT-DX for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 03:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qWXDh-00050Y-Tl for bug-gnu-emacs@gnu.org; Thu, 17 Aug 2023 03:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Aug 2023 07:15:01 +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.169225647719202 (code B ref 65347); Thu, 17 Aug 2023 07:15:01 +0000 Original-Received: (at 65347) by debbugs.gnu.org; 17 Aug 2023 07:14:37 +0000 Original-Received: from localhost ([127.0.0.1]:42672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWXDJ-0004ze-9V for submit@debbugs.gnu.org; Thu, 17 Aug 2023 03:14:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qWXDH-0004zQ-5N for 65347@debbugs.gnu.org; Thu, 17 Aug 2023 03:14:36 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWXDB-0001T7-NC; Thu, 17 Aug 2023 03:14:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=KmSKoSoLrWw2wdkfzLVuoV3z9O3sGWWWPQuGscGSYY4=; b=hpNG5jJ7T3ZhR/x+jXey 6Y8FfNWbM6sQW2ZxjWUkbelcCMFRHoMC0miaNjiICjlb4MFRCV8xyZnh9pHgcvcVRVUNtehDN4p4k Lkvs/I3fklPi+u2k8PIhwD6dVLLt4qRfqpAANZ8sJTOmb0t5z0hRCA1OSEyci0bG+a4FPdEEa68SA 6jfcXV/L3JKSK0fv06r0zK92gLSIlmYE9QD+oIsUIVnKEdffRyPcTvuW1KnHeGltnnxWKXMfcO78D QyspvtD3QyLWJdN2k1oPUIGXF/11zMQPCr/mC8gt9wZaqM421DtD9WCrj7d+2TY0uW1RtZHL9oihK D9r8vzCM4+2FLg==; In-Reply-To: (message from Spencer Baugh on Wed, 16 Aug 2023 17:27:34 -0400) 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:267638 Archived-At: > From: Spencer Baugh > Date: Wed, 16 Aug 2023 17:27:34 -0400 > > > 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 > > Expected behavior: > 7. Observe the buffer contains Quux > > It seems to me that this would match the docstring better: > > Replacement transfers the case pattern of the old text to the > new text, if both ‘case-fold-search’ and ‘case-replace’ 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.