From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: query-replace-regexp on a string with '=' sign Date: Fri, 09 Sep 2022 07:10:22 +0200 Message-ID: <87leqtt9ab.fsf@gnu.org> References: <87k06e477o.fsf@codeisgreat.org> <87lequw2f4.fsf@gnu.org> <87a679qj9i.fsf@codeisgreat.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14074"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.0; emacs 29.0.50 Cc: help-gnu-emacs@gnu.org To: Pankaj Jangid Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 09 07:22:32 2022 Return-path: Envelope-to: geh-help-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 1oWWTH-0003W0-1e for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Sep 2022 07:22:31 +0200 Original-Received: from localhost ([::1]:48926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWWTF-0008QY-Tb for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Sep 2022 01:22:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWWPp-0007C7-V8 for help-gnu-emacs@gnu.org; Fri, 09 Sep 2022 01:18:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWWPp-0003FO-Ck; Fri, 09 Sep 2022 01:18:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=sccwP1/L/zCTpPjpanEi/wSE2DOKUpr28OfUNp2DVpA=; b=jVI8yZLOLzqwjQ 4keD0aS/j0TPNW0v1hEHR4QRa4bWTa8TkRpexGFae+RV1snwp7vsMPBw4UieuWxpyZwgL8vl0GGG0 XxHuC+iAjm/Hhcn93y9NMawZirIntPwl676tmTa8VY36IsvvLDZo9OxKm0eaZEpd2giSRuE664fIi NXE6TVsFEJpbiHq6marDpWCVDqc8DIFwS7YGGV7aJGKjaGfzrUVnqbN84VzlfQSDHPwKHAWM+dHDN uura5tPNeUvudrn4i9kOdfXJdYi8VYXsM0r2Y7te+J2bAv1vAv8Z+cpMl9pabCdoTSMx7+CbZuUXF AEojZfc1LgTBTWvx/amg==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:52627) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWWPo-0007um-TE; Fri, 09 Sep 2022 01:18:57 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 6778527C0054; Fri, 9 Sep 2022 01:18:56 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Sep 2022 01:18:56 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedtgedgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvvefuffgjkfggtgesthdtredttdertdenucfhrhhomhepvfgrshhs ihhlohcujfhorhhnuceothhsughhsehgnhhurdhorhhgqeenucggtffrrghtthgvrhhnpe dujedtheduvdelffejkeetgedvheelhedvueefhfeukeekkeehvdfggeegffevgfenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhorhhnod hmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdekieejfeekjeekgedqieefhedv leekqdhtshguhheppehgnhhurdhorhhgsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Sep 2022 01:18:55 -0400 (EDT) In-reply-to: <87a679qj9i.fsf@codeisgreat.org> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139337 Archived-At: Pankaj Jangid writes: >>> I have a line like this, >>> HELLO=WORLD >>> now I want to downcase the part before the equal (=) sign. >>> I am approaching like this >>> >>> M-x query-replace-regexp RET \(.+\)= RET \,(downcase \1)= RET >>> >>> But this doesn't work. >> >> Where "doesn't work" means "doesn't downcase but keeps HELLO", right? > > Yes. Suppose I have these lines in a region > HELLO=WORLD > HELLOXXXXWORLD > and if I now execute following sequence, > M-x query-replace-regexp RET \(.+\)= RET \,(downcase \1)= RET > the output is, > > hello=WORLD > HELLOXXXXWORLD For me (with emacs -Q on the current master), it stays as it is, i.e., all caps. > but if I execute this, > M-x query-replace-regexp RET \(.+\)XXXX RET \,(downcase \1)XXXX RET > then the output is, > > HELLO=WORLD > helloXXXXWORLD I can reproduce that. I think that's documented on the info page I've cited. When the replacement is all lower- or all uppercase (like hello=), `case-replace' has an effect. But when the replacement is mixed-case (like helloXXXX), case will be preserved. >> Have a look at (info "(emacs) Replacement and Lax Matches") which >> explains it. I think the default `case-replace' value of t is the >> problem here. > > Thanks for pointing me to the right direction. Understood case-replace > thing. But the one thing that is still not clear to me is that, why > the first command doesn't downcase HELLO in the first line, whereas > the second command downcases the HELLO in the second line. Huh? You've said the first command does downcase hello in the first line although I cannot reproduce that and would not have an explanation for that behavior. If it's actually the same for you, then see my last paragraph for the explanation. Bye, Tassilo