[Top][All Lists]

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

bug#25562: 25.1; isearch-forward-word first matches a non-word

From: Juri Linkov
Subject: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Thu, 02 Feb 2017 02:51:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (x86_64-pc-linux-gnu)

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

reply via email to

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