GNU bug report logs - #25562
25.1; isearch-forward-word first matches a non-word

Previous Next

Package: emacs;

Reported by: Antoine Levitt <antoine.levitt <at> gmail.com>

Date: Sat, 28 Jan 2017 11:24:02 UTC

Severity: minor

Merged with 22589

Found in versions 25.0.90, 25.1

Done: Juri Linkov <juri <at> linkov.net>

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 25562 in the body.
You can then email your comments to 25562 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Sat, 28 Jan 2017 11:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Antoine Levitt <antoine.levitt <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 28 Jan 2017 11:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Antoine Levitt <antoine.levitt <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; isearch-forward-word first matches a non-word
Date: Sat, 28 Jan 2017 12:23:08 +0100
emacs -Q
M-<
M-s w
it

see that the "it" of "visit" is matched, and should not be. Subsequent
C-s fix this.

Best,
Antoine




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Sun, 29 Jan 2017 00:52:03 GMT) Full text and rfc822 format available.

Message #8 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Antoine Levitt <antoine.levitt <at> gmail.com>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Sun, 29 Jan 2017 02:29:03 +0200
merge 22589 25562
thanks

> emacs -Q
> M-<
> M-s w
> it
>
> see that the "it" of "visit" is matched, and should not be. Subsequent
> C-s fix this.

Thanks for the report.  Please see the rationale for this behavior in
https://debbugs.gnu.org/22589

Do you think the proposed change suits your case?




Merged 22589 25562. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sun, 29 Jan 2017 00:52:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Sun, 29 Jan 2017 06:53:01 GMT) Full text and rfc822 format available.

Message #13 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Antoine Levitt <antoine.levitt <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Sun, 29 Jan 2017 07:52:38 +0100
[Message part 1 (text/plain, inline)]
I see, thanks for the explanation. That's still unsatisfactory to me. I
think an ideal incremental word search would just start over from the
current point each time a new character is typed (that's what most users
would expect). Then any non-insertion command would make the user "commit"
to the particular search and the incremental search proper would begin. Is
that compatible with the current design of isearch?

Best,
Antoine

On 29 Jan 2017 01:50, "Juri Linkov" <juri <at> linkov.net> wrote:

> merge 22589 25562
> thanks
>
> > emacs -Q
> > M-<
> > M-s w
> > it
> >
> > see that the "it" of "visit" is matched, and should not be. Subsequent
> > C-s fix this.
>
> Thanks for the report.  Please see the rationale for this behavior in
> https://debbugs.gnu.org/22589
>
> Do you think the proposed change suits your case?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Mon, 30 Jan 2017 00:35:03 GMT) Full text and rfc822 format available.

Message #16 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Antoine Levitt <antoine.levitt <at> gmail.com>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Mon, 30 Jan 2017 02:30:41 +0200
> I see, thanks for the explanation. That's still unsatisfactory to me. I
> think an ideal incremental word search would just start over from the
> current point each time a new character is typed (that's what most users
> would expect). Then any non-insertion command would make the user "commit"
> to the particular search and the incremental search proper would begin. Is
> that compatible with the current design of isearch?

What you describe looks like isearch-barrier used for subsequent \| in regexps,
e.g. typing ‘C-M-s ^\<it\>’ and then ‘\|’ moves point back to the beginning
of the search.  But wouldn't this make the search too “jumpy”, especially
while typing long words?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Mon, 30 Jan 2017 08:12:02 GMT) Full text and rfc822 format available.

Message #19 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Antoine Levitt <antoine.levitt <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Mon, 30 Jan 2017 09:12:20 +0100
30 January 2017 01:30 +0100, Juri Linkov <juri <at> linkov.net>:
>> I see, thanks for the explanation. That's still unsatisfactory to me. I
>> think an ideal incremental word search would just start over from the
>> current point each time a new character is typed (that's what most users
>> would expect). Then any non-insertion command would make the user "commit"
>> to the particular search and the incremental search proper would begin. Is
>> that compatible with the current design of isearch?
>
> What you describe looks like isearch-barrier used for subsequent \| in regexps,
> e.g. typing ‘C-M-s ^\<it\>’ and then ‘\|’ moves point back to the beginning
> of the search.  But wouldn't this make the search too “jumpy”, especially
> while typing long words?

