GNU bug report logs - #40940
27.0.91; project-query-replace-regexp stops too early

Previous Next

Package: emacs;

Reported by: Simen Heggestøyl <simenheg <at> runbox.com>

Date: Tue, 28 Apr 2020 14:57:02 UTC

Severity: normal

Found in version 27.0.91

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: simenheg <at> runbox.com, monnier <at> IRO.UMontreal.CA, 40940 <at> debbugs.gnu.org
Subject: bug#40940: 27.0.91; project-query-replace-regexp stops too early
Date: Wed, 29 Apr 2020 23:53:46 +0300
On 29.04.2020 13:41, Eli Zaretskii wrote:
> The patch below seems to fix the rest.  Note that I've decided to make
> the change in fileloop.el, since I think all the other callers need
> the same fix.

Naturally.

> 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.

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)))))

 (provide 'fileloop)
 ;;; fileloop.el ends here




This bug report was last modified 5 years and 112 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.