GNU bug report logs -
#21164
25.0.50; char-fold search broken for multi-line searches (sometimes)
Previous Next
Reported by: Dima Kogan <dima <at> secretsauce.net>
Date: Fri, 31 Jul 2015 04:05:02 UTC
Severity: normal
Found in version 25.0.50
Done: Artur Malabarba <bruce.connor.am <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21164 in the body.
You can then email your comments to 21164 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Fri, 31 Jul 2015 04:05:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dima Kogan <dima <at> secretsauce.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 31 Jul 2015 04:05:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Sun, 02 Aug 2015 20:43:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 21164 <at> debbugs.gnu.org (full text, mbox):
> 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))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Wed, 05 Aug 2015 17:21:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 21164 <at> debbugs.gnu.org (full text, mbox):
> 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 ))
Before applying this, I'd like to figure out why lax is nil here.
IIUC, it is supposed to be t whenever isearch-lax-whitespace is
non-nil.
When I test use-case in the bug report I get that this function is
immediately invoked 3 times. And lax is t in the first, but nil in the
following two.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Wed, 05 Aug 2015 18:17:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 21164 <at> debbugs.gnu.org (full text, mbox):
There is some logic in `isearch-search-fun-default' that I don't quite
understand, and it's giving me trouble.
The following expression is used to decide whether lax-whitespace
matching should be used.
;; Use lax versions to not fail at the end of the word while
;; the user adds and removes characters in the search string
;; (or when using nonincremental word isearch)
(let ((lax (not (or isearch-nonincremental
(null (car isearch-cmds))
(eq (length isearch-string)
(length (isearch--state-string
(car isearch-cmds))))))))
...)
I don't understand the purpose of the last clause `(eq (...) (...))'.
For me, the only effect that it has is to disable lax while isearch is
looking for matches beyond the current one.
For instance, here's what happens with me:
1. Type C-s SPC to start isearching for a space.
2. All of the clauses evaluate to nil, and the `isearch-word' function
is called with LAX being t (all good).
3. Immediately (without me typing anything), isearch will start
looking for the next match, but this time the last clause will
evaluate to t. So the `isearch-word' function will be called with LAX
being nil, and some of the upcoming matches will be missed.
4. Step 3 is repeated to find more matches, always with lax being nil.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Sun, 09 Aug 2015 09:01:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 21164 <at> debbugs.gnu.org (full text, mbox):
I just pushed commit a5bdb87 which should fix this.
Dima, could you confirm that it solves your issue?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#21164
; Package
emacs
.
(Thu, 13 Aug 2015 22:47:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 21164 <at> debbugs.gnu.org (full text, mbox):
Artur Malabarba <bruce.connor.am <at> gmail.com> writes:
> I just pushed commit a5bdb87 which should fix this.
> Dima, could you confirm that it solves your issue?
Yes, that patch resolves the issue. Thanks!
Reply sent
to
bruce.connor.am <at> gmail.com
:
You have taken responsibility.
(Fri, 14 Aug 2015 16:40:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Dima Kogan <dima <at> secretsauce.net>
:
bug acknowledged by developer.
(Fri, 14 Aug 2015 16:40:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 21164-done <at> debbugs.gnu.org (full text, mbox):
Great!
2015-08-13 23:46 GMT+01:00 Dima Kogan <dima <at> secretsauce.net>:
> Artur Malabarba <bruce.connor.am <at> gmail.com> writes:
>
>> I just pushed commit a5bdb87 which should fix this.
>> Dima, could you confirm that it solves your issue?
>
> Yes, that patch resolves the issue. Thanks!
>
>
>
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 12 Sep 2015 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 286 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.