From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pankaj Jangid Newsgroups: gmane.emacs.help Subject: Re: query-replace-regexp on a string with '=' sign Date: Fri, 09 Sep 2022 13:16:17 +0530 Message-ID: <87o7vpoura.fsf@codeisgreat.org> References: <87k06e477o.fsf@codeisgreat.org> <87lequw2f4.fsf@gnu.org> <87a679qj9i.fsf@codeisgreat.org> <87leqtt9ab.fsf@gnu.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="25808"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 09 09:48:09 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 1oWYkC-0006VM-O1 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Sep 2022 09:48:08 +0200 Original-Received: from localhost ([::1]:60324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWYkA-0006GF-Ub for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Sep 2022 03:48:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWYiX-0006G6-Vw for help-gnu-emacs@gnu.org; Fri, 09 Sep 2022 03:46:27 -0400 Original-Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:35403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWYiU-000879-9P for help-gnu-emacs@gnu.org; Fri, 09 Sep 2022 03:46:25 -0400 Original-Received: by mail-pf1-x435.google.com with SMTP id e5so929222pfl.2 for ; Fri, 09 Sep 2022 00:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeisgreat-org.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:message-id:date:mail-followup-to:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date; bh=SnfnXfQgy6uLAU5GW0yEfhF8lvgLeeIoUuORUHcmBJQ=; b=BRsIGBZr5wIHIJO1O3KkNiXBfo1SkWbO+djew+C4rTjuiCA2v3FhkgbbK5BGpw4nBJ rkuuu7hRiMSv7Em4bNrte8YVO8z/Mvx8i0SdHCdB1mboX5fmeh7QZaIs7AWFZvsdTVmC TbKsJjx1NSFvSYkrqC1SgHUGs6lcMyIXJZWxY+ZdXV40hiRY6j5fFVt5shWgTNdfsk1L m94ep0mDKV5V/epIX/dCwS/3ZjfTIDoUPpdYWNvDasAWSzNWB1/KX3GQu6vBpkaPXzCS FJIHD1Gr/Nf2S8rjNGnyx+uAyUUo0CXZUS6hMVYwL1SLR9/l6fug4RhtaABdjpbB8Pqs wpig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:mail-followup-to:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=SnfnXfQgy6uLAU5GW0yEfhF8lvgLeeIoUuORUHcmBJQ=; b=SvsSekLfSlCxQjdu3JlLAfGdDW9fqbMUvDyooeAFuoI24xf2LMxfNkanG9o3sKUeIn 4Yb9HapvdpECdcx9D15dvg4AuYZsGIzrE/77FDVZQkGIUMq1bfKpQ0jqr4asL0TbyWWU tQ9oQqDg1apJsHwr+uoSZT+G3jfoI/ZjsNI5h4RzMPiwSNSaZmkDUXPRwjJ1xH5mPiAv UvLl4KzOzXcH309e3xGKuppPZSNya9AqpVsongt4N1o+XkcvlxEZ8shD+5sFyabUfu1U N1B99/odicx7SdHD/BId+rVyNGUvckDZoFd/83+yfRbbrRXo0uaU6e3FkN5fntsaWAwN dajA== X-Gm-Message-State: ACgBeo0KEN0iInj1HNJ9i5Jxc0LQzVUgYpZlHuZyPapjour2ASxmXNj2 MHnzEqsklqBow/MAKPP5vy6IUgiAVWSqDA== X-Google-Smtp-Source: AA6agR4/bhQOthxyWVtUIt2COIjsSRc9SF5QfWuxkb5M9pPL7nl3jHH4CVgg5xMMeaB7TchSe4SQhA== X-Received: by 2002:a05:6a00:16c8:b0:53b:3b9f:7283 with SMTP id l8-20020a056a0016c800b0053b3b9f7283mr12941518pfc.46.1662709580438; Fri, 09 Sep 2022 00:46:20 -0700 (PDT) Original-Received: from anant ([49.36.236.45]) by smtp.gmail.com with ESMTPSA id 83-20020a621556000000b0053e8f4a10c1sm923141pfv.217.2022.09.09.00.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 00:46:19 -0700 (PDT) In-Reply-To: <87leqtt9ab.fsf@gnu.org> (Tassilo Horn's message of "Fri, 09 Sep 2022 07:10:22 +0200") Mail-Followup-To: Tassilo Horn , help-gnu-emacs@gnu.org Received-SPF: none client-ip=2607:f8b0:4864:20::435; envelope-from=pankaj@codeisgreat.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action 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:139339 Archived-At: Tassilo Horn writes: > 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. Oh this is my mistake. I wanted to point out that only.. It stays 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. Sorry for creating confusion ... again.