unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* isearch-forward and Info-search
@ 2005-03-09  7:32 Nick Roberts
  2005-03-09  7:59 ` Miles Bader
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Nick Roberts @ 2005-03-09  7:32 UTC (permalink / raw)



If I look for something in an Info manual, I use Info-search (s) and if I
looked for something on a particular page, I would use isearch-forward
(C-s). However, now isearch-forward now also searches the subsequent manual
pages and takes me away from the page I'm interested in. That seems a bit
redundant and also inappropriate. How about, if isearch-forward doesn't find
what its looking in the current file, it starts searching all other files in
the same directory, computer, universe...?

Maybe theres been a long thread about this which I've missed, in which case
I apologise but is there a variable to change this behaviour back to the
old one? Could it be made the default?

I've also noticed that if you abort a search (C-s) before it gets to the end
of the manual the formatting of the links on the current page gets messed up.


Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-09  7:32 isearch-forward and Info-search Nick Roberts
@ 2005-03-09  7:59 ` Miles Bader
  2005-03-10  2:02   ` Richard Stallman
  2005-03-10  6:29   ` Juri Linkov
  2005-03-10  6:33 ` Juri Linkov
  2005-03-12  2:23 ` Juri Linkov
  2 siblings, 2 replies; 18+ messages in thread
From: Miles Bader @ 2005-03-09  7:59 UTC (permalink / raw)
  Cc: emacs-devel

On Wed, 9 Mar 2005 20:32:35 +1300, Nick Roberts <nickrob@snap.net.nz> wrote:
> If I look for something in an Info manual, I use Info-search (s) and if I
> looked for something on a particular page, I would use isearch-forward
> (C-s). However, now isearch-forward now also searches the subsequent manual
> pages and takes me away from the page I'm interested in.

I think it would be a lot less annoying if it at least changed the
prompt to say what it was doing, in the manner of a wrapped isearch
("I-search in node ...: " ?).

Maybe it could even act more like wrapped i-search, and fail once,
before proceeding to the next info page if you hit C-s again.

-Miles
-- 
Do not taunt Happy Fun Ball.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-09  7:59 ` Miles Bader
@ 2005-03-10  2:02   ` Richard Stallman
  2005-03-10  6:29   ` Juri Linkov
  1 sibling, 0 replies; 18+ messages in thread
From: Richard Stallman @ 2005-03-10  2:02 UTC (permalink / raw)
  Cc: nickrob, emacs-devel

    I think it would be a lot less annoying if it at least changed the
    prompt to say what it was doing, in the manner of a wrapped isearch
    ("I-search in node ...: " ?).

    Maybe it could even act more like wrapped i-search, and fail once,
    before proceeding to the next info page if you hit C-s again.

I agree (I suggested both of these things).  Would you like to
implement them?  Juri, could you possibly do so?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-09  7:59 ` Miles Bader
  2005-03-10  2:02   ` Richard Stallman
@ 2005-03-10  6:29   ` Juri Linkov
  2005-03-10  7:56     ` Nick Roberts
                       ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Juri Linkov @ 2005-03-10  6:29 UTC (permalink / raw)
  Cc: nickrob, emacs-devel, miles

Miles Bader <snogglethorpe@gmail.com> writes:
> I think it would be a lot less annoying if it at least changed the
> prompt to say what it was doing, in the manner of a wrapped isearch
> ("I-search in node ...: " ?).
>
> Maybe it could even act more like wrapped i-search, and fail once,
> before proceeding to the next info page if you hit C-s again.

It seems this is the most reasonable default behavior.
But I also think it would be too annoying to fail before
leaving every Info node.  It would be better to fail only
in the first Info node where isearch was started.  Of course,
this doesn't preclude creating at least four different options
for the `Info-isearch-search' variable:

- never fail (current behavior)
- fail only in the node where isearch was started (proposed default)
- fail in every node visited by isearch (somebody may like this)
- fail and wrap to the beginning of the current node (old behavior)

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-09  7:32 isearch-forward and Info-search Nick Roberts
  2005-03-09  7:59 ` Miles Bader
@ 2005-03-10  6:33 ` Juri Linkov
  2005-03-10 17:19   ` Drew Adams
  2005-03-12  2:23 ` Juri Linkov
  2 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2005-03-10  6:33 UTC (permalink / raw)
  Cc: emacs-devel

Nick Roberts <nickrob@snap.net.nz> writes:
> Maybe theres been a long thread about this which I've missed, in which case
> I apologise but is there a variable to change this behaviour back to the
> old one?