My use case of isearch-word is mainly short words, e.g. variable names
such as f in f(x) in latex. I'd guess that's a pretty common pattern.
Even for long words, I think an user would type a word quickly, and be
confused that their first match is not really a match. That offsets the
potential jumpiness (ie what happens when the user is typing the word)
for me.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Mon, 30 Jan 2017 23:29:02 GMT) Full text and rfc822 format available.

Message #22 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Antoine Levitt <antoine.levitt <at> gmail.com>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 01:24:07 +0200
>>> I see, thanks for the explanation. That's still unsatisfactory to me. I
>>> think an ideal incremental word search would just start over from the
>>> current point each time a new character is typed (that's what most users
>>> would expect). Then any non-insertion command would make the user "commit"
>>> to the particular search and the incremental search proper would begin. Is
>>> that compatible with the current design of isearch?
>>
>> What you describe looks like isearch-barrier used for subsequent \| in regexps,
>> e.g. typing ‘C-M-s ^\<it\>’ and then ‘\|’ moves point back to the beginning
>> of the search.  But wouldn't this make the search too “jumpy”, especially
>> while typing long words?
>
> My use case of isearch-word is mainly short words, e.g. variable names
> such as f in f(x) in latex. I'd guess that's a pretty common pattern.
> Even for long words, I think an user would type a word quickly, and be
> confused that their first match is not really a match. That offsets the
> potential jumpiness (ie what happens when the user is typing the word)
> for me.

You can try yourself using the minimal patch below that demonstrates your idea.

But from what I see, it's not too good, using the recipe from your top post:

emacs -Q
M-<
M-s w
i

After typing the letter “i”, isearch fails, beeps, flashes the screen,
with a clear indication that something went wrong.  This is more confusing
for a user, because now a user has to stop and think about what is wrong.

Here is the patch to help seeing this in action:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 5c48c30..85b9365 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1616,6 +1616,7 @@ (defun word-search-regexp (string &optional lax)
 
 Used in `word-search-forward', `word-search-backward',
 `word-search-forward-lax', `word-search-backward-lax'."
+  (setq lax nil)
   (cond
    ((equal string "") "")
    ((string-match-p "\\`\\W+\\'" string) "\\W+")
@@ -2465,6 +2466,11 @@ (defun isearch-process-search-char (char &optional count)
   ;; } and | are special in regexps when preceded by \.
   ;; Nothing special for + because it matches at least once.
   (cond
+   ((eq isearch-regexp-function t)
+    (goto-char isearch-barrier)
+    (setq isearch-other-end isearch-barrier
+          isearch-success t
+          isearch-error nil))
    ((memq char '(?* ??)) (isearch-fallback nil))
    ((eq   char ?\})      (isearch-fallback t t))
    ((eq   char ?|)       (isearch-fallback t nil t)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 31 Jan 2017 03:29:02 GMT) Full text and rfc822 format available.

Message #25 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, antoine.levitt <at> gmail.com
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 05:28:27 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Date: Tue, 31 Jan 2017 01:24:07 +0200
> Cc: 25562 <at> debbugs.gnu.org
> 
> You can try yourself using the minimal patch below that demonstrates your idea.
> 
> But from what I see, it's not too good, using the recipe from your top post:
> 
> emacs -Q
> M-<
> M-s w
> i
> 
> After typing the letter “i”, isearch fails, beeps, flashes the screen,
> with a clear indication that something went wrong.  This is more confusing
> for a user, because now a user has to stop and think about what is wrong.

I think this is a consequence of the simple fact that "word search"
and "incremental search" contradict each other: as long as "the word"
was not fully specified, searching for it incrementally is not a
well-defined operation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 31 Jan 2017 07:58:01 GMT) Full text and rfc822 format available.

Message #28 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Antoine Levitt <antoine.levitt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25562 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 08:57:37 +0100
[Message part 1 (text/plain, inline)]
I agree it's an ill defined problem ; but then, so is isearching for
foo\|bar.

I disabled the beeping and screen flashing, so it doesn't bother me, but I
get the point.

In the end, it's mostly a matter of personal convenience. The patched
behavior suits me better, and seems more consistent with the way regexp are
handled.

Best,
Antoine


On 31 Jan 2017 04:29, "Eli Zaretskii" <eliz <at> gnu.org> wrote:

> From: Juri Linkov <juri <at> linkov.net>
> Date: Tue, 31 Jan 2017 01:24:07 +0200
> Cc: 25562 <at> debbugs.gnu.org
>
> You can try yourself using the minimal patch below that demonstrates your
idea.
>
> But from what I see, it's not too good, using the recipe from your top
post:
>
> emacs -Q
> M-<
> M-s w
> i
>
> After typing the letter “i”, isearch fails, beeps, flashes the screen,
> with a clear indication that something went wrong.  This is more confusing
> for a user, because now a user has to stop and think about what is wrong.

I think this is a consequence of the simple fact that "word search"
and "incremental search" contradict each other: as long as "the word"
was not fully specified, searching for it incrementally is not a
well-defined operation.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 31 Jan 2017 15:40:02 GMT) Full text and rfc822 format available.

Message #31 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Antoine Levitt <antoine.levitt <at> gmail.com>
Cc: 25562 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 17:38:46 +0200
> From: Antoine Levitt <antoine.levitt <at> gmail.com>
> Date: Tue, 31 Jan 2017 08:57:37 +0100
> Cc: Juri Linkov <juri <at> linkov.net>, 25562 <at> debbugs.gnu.org
> 
> I agree it's an ill defined problem ; but then, so is isearching for foo\|bar.
> 
> I disabled the beeping and screen flashing, so it doesn't bother me, but I get the point. 
> 
> In the end, it's mostly a matter of personal convenience. The patched behavior suits me better, and seems
> more consistent with the way regexp are handled.

Did you try typing RET right after "C-s M-s w", then typing the word
to search, and then typing "C-s C-s" again to repeat that?  This might
be better suited to your needs, I think, and it doesn't require any
changes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 31 Jan 2017 16:46:02 GMT) Full text and rfc822 format available.

Message #34 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Antoine Levitt <antoine.levitt <at> gmail.com>
Cc: 25562 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 17:45:08 +0100
Antoine Levitt <antoine.levitt <at> gmail.com> writes:

> I see, thanks for the explanation. That's still unsatisfactory to
> me. I think an ideal incremental word search would just start over
> from the current point each time a new character is typed (that's what
> most users would expect).

It's what I had expected, too.  But after I had tried it, I changed my
mind.  AFAIR I was especially annoyed that i could not anymore use C-w
to extend the search string because isearch did not go to partial
matches any more.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 31 Jan 2017 16:52:02 GMT) Full text and rfc822 format available.

