From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#40940: 27.0.91; project-query-replace-regexp stops too early Date: Sun, 3 May 2020 04:43:26 +0300 Message-ID: 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> <835zdgw3aj.fsf@gnu.org> <83sggjveto.fsf@gnu.org> <835zdevnsh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="52067"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: simenheg@runbox.com, monnier@IRO.UMontreal.CA, 40940@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 03 03:45:04 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 1jV3gl-000DRf-ME for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 May 2020 03:45:03 +0200 Original-Received: from localhost ([::1]:53052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jV3gk-0005qP-OR for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 May 2020 21:45:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jV3gc-0005pL-0f for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 21:44:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jV3fm-0006XE-Ps for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 21:44:53 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jV3fm-0006X9-DF for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 21:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jV3fm-0003WM-9r for bug-gnu-emacs@gnu.org; Sat, 02 May 2020 21:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 May 2020 01:44: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.158847021613492 (code B ref 40940); Sun, 03 May 2020 01:44:02 +0000 Original-Received: (at 40940) by debbugs.gnu.org; 3 May 2020 01:43:36 +0000 Original-Received: from localhost ([127.0.0.1]:54379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jV3fM-0003VY-D3 for submit@debbugs.gnu.org; Sat, 02 May 2020 21:43:36 -0400 Original-Received: from mail-wr1-f45.google.com ([209.85.221.45]:36484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jV3fK-0003VJ-8a for 40940@debbugs.gnu.org; Sat, 02 May 2020 21:43:35 -0400 Original-Received: by mail-wr1-f45.google.com with SMTP id d15so16659200wrx.3 for <40940@debbugs.gnu.org>; Sat, 02 May 2020 18:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NTC7r2Jy9RWM+Y81pVPJVhRAxDMDnB/RQwMbJVVUwFE=; b=vWzFoKgLF/nVs4/fFmZHLRGEn+2TIw0hEXc60g6CASw2UKvtA3DNrIZbeIdSfnu8El IpPyjO/t/jh+e09/SOvYlqwWuwuCj3y8EFVLUiwCIeuIh0UO2h1tMpehhz3w5SDw1pz2 LVQWd51JigEtfNPSd6fTMsYi8mGgKGdBNQJpcMikn1AHgz7mQw4bhNWZ8iGkHAVUsiBa SfX4GjimI0aXAM73CPF+58POjCGUdJCimIzPaCRtN02WNUjFF31+zPkIbY8GD066d+d1 t8ihqe0iWW05TKHGlAkhK3E8P9ubPRW8ag2RDgn3n4ZxqiLjHs4n6BBJlGCJMlQfsyqc 9xcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NTC7r2Jy9RWM+Y81pVPJVhRAxDMDnB/RQwMbJVVUwFE=; b=VTVtPe1Z+u2E5UbtXyhyI+jDu/PRQ4vTPSSKA518gnKH9BRLuBnGFUsuliKRJWogZf e8AzY20BN8lBej/0At4hAeW86eMOkQcQH0JwBjtRSakfs1R10s/jkdlFEIPq3XPTdk12 P0GbSCVUy7VKJVfjflkHgKoBwybhg2qpCrO2UuJ/tZR2TOiJ2mvU5EKg6w0styaBBJSl sFxcdj6hIjRiZmnL8p2h7Kp8Y0dpGLpkteIhzN+qMidfsZgDkX/M3s1CFT1Sem8e9Zg6 x+IKO2M+dUVFvUxZ9vn8pqPhBf9Fe4wx9FSB6of5Q36u/FmU5h4zOiGD94aV1HlpAAvB oqGA== X-Gm-Message-State: AGi0PuaCfpz//jKjTufJ5s8Om60pq1qzUUWGMGUVMvENlH3CT//l34jO I5XeRjihhYo5u4qyKEnau/Cs/fGhTVo= X-Google-Smtp-Source: APiQypJpeCE+3xZ560DRQNZRmgyO/kkzGQ2aBQI3Bg3pjOx583ZFi+sa3T0nDxy4kdVCepTJRD0Z7w== X-Received: by 2002:a5d:42cf:: with SMTP id t15mr11506220wrr.354.1588470208143; Sat, 02 May 2020 18:43:28 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id d13sm6530047wmb.39.2020.05.02.18.43.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 May 2020 18:43:27 -0700 (PDT) In-Reply-To: <835zdevnsh.fsf@gnu.org> Content-Language: en-US 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:179559 Archived-At: On 02.05.2020 09:44, Eli Zaretskii wrote: > I can update the doc string, yes. But I don't think it's a good idea > to divide the coding part between us, though. So please show the > code, and I will suggest the doc change. Here's the comprehensive fix I'd like to see: diff --git a/lisp/fileloop.el b/lisp/fileloop.el index 543963feaf..69825fdcae 100644 --- a/lisp/fileloop.el +++ b/lisp/fileloop.el @@ -181,8 +181,7 @@ fileloop-initialize-search (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 regexp case-fold))) (re-search-forward regexp nil t))) (lambda () (unless (eq last-buffer (current-buffer)) @@ -190,6 +189,15 @@ fileloop-initialize-search (message "Scanning file %s...found" buffer-file-name)) nil)))) +(defun fileloop--case-fold (regexp case-fold) + (let ((value + (if (memql case-fold '(nil t)) + case-fold + case-fold-search))) + (if (and value search-upper-case) + (isearch-no-upper-case-p regexp t) + value))) + ;;;###autoload (defun fileloop-initialize-replace (from to files case-fold &optional delimited) "Initialize a new round of query&replace on several files. @@ -203,15 +211,15 @@ 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 from 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 from case-fold))) + (perform-replace from to t t delimited nil multi-query-replace-map))))) (provide 'fileloop) ;;; fileloop.el ends here