The variable is `Info-isearch-search' and when set to nil it changes
the behavior to the old one.

> Could it be made the default?

Let's try to fix the new behavior and see if it will satisfy most
people.  Would you like it if isearch failed before proceeding to the
next Info node?

> I've also noticed that if you abort a search (C-s) before it gets to the end
> of the manual the formatting of the links on the current page gets messed up.

This looks like a bug, but I can't reproduce it.  Could you provide
a precise receipt to reproduce it?

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-10  6:29   ` Juri Linkov
@ 2005-03-10  7:56     ` Nick Roberts
  2005-03-10 17:20     ` Drew Adams
  2005-03-11  1:48     ` Richard Stallman
  2 siblings, 0 replies; 18+ messages in thread
From: Nick Roberts @ 2005-03-10  7:56 UTC (permalink / raw)
  Cc: snogglethorpe, emacs-devel, miles

 > > I think it would be a lot less annoying if it at least changed the
 > > prompt to say what it was doing, in the manner of a wrapped isearch
 > > ("I-search in node ...: " ?).
 > >
 > > Maybe it could even act more like wrapped i-search, and fail once,
 > > before proceeding to the next info page if you hit C-s again.
 > 
 > It seems this is the most reasonable default behavior.
 > But I also think it would be too annoying to fail before
 > leaving every Info node.  It would be better to fail only
 > in the first Info node where isearch was started.  Of course,
 > this doesn't preclude creating at least four different options
 > for the `Info-isearch-search' variable:
 > 
 > - never fail (current behavior)
 > - fail only in the node where isearch was started (proposed default)
 > - fail in every node visited by isearch (somebody may like this)
 > - fail and wrap to the beginning of the current node (old behavior)

This sounds a like a good idea. The proposed default would also be my
preferred behaviour.

Me> > I've also noticed that if you abort a search (C-s) before it gets to the
Me> > end of the manual the formatting of the links on the current page gets
Me> > messed up.

> This looks like a bug, but I can't reproduce it.  Could you provide
> a precise receipt to reproduce it?

I can't seem to reproduce it. All the links after a certain point (where the
search had reached displayed as ordinary text like this:

Important Text-Changing Commands
* Mark::	        The mark: how to delimit a ``region'' of text.
* Killing::	        Killing (cutting) text.
* Yanking::	        Recovering killed text.  Moving text. (Pasting.)

If I can remember exactly what I did, I'll file a bug report.


Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: isearch-forward and Info-search
  2005-03-10  6:33 ` Juri Linkov
@ 2005-03-10 17:19   ` Drew Adams
  2005-03-11  7:28     ` Juri Linkov
  0 siblings, 1 reply; 18+ messages in thread
From: Drew Adams @ 2005-03-10 17:19 UTC (permalink / raw)


    Would you like it if isearch failed before proceeding to the
    next Info node?

I would. I suggested this long ago. It should first wrap, as Richard
suggested. After the entire Info node has been searched, it should fail. A
subsequent invocation should continue through the manual.

IOW, isearch the node completely first (wrapping), then inform the user that
there are no more occurrences in the node, then continue on to other nodes.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: isearch-forward and Info-search
  2005-03-10  6:29   ` Juri Linkov
  2005-03-10  7:56     ` Nick Roberts
@ 2005-03-10 17:20     ` Drew Adams
  2005-03-11  1:48     ` Richard Stallman
  2 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2005-03-10 17:20 UTC (permalink / raw)
  Cc: nickrob, miles, emacs-devel

    I also think it would be too annoying to fail before
    leaving every Info node.  It would be better to fail only
    in the first Info node where isearch was started.

Good point - I agree.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-10  6:29   ` Juri Linkov
  2005-03-10  7:56     ` Nick Roberts
  2005-03-10 17:20     ` Drew Adams
