unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38539: char-fold-to-regexp and search-whitespace-regexp
@ 2019-12-08 21:22 Juri Linkov
  2020-08-21 12:07 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2019-12-08 21:22 UTC (permalink / raw)
  To: 38539

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





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#38539: char-fold-to-regexp and search-whitespace-regexp
  2019-12-08 21:22 bug#38539: char-fold-to-regexp and search-whitespace-regexp Juri Linkov
@ 2020-08-21 12:07 ` Lars Ingebrigtsen
  2020-09-07 18:36   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-21 12:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 38539

Juri Linkov <juri@linkov.net> writes:

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

I think that makes a lot of sense -- you'd expect nonbreaking space and
space to be handled equivalently when char-fold-symmetric is switched on.

I didn't see anybody objecting to the patch, so I think you should just
apply it and see whether anybody has any comments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#38539: char-fold-to-regexp and search-whitespace-regexp
  2020-08-21 12:07 ` Lars Ingebrigtsen
@ 2020-09-07 18:36   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2020-09-07 18:36 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38539

tags 38539 fixed
close 38539 28.0.50
quit

>> 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.
>
> I think that makes a lot of sense -- you'd expect nonbreaking space and
> space to be handled equivalently when char-fold-symmetric is switched on.
>
> I didn't see anybody objecting to the patch, so I think you should just
> apply it and see whether anybody has any comments.

I was unsure about validity of this patch, but since it works,
now pushed to master, and closed both this and bug#22147.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-07 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08 21:22 bug#38539: char-fold-to-regexp and search-whitespace-regexp Juri Linkov
2020-08-21 12:07 ` Lars Ingebrigtsen
2020-09-07 18:36   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).