unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 25562@debbugs.gnu.org
Subject: bug#25562: 25.1; isearch-forward-word first matches a non-word
Date: Fri, 10 Feb 2017 01:28:55 +0200	[thread overview]
Message-ID: <87h943lzg8.fsf@localhost> (raw)
In-Reply-To: <87zii6u4cr.fsf@mail.linkov.net> (Juri Linkov's message of "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.

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





  reply	other threads:[~2017-02-09 23:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-28 11:23 bug#25562: 25.1; isearch-forward-word first matches a non-word Antoine Levitt
2017-01-29  0:29 ` Juri Linkov
2017-01-29  6:52   ` Antoine Levitt
2017-01-30  0:30     ` Juri Linkov
2017-01-30  8:12       ` Antoine Levitt
2017-01-30 23:24         ` Juri Linkov
2017-01-31  3:28           ` Eli Zaretskii
     [not found]             ` <CABfD5m0NxLQ5rbfXcXvxXLDK6c_88Rzsu-bwRj8gJNdh3cinSw@mail.gmail.com>
     [not found]               ` <CABfD5m1wB_z3aLsW_vOj0Vx6+1H48bUeWs46ORW0fFBUsNB0ew@mail.gmail.com>
2017-01-31  7:57                 ` Antoine Levitt
2017-01-31 15:38                   ` Eli Zaretskii
2017-02-01  0:44                     ` Juri Linkov
2017-02-09 23:28                       ` Juri Linkov [this message]
2017-02-14 23:28                         ` Juri Linkov
2017-01-31 16:45     ` Michael Heerdegen
2017-01-31 16:51   ` Michael Heerdegen
2017-02-01  0:38     ` Juri Linkov
2017-02-01 17:51       ` Michael Heerdegen
2017-02-02  0:51         ` Juri Linkov
2017-02-02 21:07           ` Michael Heerdegen
2017-02-03 11:04           ` Michael Heerdegen
2017-02-03 13:06             ` Eli Zaretskii
2017-02-03 14:16               ` Michael Heerdegen
2017-02-05 23:48                 ` Juri Linkov
2017-02-07 20:02                   ` Michael Heerdegen
2017-02-09 22:35                     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h943lzg8.fsf@localhost \
    --to=juri@linkov.net \
    --cc=25562@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).