@ 2005-03-11  1:48     ` Richard Stallman
  2 siblings, 0 replies; 18+ messages in thread
From: Richard Stallman @ 2005-03-11  1:48 UTC (permalink / raw)
  Cc: miles, nickrob, snogglethorpe, emacs-devel

    It seems this is the most reasonable default behavior.
    But I also think it would be too annoying to fail before
    leaving every Info node.  It would be better to fail only
    in the first Info node where isearch was started.

Yes, I think that is right.

Could you please do it?

      Of course,
    this doesn't preclude creating at least four different options

I'd rather keep things simple and not have this option.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-10 17:19   ` Drew Adams
@ 2005-03-11  7:28     ` Juri Linkov
  2005-03-11  8:15       ` Nick Roberts
  2005-03-11 14:40       ` Drew Adams
  0 siblings, 2 replies; 18+ messages in thread
From: Juri Linkov @ 2005-03-11  7:28 UTC (permalink / raw)
  Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
>     Would you like it if isearch failed before proceeding to the
>     next Info node?
>
> I would. I suggested this long ago. It should first wrap, as Richard
> suggested. After the entire Info node has been searched, it should
> fail. A subsequent invocation should continue through the manual.
>
> IOW, isearch the node completely first (wrapping), then inform the
> user that there are no more occurrences in the node, then continue
> on to other nodes.

IMO, this behavior is too confusing.  Imagine the situation where
isearch was wrapped once and after overwrapping it landed again on the
first matching point.  Now the user sees lazy-highlighted matches
below point, and when he types C-s again, isearch skips these matches
and continues on to the next node.  Even though these matches were
visited once, the user may forget this, so it would be confusing when
the user expects that C-s will go to the next lazy-highlighted match,
but it goes to the next node instead.  It's better is to go to the
next node after the first failure without wrapping.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-11  7:28     ` Juri Linkov
@ 2005-03-11  8:15       ` Nick Roberts
  2005-03-11 14:40       ` Drew Adams
  1 sibling, 0 replies; 18+ messages in thread
From: Nick Roberts @ 2005-03-11  8:15 UTC (permalink / raw)
  Cc: Drew Adams, emacs-devel

 > >     Would you like it if isearch failed before proceeding to the
 > >     next Info node?
 > >
 > > I would. I suggested this long ago. It should first wrap, as Richard
 > > suggested. After the entire Info node has been searched, it should
 > > fail. A subsequent invocation should continue through the manual.
 > >
 > > IOW, isearch the node completely first (wrapping), then inform the
 > > user that there are no more occurrences in the node, then continue
 > > on to other nodes.
 > 
 > IMO, this behavior is too confusing...

I agree. isearch already does a wrapped search around the manual, I don't
think it needs to wrap around each node. I think the others were just talking
about it *failing* like wrapped isearch and changing the prompt.

Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: isearch-forward and Info-search
  2005-03-11  7:28     ` Juri Linkov
  2005-03-11  8:15       ` Nick Roberts
@ 2005-03-11 14:40       ` Drew Adams
  1 sibling, 0 replies; 18+ messages in thread
From: Drew Adams @ 2005-03-11 14:40 UTC (permalink / raw)
  Cc: emacs-devel

    >     Would you like it if isearch failed before proceeding to the
    >     next Info node?
    >
    > I would. I suggested this long ago. It should first wrap, as Richard
    > suggested. After the entire Info node has been searched, it should
    > fail. A subsequent invocation should continue through the manual.
    > IOW, isearch the node completely first (wrapping), then inform the
    > user that there are no more occurrences in the node, then continue
    > on to other nodes.

    IMO, this behavior is too confusing.

I agree, and I don't know why I suggested here to first wrap. In fact, what
you describe was what I suggested originally:

          > But it would be better if
          > normal C-s isearch searched through multiple nodes as well.

    I like being able to confine an isearch to the current node.
    Currently, I can use `s' for global search and `C-s' (or
    `C-M-s') for local (node) search.

    So, to me, it would be desirable to have some indication that
    the end of the current node was reached without finding another
    occurrence of the string - e.g. "Failing isearch in node Foo:
    bar". Except for being able to overwrap isearch in the node (no
    great loss), this would give the advantages of both approaches
    (local and global search)....
    IOW, why not have two levels of isearch "failure": 1) no more
    in the current node, 2) no more in the current Info "manual"?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-09  7:32 isearch-forward and Info-search Nick Roberts
  2005-03-09  7:59 ` Miles Bader
  2005-03-10  6:33 ` Juri Linkov
@ 2005-03-12  2:23 ` Juri Linkov
  2005-03-12 13:47   ` Stefan Monnier
  2 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2005-03-12  2:23 UTC (permalink / raw)
  Cc: emacs-devel

Below is an implementation that works as follows:
after an attempt to leave the first Info node,
isearch fails with the following message:

    Failing I-search: search string [failed in current node]

After leaving the first Info node with subsequent C-s or C-r,
isearch doesn't fail more in other Info nodes.  In the end/beginning
of the manual isearch fails with the usual message:

    Failing I-search: search string

After the next C-s/C-r it wraps to the top/final node.

In the implementation below it would be possible to reuse
`isearch-invalid-regexp' to hold the error message, but this is not
a clean solution.  Adding a new special variable `isearch-error' looks
better.  When set to a string value it adds the error message in
square brackets to the end of the echo area.  `isearch-error' is set
in `isearch-search' via the second argument of the `search-failed'
signal (its first argument is the failed search string).

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.256
diff -u -r1.256 isearch.el
--- lisp/isearch.el	19 Feb 2005 20:52:47 -0000	1.256
+++ lisp/isearch.el	12 Mar 2005 02:22:55 -0000
@@ -438,6 +438,7 @@
 (defvar isearch-message "") ; text-char-description version of isearch-string
 
 (defvar isearch-success t)		; Searching is currently successful.
+(defvar isearch-error nil)		; Error message for failed search.
 (defvar isearch-invalid-regexp nil)	; Regexp not well formed.
 (defvar isearch-within-brackets nil)	; Regexp has unclosed [.
 (defvar isearch-other-end nil)	; Start (end) of match if forward (backward).
@@ -1146,10 +1147,11 @@
 	;; If already have what to search for, repeat it.
 	(or isearch-success
 	    (progn
+	      ;; Set isearch-wrapped before calling isearch-wrap-function
+	      (setq isearch-wrapped t)
 	      (if isearch-wrap-function
 		  (funcall isearch-wrap-function)
-	        (goto-char (if isearch-forward (point-min) (point-max))))
-	      (setq isearch-wrapped t))))
+	        (goto-char (if isearch-forward (point-min) (point-max)))))))
     ;; C-s in reverse or C-r in forward, change direction.
     (setq isearch-forward (not isearch-forward)))
 
