]> git.eshelyaron.com Git - emacs.git/commitdiff
(Info-search): Don't lose with empty regexp.
authorDave Love <fx@gnu.org>
Mon, 19 Jul 1999 22:21:44 +0000 (22:21 +0000)
committerDave Love <fx@gnu.org>
Mon, 19 Jul 1999 22:21:44 +0000 (22:21 +0000)
lisp/info.el

index 396f4fad9ea285df5ecf19afd9e24354b3f4349e..b2a6df32594fbe744454e7ef966be599a8a9e5e6 100644 (file)
@@ -958,60 +958,61 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
   (if (equal regexp "")
       (setq regexp Info-last-search)
     (setq Info-last-search regexp))
-  (let ((found ()) current
-       (onode Info-current-node)
-       (ofile Info-current-file)
-       (opoint (point))
-       (ostart (window-start))
-       (osubfile Info-current-subfile))
-    (save-excursion
-      (save-restriction
-       (widen)
-       (if (null Info-current-subfile)
-           (progn (re-search-forward regexp) (setq found (point)))
-         (condition-case err
+  (when regexp
+    (let ((found ()) current
+         (onode Info-current-node)
+         (ofile Info-current-file)
+         (opoint (point))
+         (ostart (window-start))
+         (osubfile Info-current-subfile))
+      (save-excursion
+       (save-restriction
+         (widen)
+         (if (null Info-current-subfile)
              (progn (re-search-forward regexp) (setq found (point)))
-           (search-failed nil)))))
-    (if (not found) ;can only happen in subfile case -- else would have erred
-       (unwind-protect
-           (let ((list ()))
-             (save-excursion
-               (set-buffer (marker-buffer Info-tag-table-marker))
-               (goto-char (point-min))
-               (search-forward "\n\^_\nIndirect:")
-               (save-restriction
-                 (narrow-to-region (point)
-                                   (progn (search-forward "\n\^_")
-                                          (1- (point))))
+           (condition-case err
+               (progn (re-search-forward regexp) (setq found (point)))
+             (search-failed nil)))))
+      (if (not found) ;can only happen in subfile case -- else would have erred
+         (unwind-protect
+             (let ((list ()))
+               (save-excursion
+                 (set-buffer (marker-buffer Info-tag-table-marker))
                  (goto-char (point-min))
-                 (search-forward (concat "\n" osubfile ": "))
-                 (beginning-of-line)
-                 (while (not (eobp))
-                   (re-search-forward "\\(^.*\\): [0-9]+$")
-                   (goto-char (+ (match-end 1) 2))
-                   (setq list (cons (cons (read (current-buffer))
-                                          (buffer-substring
-                                           (match-beginning 1) (match-end 1)))
-                                    list))
-                   (goto-char (1+ (match-end 0))))
-                 (setq list (nreverse list)
-                       current (car (car list))
-                       list (cdr list))))
-             (while list
-               (message "Searching subfile %s..." (cdr (car list)))
-               (Info-read-subfile (car (car list)))
-               (setq list (cdr list))
-;;             (goto-char (point-min))
-               (if (re-search-forward regexp nil t)
-                   (setq found (point) list ())))
-             (if found
-                 (message "")
-               (signal 'search-failed (list regexp))))
-         (if (not found)
-             (progn (Info-read-subfile osubfile)
-                    (goto-char opoint)
-                    (Info-select-node)
-                    (set-window-start (selected-window) ostart)))))
+                 (search-forward "\n\^_\nIndirect:")
+                 (save-restriction
+                   (narrow-to-region (point)
+                                     (progn (search-forward "\n\^_")
+                                            (1- (point))))
+                   (goto-char (point-min))
+                   (search-forward (concat "\n" osubfile ": "))
+                   (beginning-of-line)
+                   (while (not (eobp))
+                     (re-search-forward "\\(^.*\\): [0-9]+$")
+                     (goto-char (+ (match-end 1) 2))
+                     (setq list (cons (cons (read (current-buffer))
+                                            (buffer-substring
+                                             (match-beginning 1) (match-end 1)))
+                                      list))
+                     (goto-char (1+ (match-end 0))))
+                   (setq list (nreverse list)
+                         current (car (car list))
+                         list (cdr list))))
+               (while list
+                 (message "Searching subfile %s..." (cdr (car list)))
+                 (Info-read-subfile (car (car list)))
+                 (setq list (cdr list))
+;;;            (goto-char (point-min))
+                 (if (re-search-forward regexp nil t)
+                     (setq found (point) list ())))
+               (if found
+                   (message "")
+                 (signal 'search-failed (list regexp))))
+           (if (not found)
+               (progn (Info-read-subfile osubfile)
+                      (goto-char opoint)
+                      (Info-select-node)
+                      (set-window-start (selected-window) ostart)))))
     (widen)
     (goto-char found)
     (Info-select-node)
@@ -1019,7 +1020,7 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
     (or (and (string-equal onode Info-current-node)
             (equal ofile Info-current-file))
        (setq Info-history (cons (list ofile onode opoint)
-                                Info-history)))))
+                                Info-history))))))
 \f
 ;; Extract the value of the node-pointer named NAME.
 ;; If there is none, use ERRORNAME in the error message;