Message #37 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 31 Jan 2017 17:51:39 +0100
Juri Linkov <juri <at> linkov.net> writes:

> merge 22589 25562
> thanks

AFAIK you didn't yet make the change so that the lax matching state is
recognizable from the prompt.  No hurry, but I think this report shows
that the current behavior is at first surprising to users.  Maybe even a
stronger term than your suggested "Pending" would be appropriate.


Thanks,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Wed, 01 Feb 2017 00:49:01 GMT) Full text and rfc822 format available.

Message #40 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Wed, 01 Feb 2017 02:38:16 +0200
>> merge 22589 25562
>> thanks
>
> AFAIK you didn't yet make the change so that the lax matching state is
> recognizable from the prompt.  No hurry, but I think this report shows
> that the current behavior is at first surprising to users.  Maybe even a
> stronger term than your suggested "Pending" would be appropriate.

Thanks for confirming that it would be a good solution.
We are already using "Pending" indication in the search prompt
in other places to show that the search is not yet fully accepted.
This could do the same for word search as well:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 5c48c30..3c9dff1 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2741,6 +2747,8 @@ (defun isearch-search-fun-default ()
            (if isearch-forward #'re-search-forward #'re-search-backward)
            (cond (isearch-regexp-function
                   (let ((lax (isearch--lax-regexp-function-p)))
+                    (when lax
+                      (setq isearch-adjusted t))
                     (if (functionp isearch-regexp-function)
                         (funcall isearch-regexp-function string lax)
                       (word-search-regexp string lax))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Wed, 01 Feb 2017 00:49:02 GMT) Full text and rfc822 format available.

Message #43 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Wed, 01 Feb 2017 02:44:36 +0200
>> I agree it's an ill defined problem ; but then, so is isearching for foo\|bar.
>>
>> I disabled the beeping and screen flashing, so it doesn't bother me, but I get the point.
>>
>> In the end, it's mostly a matter of personal convenience. The patched behavior suits me better, and seems
>> more consistent with the way regexp are handled.
>
> Did you try typing RET right after "C-s M-s w", then typing the word
> to search, and then typing "C-s C-s" again to repeat that?  This might
> be better suited to your needs, I think, and it doesn't require any
> changes.

Since incrementality of word search is not well-defined,
it makes sense to type the word in non-incremental mode indeed.

One problem I noticed is that it's not easy to get back to incremental
mode: after typing a word in non-incremental mode ‘M-s w RET it’
typing ‘C-s’ in the minibuffer doesn't go back to incremental mode.
Also ‘C-s C-s’ doesn't reuse the previous word search.
We need to fix this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Wed, 01 Feb 2017 17:52:01 GMT) Full text and rfc822 format available.

Message #46 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Wed, 01 Feb 2017 18:51:42 +0100
Juri Linkov <juri <at> linkov.net> writes:

> Thanks for confirming that it would be a good solution.  We are
> already using "Pending" indication in the search prompt in other
> places to show that the search is not yet fully accepted.

Ok, then let's just do this.

> This could do the same for word search as well:
>
> diff --git a/lisp/isearch.el b/lisp/isearch.el
> index 5c48c30..3c9dff1 100644
> --- a/lisp/isearch.el
> +++ b/lisp/isearch.el
> @@ -2741,6 +2747,8 @@ (defun isearch-search-fun-default ()
>             (if isearch-forward #'re-search-forward #'re-search-backward)
>             (cond (isearch-regexp-function
>                    (let ((lax (isearch--lax-regexp-function-p)))
> +                    (when lax
> +                      (setq isearch-adjusted t))
>                      (if (functionp isearch-regexp-function)
>                          (funcall isearch-regexp-function string lax)
>                        (word-search-regexp string lax))))

I tried it.  Works as I would expect in *scratch* and dired, but hmm,
not in Info (the prompt just doesn't contain "pending" there).  I tried
with emacs -Q, and in any buffer I started a word search and just began
typing characters.


BTW, a different question: when I delete characters from my input (with
backspace) in a word search and then add some new characters, I somehow
expected that isearch would return to that "pending" state.  But I got
the jumpy (nonlax) incremental search behavior instead.  I don't have an
opinion about that, just wanted to mention it.


Regards,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Thu, 02 Feb 2017 01:31:01 GMT) Full text and rfc822 format available.

Message #49 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Thu, 02 Feb 2017 02:51:08 +0200
> I tried it.  Works as I would expect in *scratch* and dired, but hmm,
> not in Info (the prompt just doesn't contain "pending" there).  I tried
> with emacs -Q, and in any buffer I started a word search and just began
> typing characters.

Thanks for discovering the problem in Info, it will be fixed by the next patch.
It seems to work while I used it to search for the mentions of the word
“pending” in the Emacs manual - there is no one, so we could document it
in (info "(emacs) Word Search") with the second patch below.

> BTW, a different question: when I delete characters from my input (with
> backspace) in a word search and then add some new characters, I somehow
> expected that isearch would return to that "pending" state.  But I got
> the jumpy (nonlax) incremental search behavior instead.  I don't have an
> opinion about that, just wanted to mention it.

“Pending” is not displayed in the prompt while deleting with backspace
since this state in not stored in isearch-cmds.  But I see no problem
because “pending” appears again when you continue typing new characters.

diff --git a/lisp/info.el b/lisp/info.el
index e32b6b3..3eb2021 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -2107,11 +2107,10 @@ (defun Info-isearch-search ()
 	   (cond
 	    (isearch-regexp-function
 	     ;; Lax version of word search
-	     (let ((lax (not (or isearch-nonincremental
-				 (eq (length string)
-				     (length (isearch--state-string
-					      (car isearch-cmds))))))))
-	       (if (functionp isearch-regexp-function)
+	     (let ((lax (isearch--lax-regexp-function-p string)))
+               (when lax
+                 (setq isearch-adjusted t))
+               (if (functionp isearch-regexp-function)
 		   (funcall isearch-regexp-function string lax)
 		 (word-search-regexp string lax))))
 	    (isearch-regexp string)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 5c48c30..856738e 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2718,11 +2718,11 @@ (defun isearch-search-fun ()
 Can be changed via `isearch-search-fun-function' for special needs."
   (funcall (or isearch-search-fun-function 'isearch-search-fun-default)))
 
-(defun isearch--lax-regexp-function-p ()
+(defun isearch--lax-regexp-function-p (&optional string)
   "Non-nil if next regexp-function call should be lax."
   (not (or isearch-nonincremental
            (null (car isearch-cmds))
-           (eq (length isearch-string)
+           (eq (length (or string isearch-string))
                (length (isearch--state-string
                         (car isearch-cmds)))))))
 
@@ -2741,6 +2741,8 @@ (defun isearch-search-fun-default ()
            (if isearch-forward #'re-search-forward #'re-search-backward)
            (cond (isearch-regexp-function
                   (let ((lax (isearch--lax-regexp-function-p)))
+                    (when lax
+                      (setq isearch-adjusted t))
                     (if (functionp isearch-regexp-function)
                         (funcall isearch-regexp-function string lax)
                       (word-search-regexp string lax))))

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index b728258..1296b3b 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -609,6 +609,8 @@ Word Search
 so that the matching can proceed incrementally as you type.  This
 additional laxity does not apply to the lazy highlight
 (@pxref{Incremental Search}), which always matches whole words.
+While you are typing the search string, @samp{Pending} appears in the
+search prompt until you use a search repeating key like @kbd{C-s}.
 
   The word search commands don't perform character folding, and
 toggling lax whitespace matching (@pxref{Lax Search, lax space




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Thu, 02 Feb 2017 21:08:01 GMT) Full text and rfc822 format available.

Message #52 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Thu, 02 Feb 2017 22:07:30 +0100
Juri Linkov <juri <at> linkov.net> writes:

> “Pending” is not displayed in the prompt while deleting with backspace
> since this state in not stored in isearch-cmds.  But I see no problem
> because “pending” appears again when you continue typing new
> characters.

Indeed, it's alright, maybe I had tried with the normal (literal)
search, dunno, I can't reproduce what I remembered to have seen
yesterday.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Fri, 03 Feb 2017 11:05:01 GMT) Full text and rfc822 format available.

Message #55 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 03 Feb 2017 12:04:05 +0100
Juri Linkov <juri <at> linkov.net> writes:

> diff --git a/lisp/info.el b/lisp/info.el
> index e32b6b3..3eb2021 100644

Works ok for me, thanks.

I wonder however if we should similarly also update/improve the manual
page about symbol search.  In particular, this sentence seems to speak
about lax matching:

  "In incremental symbol search, only the beginning of the search string
  is required to match the beginning of a symbol."

but as it stands, the sentence is false - this is only true while still
adding characters to the input.


Thanks,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Fri, 03 Feb 2017 13:07:01 GMT) Full text and rfc822 format available.

Message #58 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: antoine.levitt <at> gmail.com, 25562 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 03 Feb 2017 15:06:11 +0200
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Date: Fri, 03 Feb 2017 12:04:05 +0100
> Cc: 25562 <at> debbugs.gnu.org, Antoine Levitt <antoine.levitt <at> gmail.com>
> 
>   "In incremental symbol search, only the beginning of the search string
>   is required to match the beginning of a symbol."
> 
> but as it stands, the sentence is false - this is only true while still
> adding characters to the input.

"While still adding characters" is not a useful qualification in
incremental search, because the user has no means to tell Emacs when
this phase is over.  I think you meant to say "until the next C-s".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Fri, 03 Feb 2017 14:17:02 GMT) Full text and rfc822 format available.

Message #61 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: antoine.levitt <at> gmail.com, 25562 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 03 Feb 2017 15:16:03 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> "While still adding characters" is not a useful qualification in
> incremental search, because the user has no means to tell Emacs when
> this phase is over.  I think you meant to say "until the next C-s".

Sure.  I didn't suggest to add what I said literally that to the docs.
I rather just wanted to point to a deficiency.  Thanks for the
clarification anyway.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Sun, 05 Feb 2017 23:54:02 GMT) Full text and rfc822 format available.

Message #64 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 25562 <at> debbugs.gnu.org,
 antoine.levitt <at> gmail.com
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Mon, 06 Feb 2017 01:48:21 +0200
>> "While still adding characters" is not a useful qualification in
>> incremental search, because the user has no means to tell Emacs when
>> this phase is over.  I think you meant to say "until the next C-s".
>
> Sure.  I didn't suggest to add what I said literally that to the docs.
> I rather just wanted to point to a deficiency.  Thanks for the
> clarification anyway.

Thanks for the suggestion.  What do you think about this?

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index fa69ba4..a76141e 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -609,6 +609,8 @@ Word Search
 so that the matching can proceed incrementally as you type.  This
 additional laxity does not apply to the lazy highlight
 (@pxref{Incremental Search}), which always matches whole words.
+While you are typing the search string, @samp{Pending} appears in the
+search prompt until you use a search repeating key like @kbd{C-s}.
 
   The word search commands don't perform character folding, and
 toggling lax whitespace matching (@pxref{Lax Search, lax space
@@ -662,7 +664,9 @@ Symbol Search
 direction of the search and the current search string; you can disable
 symbol search by typing @kbd{M-s _} again.  In incremental symbol
 search, only the beginning of the search string is required to match
-the beginning of a symbol.
+the beginning of a symbol while you are typing the search string,
+@samp{Pending} appears in the search prompt until you use a search
+repeating key like @kbd{C-s}.
 
   To begin a nonincremental symbol search, type @kbd{M-s _ @key{RET}}
 for a forward search, or @kbd{M-s _ C-r @key{RET}} or a backward




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 07 Feb 2017 20:03:01 GMT) Full text and rfc822 format available.

Message #67 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 25562 <at> debbugs.gnu.org, antoine.levitt <at> gmail.com
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Tue, 07 Feb 2017 21:02:32 +0100
Juri Linkov <juri <at> linkov.net> writes:

> Thanks for the suggestion.  What do you think about this?

Seems appropriate.

> -the beginning of a symbol.
> +the beginning of a symbol while you are typing the search string,
                                                                   ^
> +@samp{Pending} appears in the search prompt until you use a search
> +repeating key like @kbd{C-s}.

Should we maybe replace the comma with "and" to make clear that those
two parts (lax matching behavior and "Pending" in the prompt) refer
exactly to the same situation?


Michael.




Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Thu, 09 Feb 2017 22:37:02 GMT) Full text and rfc822 format available.

Notification sent to Antoine Levitt <antoine.levitt <at> gmail.com>:
bug acknowledged by developer. (Thu, 09 Feb 2017 22:37:02 GMT) Full text and rfc822 format available.

Message #72 received at 25562-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25562-done <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 10 Feb 2017 00:35:59 +0200
>> -the beginning of a symbol.
>> +the beginning of a symbol while you are typing the search string,
>                                                                    ^
>> +@samp{Pending} appears in the search prompt until you use a search
>> +repeating key like @kbd{C-s}.
>
> Should we maybe replace the comma with "and" to make clear that those
> two parts (lax matching behavior and "Pending" in the prompt) refer
> exactly to the same situation?

Thanks for the help, now installed and closed.




Reply sent to Juri Linkov <juri <at> linkov.net>:
You have taken responsibility. (Thu, 09 Feb 2017 22:37:02 GMT) Full text and rfc822 format available.

Notification sent to Bastian Beischer <bastian.beischer <at> gmail.com>:
bug acknowledged by developer. (Thu, 09 Feb 2017 22:37:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Thu, 09 Feb 2017 23:30:02 GMT) Full text and rfc822 format available.

Message #80 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 10 Feb 2017 01:28:55 +0200
>>> I agree it's an ill defined problem ; but then, so is isearching for foo\|bar.
>>>
>>> I disabled the beeping and screen flashing, so it doesn't bother me, but I get the point.
>>>
>>> In the end, it's mostly a matter of personal convenience. The patched behavior suits me better, and seems
>>> more consistent with the way regexp are handled.
>>
>> Did you try typing RET right after "C-s M-s w", then typing the word
>> to search, and then typing "C-s C-s" again to repeat that?  This might
>> be better suited to your needs, I think, and it doesn't require any
>> changes.
>
> Since incrementality of word search is not well-defined,
> it makes sense to type the word in non-incremental mode indeed.
>
> One problem I noticed is that it's not easy to get back to incremental
> mode: after typing a word in non-incremental mode ‘M-s w RET it’
> typing ‘C-s’ in the minibuffer doesn't go back to incremental mode.

IIRC, it was supposed to work this way, i.e.:

‘M-s w RET it RET’ to quit isearch and search the word nonincrementally,
as documented in (info "(emacs) Word Search")

‘M-s w RET it C-s’ to enter the word and continue searching incrementally,
as documented in the docstrings of ‘isearch-forward-exit-minibuffer’ and
‘isearch-reverse-exit-minibuffer’, but at some point the implementation
deviated from its documentation.  Here is the patch to restore it:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4b35f25..23ca18c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -638,6 +638,9 @@ (defvar isearch-recursive-edit nil)
 ;; Should isearch be terminated after doing one search?
 (defvar isearch-nonincremental nil)
 
+;; New value of isearch-nonincremental after isearch-edit-string.
+(defvar isearch-new-nonincremental nil)
+
 ;; New value of isearch-forward after isearch-edit-string.
 (defvar isearch-new-forward nil)
 
@@ -1228,7 +1231,7 @@ (defmacro with-isearch-suspended (&rest body)
   "Exit Isearch mode, run BODY, and reinvoke the pending search.
 You can update the global isearch variables by setting new values to
 `isearch-new-string', `isearch-new-message', `isearch-new-forward',
-`isearch-new-regexp-function', `isearch-new-case-fold'."
+`isearch-new-nonincremental', `isearch-new-regexp-function', `isearch-new-case-fold'."
   ;; This code is very hairy for several reasons, explained in the code.
   ;; Mainly, isearch-mode must be terminated while editing and then restarted.
   ;; If there were a way to catch any change of buffer from the minibuffer,
@@ -1236,7 +1239,7 @@ (defmacro with-isearch-suspended (&rest body)
   ;; Editing doesn't back up the search point.  Should it?
   `(condition-case nil
       (progn
-	(let ((isearch-nonincremental isearch-nonincremental)
+	(let ((isearch-new-nonincremental isearch-nonincremental)
 
 	      ;; Locally bind all isearch global variables to protect them
 	      ;; from recursive isearching.
@@ -1315,6 +1318,7 @@ (defmacro with-isearch-suspended (&rest body)
 	    (setq isearch-string isearch-new-string
 		  isearch-message isearch-new-message
 		  isearch-forward isearch-new-forward
+		  isearch-nonincremental isearch-new-nonincremental
 		  isearch-regexp-function isearch-new-regexp-function
 		  isearch-case-fold-search isearch-new-case-fold
 		  multi-isearch-current-buffer multi-isearch-current-buffer-new
@@ -1405,22 +1409,22 @@ (defun isearch-edit-string ()
 
 (defun isearch-nonincremental-exit-minibuffer ()
   (interactive)
-  (setq isearch-nonincremental t)
+  (setq isearch-new-nonincremental t)
   (exit-minibuffer))
-;; Changing the value of `isearch-nonincremental' has no effect here,
-;; because `isearch-edit-string' ignores this change.  Thus marked as obsolete.
+;; It makes no sense to change the value of `isearch-new-nonincremental'
+;; from nil to t during `isearch-edit-string'.   Thus marked as obsolete.
 (make-obsolete 'isearch-nonincremental-exit-minibuffer 'exit-minibuffer "24.4")
 
 (defun isearch-forward-exit-minibuffer ()
   "Resume isearching forward from the minibuffer that edits the search string."
   (interactive)
-  (setq isearch-new-forward t)
+  (setq isearch-new-forward t isearch-new-nonincremental nil)
   (exit-minibuffer))
 
 (defun isearch-reverse-exit-minibuffer ()
   "Resume isearching backward from the minibuffer that edits the search string."
   (interactive)
-  (setq isearch-new-forward nil)
+  (setq isearch-new-forward nil isearch-new-nonincremental nil)
   (exit-minibuffer))
 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25562; Package emacs. (Tue, 14 Feb 2017 23:30:03 GMT) Full text and rfc822 format available.

Message #83 received at 25562 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 25562 <at> debbugs.gnu.org
Subject: Re: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Wed, 15 Feb 2017 01:28:39 +0200
> IIRC, it was supposed to work this way, i.e.:
>
> ‘M-s w RET it RET’ to quit isearch and search the word nonincrementally,
> as documented in (info "(emacs) Word Search")
>
> ‘M-s w RET it C-s’ to enter the word and continue searching incrementally,
> as documented in the docstrings of ‘isearch-forward-exit-minibuffer’ and
> ‘isearch-reverse-exit-minibuffer’, but at some point the implementation
> deviated from its documentation.  Here is the patch to restore it:

Installed as well.  I guess updating NEWS is not needed because
it already used to work this way some time ago, and the Emacs manual
mentions this feature in several places, e.g. in ‘(emacs) Repeat Isearch’:
“Type <RET>, `C-s' or `C-r' to finish editing the string and search for it.”




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Mar 2017 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.