From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#40940: 27.0.91; project-query-replace-regexp stops too early Date: Fri, 01 May 2020 09:57:24 +0300 Message-ID: <835zdgw3aj.fsf@gnu.org> References: <871ro7ptk0.fsf@runbox.com> <9ba1394f-5a29-8e8d-93cf-9b794b8ebb98@yandex.ru> <83d07q217v.fsf@gnu.org> <87ftcmhezl.fsf@runbox.com> <831ro61yce.fsf@gnu.org> <83zhauzlt7.fsf@gnu.org> <83mu6uzi8h.fsf@gnu.org> <32c0b31e-9165-faff-c9a0-9103d937898b@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="81755"; mail-complaints-to="usenet@ciao.gmane.io" Cc: simenheg@runbox.com, monnier@IRO.UMontreal.CA, 40940@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 01 08:58:13 2020 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 1jUPcj-000LBb-80 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 May 2020 08:58:13 +0200 Original-Received: from localhost ([::1]:58382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUPci-00081a-6Z for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 May 2020 02:58:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48902) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUPcZ-00081U-Td for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 02:58:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUPcY-000857-UO for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 02:58:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUPcY-00083i-HP for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 02:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUPcY-0003Zn-Ft for bug-gnu-emacs@gnu.org; Fri, 01 May 2020 02:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 May 2020 06:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40940 X-GNU-PR-Package: emacs Original-Received: via spool by 40940-submit@debbugs.gnu.org id=B40940.158831626913727 (code B ref 40940); Fri, 01 May 2020 06:58:02 +0000 Original-Received: (at 40940) by debbugs.gnu.org; 1 May 2020 06:57:49 +0000 Original-Received: from localhost ([127.0.0.1]:48137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUPcK-0003ZK-RB for submit@debbugs.gnu.org; Fri, 01 May 2020 02:57:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUPcI-0003Z5-O5 for 40940@debbugs.gnu.org; Fri, 01 May 2020 02:57:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38637) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUPcB-0006fH-D7; Fri, 01 May 2020 02:57:39 -0400 Original-Received: from [176.228.60.248] (port=4455 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jUPc8-0000EC-FQ; Fri, 01 May 2020 02:57:38 -0400 In-Reply-To: <32c0b31e-9165-faff-c9a0-9103d937898b@yandex.ru> (message from Dmitry Gutov on Wed, 29 Apr 2020 23:53:46 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:179422 Archived-At: > Cc: simenheg@runbox.com, monnier@IRO.UMontreal.CA, 40940@debbugs.gnu.org > From: Dmitry Gutov > Date: Wed, 29 Apr 2020 23:53:46 +0300 > > > Also, using downcase is not entirely correct, we should > > use isearch-no-upper-case-p instead. > > I usually like isearch-no-upper-case-p behavior, but here it doesn't fit > the docstring, does it? There is no value of CASE-FOLD described that > would indicate that the function will be too smart about it. > > So we'd need to update the docstring that the CASE-FOLD value of t will > obey the value of `search-upper-case'. Then we'll consult it as well, > like isearch-search does. I don't think I follow. isearch-no-upper-case-p is just supposed to tell you whether a regexp includes upper-case characters that would need the search to become case-sensitive. All the rest of the considerations, like the value of case-fold-search, are to be applied by the caller. I see no reference to either case-fold-search or case-fold in isearch-no-upper-case-p. So why would we need to update its doc string? > Alternatively, we could for now use the below patch which changes the > behavior less: > > diff --git a/lisp/fileloop.el b/lisp/fileloop.el > index 543963feaf..c3c55badf5 100644 > --- a/lisp/fileloop.el > +++ b/lisp/fileloop.el > @@ -175,14 +175,16 @@ fileloop-continue > (funcall fileloop--operate-function))) > (setq file-finished t)))) > > +(defun fileloop--case-fold (arg) > + (if (memq arg '(t nil)) arg case-fold-search)) > + > ;;;###autoload > (defun fileloop-initialize-search (regexp files case-fold) > (let ((last-buffer (current-buffer))) > (fileloop-initialize > files > (lambda () > - (let ((case-fold-search > - (if (memq case-fold '(t nil)) case-fold case-fold-search))) > + (let ((case-fold-search (fileloop--case-fold case-fold))) > (re-search-forward regexp nil t))) > (lambda () > (unless (eq last-buffer (current-buffer)) > @@ -203,15 +205,16 @@ fileloop-initialize-replace > (fileloop-initialize > files > (lambda () > - (let ((case-fold-search > - (if (memql case-fold '(nil t)) case-fold case-fold-search))) > + (let ((case-fold-search (fileloop--case-fold case-fold))) > (if (re-search-forward from nil t) > ;; When we find a match, move back > ;; to the beginning of it so perform-replace > ;; will see it. > (goto-char (match-beginning 0))))) > (lambda () > - (perform-replace from to t t delimited nil multi-query-replace-map)))) > + (let ((case-fold-search (fileloop--case-fold case-fold)) > + search-upper-case) > + (perform-replace from to t t delimited nil multi-query-replace-map))))) Does that really work in the case in point? Unless I'm missing something, if case-fold-search is t by default, this patch would cause the search to be case-insensitive even if the FROM regexp includes upper-case characters. But in that case, perform-replace will internally decide to be case-sensitive, and we have the same failure on our hands. This is why the patch I proposed explicitly examined the FROM regexp for upper-case characters. Whereas yours doesn't. Thanks.