@@ -1384,6 +1386,7 @@
 		     (min isearch-opoint isearch-barrier))))
 	(progn
 	  (setq isearch-success t
+		isearch-error nil
 		isearch-invalid-regexp nil
 		isearch-within-brackets nil
 		isearch-other-end (match-end 0))
@@ -2013,6 +2016,9 @@
   (concat (if c-q-hack "^Q" "")
 	  (if isearch-invalid-regexp
 	      (concat " [" isearch-invalid-regexp "]")
+	    "")
+	  (if (and (not isearch-success) isearch-error)
+	      (concat " [" isearch-error "]")
 	    "")))
 
 \f
@@ -2050,7 +2056,7 @@
 	    (search-spaces-regexp search-whitespace-regexp)
 	    (retry t))
 	(if isearch-regexp (setq isearch-invalid-regexp nil))
-	(setq isearch-within-brackets nil)
+	(setq isearch-within-brackets nil isearch-error nil)
 	(while retry
 	  (setq isearch-success
 		(funcall
@@ -2081,6 +2087,11 @@
 	  "\\`Premature \\|\\`Unmatched \\|\\`Invalid "
 	  isearch-invalid-regexp)
 	 (setq isearch-invalid-regexp "incomplete input")))
+
+    (search-failed
+     (setq isearch-success nil)
+     (setq isearch-error (nth 2 lossage)))
+
     (error
      ;; stack overflow in regexp search.
      (setq isearch-invalid-regexp (format "%s" lossage))))

Index: lisp/info.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
retrieving revision 1.419
diff -u -r1.419 info.el
--- lisp/info.el	12 Mar 2005 02:18:32 -0000	1.419
+++ lisp/info.el	12 Mar 2005 02:22:18 -0000
@@ -1514,6 +1514,13 @@
 		  (setq found (point) beg-found (if backward (match-end 0)
 						  (match-beginning 0)))
 		(setq give-up t))))))
