changeset 60615:643e6516a779

(Info-isearch-initial-node): New internal variable. (Info-search): Signal an error in isearch mode when search leaves the initial node. Signal an error when `bound' is non-nil and nothing was found in the current subfile. (Info-isearch-search): Remove `condition-case'. (Info-isearch-wrap): Don't wrap when search failed during leaving the initial node. If `Info-isearch-search' is nil, wrap around the current node. (Info-isearch-start): New fun. (Info-mode): Add buffer-local hook `Info-isearch-start' to `isearch-mode-hook'.
author Juri Linkov <juri@jurta.org>
date Tue, 15 Mar 2005 10:46:00 +0000
parents 50f2c823523a
children f028c143bfe6
files lisp/info.el
diffstat 1 files changed, 34 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/info.el	Tue Mar 15 10:45:25 2005 +0000
+++ b/lisp/info.el	Tue Mar 15 10:46:00 2005 +0000
@@ -210,6 +210,8 @@
   :type 'boolean
   :group 'info)
 
+(defvar Info-isearch-initial-node nil)
+
 (defcustom Info-mode-hook
   ;; Try to obey obsolete Info-fontify settings.
   (unless (and (boundp 'Info-fontify) (null Info-fontify))
@@ -1514,6 +1516,14 @@
 		  (setq found (point) beg-found (if backward (match-end 0)
 						  (match-beginning 0)))
 		(setq give-up t))))))
+
+      (when (and isearch-mode Info-isearch-search
+		 (not Info-isearch-initial-node)
+		 (not bound)
+		 (or give-up (and found (not (and (> found opoint-min)
+						  (< found opoint-max))))))
+	(signal 'search-failed (list regexp "initial node")))
+
       ;; If no subfiles, give error now.
       (if give-up
 	  (if (null Info-current-subfile)
@@ -1523,6 +1533,9 @@
 		  (re-search-forward regexp)))
 	    (setq found nil)))
 
+      (if (and bound (not found))
+	  (signal 'search-failed (list regexp)))
+
       (unless (or found bound)
 	(unwind-protect
 	    ;; Try other subfiles.
@@ -1650,25 +1663,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-initial-node
+	  (progn
+	    (if isearch-forward (Info-top-node) (Info-final-node))
+	    (goto-char (if isearch-forward (point-min) (point-max))))
+	(setq Info-isearch-initial-node Info-current-node)
+	(setq isearch-wrapped nil))
     (goto-char (if isearch-forward (point-min) (point-max)))))
 
 (defun Info-isearch-push-state ()
@@ -1680,6 +1696,8 @@
            (string= Info-current-node node))
       (progn (Info-find-node file node) (sit-for 0))))
 
+(defun Info-isearch-start ()
+  (setq Info-isearch-initial-node nil))
 
 (defun Info-extract-pointer (name &optional errorname)
   "Extract the value of the node-pointer named NAME.
@@ -3217,6 +3235,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)