bug#38539: char-fold-to-regexp and search-whitespace-regexp

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bug#38539: char-fold-to-regexp and search-whitespace-regexp

Juri Linkov-2
I don't know but bug#35802 removed let-binding of search-spaces-regexp
around the char-fold-to-regexp call in isearch-search-fun-default.
Maybe this is fine, but makes the following slightly more isearch-dependent:

search-whitespace-regexp matches a sequence of whitespace chars
in isearch, i.e. by entering a space it matches any whitespace.

For example, in *scratch* searching with ‘C-s M-s ' 1 2’
will match all these lines:

1 2
1  2
1 2
1  2

It would be natural to expect that when char-fold-symmetric
is customized to non-nil, searching for ‘C-s M-s ' 1 2’
will also match the above lines.

After applying this patch, it does.

diff --git a/lisp/char-fold.el b/lisp/char-fold.el
index d8d2ebc72b..47a70ad681 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -324,6 +324,13 @@ char-fold-to-regexp
     (while (< i end)
       (pcase (aref string i)
         (?\s (setq spaces (1+ spaces)))
+        ((pred (lambda (c) (and char-fold-symmetric
+                                (if isearch-regexp
+                                    isearch-regexp-lax-whitespace
+                                  isearch-lax-whitespace)
+                                (stringp search-whitespace-regexp)
+                                (string-match-p search-whitespace-regexp (char-to-string c)))))
+ (setq spaces (1+ spaces)))
         (c (when (> spaces 0)
              (push (char-fold--make-space-string spaces) out)
              (setq spaces 0))