+
+      (when (and Info-isearch-search isearch-mode
+		 (not Info-isearch-first-node)
+		 (or give-up (and found (not (and (> found opoint-min)
+						  (< found opoint-max))))))
+	(signal 'search-failed (list regexp "failed in current node")))
+
       ;; If no subfiles, give error now.
       (if give-up
 	  (if (null Info-current-subfile)
@@ -1650,25 +1657,28 @@
 (defun Info-isearch-search ()
   (if Info-isearch-search
       (lambda (string &optional bound noerror count)
-	(condition-case nil
-	    (if isearch-word
-		(Info-search (concat "\\b" (replace-regexp-in-string
-					    "\\W+" "\\\\W+"
-					    (replace-regexp-in-string
-					     "^\\W+\\|\\W+$" "" string)) "\\b")
-			     bound noerror count
-			     (unless isearch-forward 'backward))
-	      (Info-search (if isearch-regexp string (regexp-quote string))
-			   bound noerror count
-			   (unless isearch-forward 'backward))
-	      (point))
-	  (error nil)))
+	(if isearch-word
+	    (Info-search (concat "\\b" (replace-regexp-in-string
+					"\\W+" "\\\\W+"
+					(replace-regexp-in-string
+					 "^\\W+\\|\\W+$" "" string)) "\\b")
+			 bound noerror count
+			 (unless isearch-forward 'backward))
+	  (Info-search (if isearch-regexp string (regexp-quote string))
+		       bound noerror count
+		       (unless isearch-forward 'backward))
+	  (point)))
     (let ((isearch-search-fun-function nil))
       (isearch-search-fun))))
 
 (defun Info-isearch-wrap ()
-  (when Info-isearch-search
-    (if isearch-forward (Info-top-node) (Info-final-node))
+  (if Info-isearch-search
+      (if Info-isearch-first-node
+	  (progn
+	    (if isearch-forward (Info-top-node) (Info-final-node))
+	    (goto-char (if isearch-forward (point-min) (point-max))))
+	(setq Info-isearch-first-node Info-current-node)
+	(setq isearch-wrapped nil))
     (goto-char (if isearch-forward (point-min) (point-max)))))
 
 (defun Info-isearch-push-state ()
@@ -1680,6 +1690,9 @@
            (string= Info-current-node node))
       (progn (Info-find-node file node) (sit-for 0))))
 
+(defvar Info-isearch-first-node nil)
+(defun Info-isearch-start ()
+  (setq Info-isearch-first-node nil))
 \f
 (defun Info-extract-pointer (name &optional errorname)
   "Extract the value of the node-pointer named NAME.
@@ -3217,6 +3230,7 @@
   (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
   (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
   (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+  (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
   (set (make-local-variable 'isearch-search-fun-function)
        'Info-isearch-search)
   (set (make-local-variable 'isearch-wrap-function)

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-12  2:23 ` Juri Linkov
@ 2005-03-12 13:47   ` Stefan Monnier
  2005-03-13  1:00     ` Juri Linkov
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2005-03-12 13:47 UTC (permalink / raw)
  Cc: Nick Roberts, emacs-devel

> In the implementation below it would be possible to reuse
> `isearch-invalid-regexp' to hold the error message, but this is not
> a clean solution.  Adding a new special variable `isearch-error' looks

The implementation looks clean.  I just suggest that we should simply
replace isearch-invalid-regexp with isearch-error (there can only be one
error at any given time, either a search failure or an invalid regexp, or
...).


        Stefan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-12 13:47   ` Stefan Monnier
@ 2005-03-13  1:00     ` Juri Linkov
  2005-03-13 21:15       ` Nick Roberts
  2005-03-29 12:17       ` Kai Großjohann
  0 siblings, 2 replies; 18+ messages in thread
From: Juri Linkov @ 2005-03-13  1:00 UTC (permalink / raw)
  Cc: nickrob, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> The implementation looks clean.  I just suggest that we should simply
> replace isearch-invalid-regexp with isearch-error (there can only be one
> error at any given time, either a search failure or an invalid regexp, or
> ...).

OK.

I also removed `isearch-within-brackets' because it is used nowhere
within Emacs.  And added `condition-case' around the call to
`isearch-search-fun' in `isearch-lazy-highlight-search' to return nil
in case of error which allows `isearch-lazy-highlight-update' to try to
highlight matches from the window beginning (needed for Info isearch).

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.256
diff -u -r1.256 isearch.el
--- lisp/isearch.el	19 Feb 2005 20:52:47 -0000	1.256
+++ lisp/isearch.el	13 Mar 2005 00:55:45 -0000
@@ -437,9 +437,8 @@
 (defvar isearch-string "")  ; The current search string.
 (defvar isearch-message "") ; text-char-description version of isearch-string
 
-(defvar isearch-success t)		; Searching is currently successful.
-(defvar isearch-invalid-regexp nil)	; Regexp not well formed.
-(defvar isearch-within-brackets nil)	; Regexp has unclosed [.
+(defvar isearch-success t)	; Searching is currently successful.
+(defvar isearch-error nil)	; Error message for failed search.
 (defvar isearch-other-end nil)	; Start (end) of match if forward (backward).
 (defvar isearch-wrapped nil)	; Searching restarted from the top (bottom).
 (defvar isearch-barrier 0)
@@ -640,8 +639,7 @@
 	isearch-barrier (point)
 	isearch-adjusted nil
 	isearch-yank-flag nil
-	isearch-invalid-regexp nil
-	isearch-within-brackets nil
+	isearch-error nil
 	isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed)
 					(> (window-height)
 					   (* 4
@@ -867,7 +865,7 @@
 (defsubst isearch-word-state (frame)
   "Return the search-by-word flag in FRAME."
   (aref frame 6))
-(defsubst isearch-invalid-regexp-state (frame)
+(defsubst isearch-error-state (frame)
   "Return the regexp error message in FRAME, or nil if its regexp is valid."
   (aref frame 7))
 (defsubst isearch-wrapped-state (frame)
@@ -876,15 +874,12 @@
 (defsubst isearch-barrier-state (frame)
   "Return the barrier value in FRAME."
   (aref frame 9))
-(defsubst isearch-within-brackets-state (frame)
-  "Return the in-character-class flag in FRAME."
-  (aref frame 10))
 (defsubst isearch-case-fold-search-state (frame)
   "Return the case-folding flag in FRAME."
-  (aref frame 11))
+  (aref frame 10))
 (defsubst isearch-pop-fun-state (frame)
   "Return the function restoring the mode-specific isearch state in FRAME."
-  (aref frame 12))
+  (aref frame 11))
 
 (defun isearch-top-state ()
   (let ((cmd (car isearch-cmds)))
@@ -894,10 +889,9 @@
 	  isearch-forward (isearch-forward-state cmd)
 	  isearch-other-end (isearch-other-end-state cmd)
 	  isearch-word (isearch-word-state cmd)
-	  isearch-invalid-regexp (isearch-invalid-regexp-state cmd)
+	  isearch-error (isearch-error-state cmd)
 	  isearch-wrapped (isearch-wrapped-state cmd)
 	  isearch-barrier (isearch-barrier-state cmd)
-	  isearch-within-brackets (isearch-within-brackets-state cmd)
 	  isearch-case-fold-search (isearch-case-fold-search-state cmd))
     (if (functionp (isearch-pop-fun-state cmd))
 	(funcall (isearch-pop-fun-state cmd) cmd))
@@ -912,8 +906,8 @@
 	(cons (vector isearch-string isearch-message (point)
 		      isearch-success isearch-forward isearch-other-end
 		      isearch-word
-		      isearch-invalid-regexp isearch-wrapped isearch-barrier
-		      isearch-within-brackets isearch-case-fold-search
+		      isearch-error isearch-wrapped isearch-barrier
+		      isearch-case-fold-search
 		      (if isearch-push-state-function
 			  (funcall isearch-push-state-function)))
 	      isearch-cmds)))
@@ -976,8 +970,7 @@
 	      (isearch-barrier isearch-barrier)
 	      (isearch-adjusted isearch-adjusted)
 	      (isearch-yank-flag isearch-yank-flag)
-	      (isearch-invalid-regexp isearch-invalid-regexp)
-	      (isearch-within-brackets isearch-within-brackets)
+	      (isearch-error isearch-error)
   ;;; Don't bind this.  We want isearch-search, below, to set it.
   ;;; And the old value won't matter after that.
   ;;;	    (isearch-other-end isearch-other-end)
@@ -1124,7 +1117,7 @@
         (isearch-cancel))
     ;; If search is failing, or has an incomplete regexp,
     ;; rub out until it is once more successful.
-    (while (or (not isearch-success) isearch-invalid-regexp)
+    (while (or (not isearch-success) isearch-error)
       (isearch-pop-state))
     (isearch-update)))
 
@@ -1146,10 +1139,11 @@
 	;; If already have what to search for, repeat it.
 	(or isearch-success
 	    (progn
+	      ;; Set isearch-wrapped before calling isearch-wrap-function
+	      (setq isearch-wrapped t)
 	      (if isearch-wrap-function
 		  (funcall isearch-wrap-function)
-	        (goto-char (if isearch-forward (point-min) (point-max))))
-	      (setq isearch-wrapped t))))
+	        (goto-char (if isearch-forward (point-min) (point-max)))))))
     ;; C-s in reverse or C-r in forward, change direction.
     (setq isearch-forward (not isearch-forward)))
 
@@ -1384,8 +1378,7 @@
 		     (min isearch-opoint isearch-barrier))))
 	(progn
 	  (setq isearch-success t
-		isearch-invalid-regexp nil
-		isearch-within-brackets nil
+		isearch-error nil
 		isearch-other-end (match-end 0))
 	  (if (and (eq isearch-case-fold-search t) search-upper-case)
 	      (setq isearch-case-fold-search
@@ -1432,8 +1425,8 @@
 				(not want-backslash))
 	     ;; We have to check 2 stack frames because the last might be
 	     ;; invalid just because of a backslash.
-	     (or (not isearch-invalid-regexp)
-		 (not (isearch-invalid-regexp-state (cadr isearch-cmds)))
+	     (or (not isearch-error)
+		 (not (isearch-error-state (cadr isearch-cmds)))
 		 allow-invalid))
     (if to-barrier
 	(progn (goto-char isearch-barrier)
@@ -1448,7 +1441,7 @@
 	;; Also skip over postfix operators -- though horrid,
 	;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal.
 	(while (and previous
-		    (or (isearch-invalid-regexp-state frame)
+		    (or (isearch-error-state frame)
 			(let* ((string (isearch-string-state frame))
 			       (lchar (aref string (1- (length string)))))
 			  ;; The operators aren't always operators; check
@@ -1981,11 +1974,10 @@
   ;; If about to search, and previous search regexp was invalid,
   ;; check that it still is.  If it is valid now,
   ;; let the message we display while searching say that it is valid.
-  (and isearch-invalid-regexp ellipsis
+  (and isearch-error ellipsis
        (condition-case ()
 	   (progn (re-search-forward isearch-string (point) t)
-		  (setq isearch-invalid-regexp nil
-			isearch-within-brackets nil))
+		  (setq isearch-error nil))
 	 (error nil)))
   ;; If currently failing, display no ellipsis.
   (or isearch-success (setq ellipsis nil))
@@ -2011,8 +2003,8 @@
 
 (defun isearch-message-suffix (&optional c-q-hack ellipsis)
   (concat (if c-q-hack "^Q" "")
-	  (if isearch-invalid-regexp
-	      (concat " [" isearch-invalid-regexp "]")
+	  (if isearch-error
+	      (concat " [" isearch-error "]")
 	    "")))
 
 \f
@@ -2049,8 +2041,7 @@
 	    (case-fold-search isearch-case-fold-search)
 	    (search-spaces-regexp search-whitespace-regexp)
 	    (retry t))
-	(if isearch-regexp (setq isearch-invalid-regexp nil))
-	(setq isearch-within-brackets nil)
+	(setq isearch-error nil)
 	(while retry
 	  (setq isearch-success
 		(funcall
@@ -2074,16 +2065,19 @@
 	  (setq isearch-success nil))
 
     (invalid-regexp
-     (setq isearch-invalid-regexp (car (cdr lossage)))
-     (setq isearch-within-brackets (string-match "\\`Unmatched \\["
-						 isearch-invalid-regexp))
+     (setq isearch-error (car (cdr lossage)))
      (if (string-match
 	  "\\`Premature \\|\\`Unmatched \\|\\`Invalid "
-	  isearch-invalid-regexp)
-	 (setq isearch-invalid-regexp "incomplete input")))
+	  isearch-error)
+	 (setq isearch-error "incomplete input")))
+
+    (search-failed
+     (setq isearch-success nil)
+     (setq isearch-error (nth 2 lossage)))
+
     (error
      ;; stack overflow in regexp search.
-     (setq isearch-invalid-regexp (format "%s" lossage))))
+     (setq isearch-error (format "%s" lossage))))
 
   (if isearch-success
       nil
@@ -2315,7 +2309,7 @@
 ;;    `isearch-word' and `isearch-regexp';
 ;;  - the direction of the current search is expected to be given by
 ;;    `isearch-forward';
-;;  - the variable `isearch-invalid-regexp' is expected to be true
+;;  - the variable `isearch-error' is expected to be true
 ;;    iff `isearch-string' is an invalid regexp.
 
 (defvar isearch-lazy-highlight-overlays nil)
@@ -2369,7 +2363,7 @@
                          isearch-lazy-highlight-window-end))))
     ;; something important did indeed change
     (isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays
-    (when (not isearch-invalid-regexp)
+    (when (not isearch-error)
       (setq isearch-lazy-highlight-start-limit beg
 	    isearch-lazy-highlight-end-limit end)
       (setq isearch-lazy-highlight-window       (selected-window)
@@ -2391,18 +2385,20 @@
 Attempt to do the search exactly the way the pending isearch would."
   (let ((case-fold-search isearch-case-fold-search)
 	(search-spaces-regexp search-whitespace-regexp))
-    (funcall (isearch-search-fun)
-             isearch-string
-             (if isearch-forward
-                 (min (or isearch-lazy-highlight-end-limit (point-max))
-		      (if isearch-lazy-highlight-wrapped
-			  isearch-lazy-highlight-start
-			(window-end)))
-               (max (or isearch-lazy-highlight-start-limit (point-min))
-		    (if isearch-lazy-highlight-wrapped
-			isearch-lazy-highlight-end
-		      (window-start))))
-             t)))
+    (condition-case nil
+	(funcall (isearch-search-fun)
+		 isearch-string
+		 (if isearch-forward
+		     (min (or isearch-lazy-highlight-end-limit (point-max))
+			  (if isearch-lazy-highlight-wrapped
+			      isearch-lazy-highlight-start
+			    (window-end)))
+		   (max (or isearch-lazy-highlight-start-limit (point-min))
+			(if isearch-lazy-highlight-wrapped
+			    isearch-lazy-highlight-end
+			  (window-start))))
+		 t)
+      (error nil))))
 
 (defun isearch-lazy-highlight-update ()
   "Update highlighting of other matches for current search."

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-13  1:00     ` Juri Linkov
@ 2005-03-13 21:15       ` Nick Roberts
  2005-03-29 12:17       ` Kai Großjohann
  1 sibling, 0 replies; 18+ messages in thread
From: Nick Roberts @ 2005-03-13 21:15 UTC (permalink / raw)
  Cc: Stefan Monnier, emacs-devel

 > > The implementation looks clean.  I just suggest that we should simply
 > > replace isearch-invalid-regexp with isearch-error (there can only be one
 > > error at any given time, either a search failure or an invalid regexp, or
 > > ...).
 > 
 > OK.
 > 
 > I also removed `isearch-within-brackets' because it is used nowhere
 > within Emacs.  And added `condition-case' around the call to
 > `isearch-search-fun' in `isearch-lazy-highlight-search' to return nil
 > in case of error which allows `isearch-lazy-highlight-update' to try to
 > highlight matches from the window beginning (needed for Info isearch).

I like the way this works. Thanks for fixing it.

Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-13  1:00     ` Juri Linkov
  2005-03-13 21:15       ` Nick Roberts
@ 2005-03-29 12:17       ` Kai Großjohann
  2005-03-29 13:48         ` Stefan Monnier
  1 sibling, 1 reply; 18+ messages in thread
From: Kai Großjohann @ 2005-03-29 12:17 UTC (permalink / raw)


Juri Linkov <juri@jurta.org> writes:

> I also removed `isearch-within-brackets' because it is used nowhere
> within Emacs.

I think the intent of that was to allow SPC to be a shortcut to mean
"any whitespace", whereas SPC inside brackets still stands for itself.

But I lost track of the discussion at some point, so I'm not sure what
is the currently agreed way to handle whitespace search.  There was
also talk about making SPC be special in normal isearch (as opposed to
regexp isearch).

Kai

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: isearch-forward and Info-search
  2005-03-29 12:17       ` Kai Großjohann
@ 2005-03-29 13:48         ` Stefan Monnier
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2005-03-29 13:48 UTC (permalink / raw)
  Cc: emacs-devel

>> I also removed `isearch-within-brackets' because it is used nowhere
>> within Emacs.

> I think the intent of that was to allow SPC to be a shortcut to mean
> "any whitespace", whereas SPC inside brackets still stands for itself.

IIRC it's a left over of a previous implementation of that feature.


        Stefan

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2005-03-29 13:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-09  7:32 isearch-forward and Info-search Nick Roberts
2005-03-09  7:59 ` Miles Bader
2005-03-10  2:02   ` Richard Stallman
2005-03-10  6:29   ` Juri Linkov
2005-03-10  7:56     ` Nick Roberts
2005-03-10 17:20     ` Drew Adams
2005-03-11  1:48     ` Richard Stallman
2005-03-10  6:33 ` Juri Linkov
2005-03-10 17:19   ` Drew Adams
2005-03-11  7:28     ` Juri Linkov
2005-03-11  8:15       ` Nick Roberts
2005-03-11 14:40       ` Drew Adams
2005-03-12  2:23 ` Juri Linkov
2005-03-12 13:47   ` Stefan Monnier
2005-03-13  1:00     ` Juri Linkov
2005-03-13 21:15       ` Nick Roberts
2005-03-29 12:17       ` Kai Großjohann
2005-03-29 13:48         ` Stefan Monnier

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