[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21164: 25.0.50; char-fold search broken for multi-line searches (som
From: |
Juri Linkov |
Subject: |
bug#21164: 25.0.50; char-fold search broken for multi-line searches (sometimes) |
Date: |
Sun, 02 Aug 2015 23:40:15 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) |
> Hi. I'm using a very recent emacs built from the git HEAD. Sometime in
> the recent past the default C-s behavior was changed to include
> char-folding by default. There's a bug here. Suppose I have a buffer
> containing the following C source.
>
> ----------------------------------------------------
> int a(void)
> {
> for(unsigned long x = 0;
> x < 10;
> x += 2)
> {
> nvm_flash_erase_app_page( x );
> }
> }
>
> int b(void)
> {
> for(unsigned long x = 0;
> x < 10;
> x += 2)
> {
> }
> }
> ----------------------------------------------------
>
>
> Note that the two functions are identical. I place the point at the
> start of one of the 'for' statements, then C-s to enter char-folding
> isearch, then C-w to grab some amount of text to search for. While I'm
> grabbing text that's still on the 'for' line, isearch sees the other
> match, highlights it, and I can jump to it by hitting C-s. However, if I
> hit C-w enough times to go to the next line, the other match is no
> longer seen. This resolves when I turn off char-folding.
Thank you for the bug report. This can be fixed by a small patch:
diff --git a/lisp/character-fold.el b/lisp/character-fold.el
index bf5ae59..db77845 100644
--- a/lisp/character-fold.el
+++ b/lisp/character-fold.el
@@ -123,7 +123,7 @@ (defun character-fold-to-regexp (string &optional lax)
(apply #'concat
(mapcar (lambda (c) (let ((out (or (aref character-fold-table c)
(regexp-quote (string c)))))
- (if (and lax (memq c '(?\s ?\t ?\r ?\n )))
+ (if (memq c '(?\s ?\t ?\r ?\n ))
(concat out "+")
out)))
string))
Later we could also see how to handle both lax-at-the-end-of-the-search-string
and lax-a-sequence-of-whitespace-chars. Maybe something like:
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 8d4bf24..74b7e56 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2613,7 +2613,11 @@ (defun isearch-search-fun-default ()
(length (isearch--state-string
(car isearch-cmds))))))))
(funcall
- (if isearch-forward #'re-search-forward #'re-search-backward)
+ (if (and isearch-lax-whitespace search-whitespace-regexp)
+ (if isearch-forward
+ 're-search-forward-lax-whitespace
+ 're-search-backward-lax-whitespace)
+ (if isearch-forward #'re-search-forward #'re-search-backward))
(if (functionp isearch-word)
(funcall isearch-word string lax)
(word-search-regexp string lax))
- bug#21164: 25.0.50; char-fold search broken for multi-line searches (sometimes),
Juri Linkov <=