diff lisp/info.el @ 16399:f73d53a1b448

(Info-read-subfile): Allow a file name as arg. (Info-search): Restore previous subfile correctly.
author Richard M. Stallman <rms@gnu.org>
date Sun, 06 Oct 1996 22:50:07 +0000
parents 68eb8e1eeb13
children de67834f456d
line wrap: on
line diff
--- a/lisp/info.el	Sun Oct 06 22:49:28 1996 +0000
+++ b/lisp/info.el	Sun Oct 06 22:50:07 1996 +0000
@@ -549,28 +549,34 @@
   (setq default-directory Info-dir-contents-directory))
 
 (defun Info-read-subfile (nodepos)
-  (set-buffer (marker-buffer Info-tag-table-marker))
-  (goto-char (point-min))
-  (search-forward "\n\^_")
+  ;; NODEPOS is either a position (in the Info file as a whole,
+  ;; not relative to a subfile) or the name of a subfile.
   (let (lastfilepos
 	lastfilename)
-    (forward-line 2)
-    (catch 'foo
-      (while (not (looking-at "\^_"))
-	(if (not (eolp))
-	    (let ((beg (point))
-		  thisfilepos thisfilename)
-	      (search-forward ": ")
-	      (setq thisfilename  (buffer-substring beg (- (point) 2)))
-	      (setq thisfilepos (read (current-buffer)))
-	      ;; read in version 19 stops at the end of number.
-	      ;; Advance to the next line.
-	      (forward-line 1)
-	      (if (> thisfilepos nodepos)
-		  (throw 'foo t))
-	      (setq lastfilename thisfilename)
-	      (setq lastfilepos thisfilepos))
-	  (forward-line 1))))
+    (if (numberp nodepos)
+	(save-excursion
+	  (set-buffer (marker-buffer Info-tag-table-marker))
+	  (goto-char (point-min))
+	  (search-forward "\n\^_")
+	  (forward-line 2)
+	  (catch 'foo
+	    (while (not (looking-at "\^_"))
+	      (if (not (eolp))
+		  (let ((beg (point))
+			thisfilepos thisfilename)
+		    (search-forward ": ")
+		    (setq thisfilename  (buffer-substring beg (- (point) 2)))
+		    (setq thisfilepos (read (current-buffer)))
+		    ;; read in version 19 stops at the end of number.
+		    ;; Advance to the next line.
+		    (forward-line 1)
+		    (if (> thisfilepos nodepos)
+			(throw 'foo t))
+		    (setq lastfilename thisfilename)
+		    (setq lastfilepos thisfilepos))
+		(forward-line 1)))))
+      (setq lastfilename nodepos)
+      (setq lastfilepos 0))
     (set-buffer (get-buffer "*info*"))
     (or (equal Info-current-subfile lastfilename)
 	(let ((buffer-read-only nil))
@@ -582,7 +588,8 @@
 	  (setq Info-current-subfile lastfilename)))
     (goto-char (point-min))
     (search-forward "\n\^_")
-    (+ (- nodepos lastfilepos) (point))))
+    (if (numberp nodepos)
+	(+ (- nodepos lastfilepos) (point)))))
 
 ;; Select the info node that point is in.
 (defun Info-select-node ()
@@ -727,6 +734,7 @@
 	(onode Info-current-node)
 	(ofile Info-current-file)
 	(opoint (point))
+	(ostart (window-start))
 	(osubfile Info-current-subfile))
     (save-excursion
       (save-restriction
@@ -771,9 +779,10 @@
 		  (message "")
 		(signal 'search-failed (list regexp))))
 	  (if (not found)
-	      (progn (Info-read-subfile opoint)
+	      (progn (Info-read-subfile osubfile)
 		     (goto-char opoint)
-		     (Info-select-node)))))
+		     (Info-select-node)
+		     (set-window-start (selected-window) ostart)))))
     (widen)
     (goto-char found)
     (Info-select-node)