bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Juri Linkov
Subject: bug#38539: char-fold-to-regexp and search-whitespace-regexp
Date: Sun, 08 Dec 2019 23:22:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]