comparison 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
comparison
equal deleted inserted replaced
16398:71e49abd5906 16399:f73d53a1b448
547 (message "Composing main Info directory...done")) 547 (message "Composing main Info directory...done"))
548 (setq Info-dir-contents (buffer-string))) 548 (setq Info-dir-contents (buffer-string)))
549 (setq default-directory Info-dir-contents-directory)) 549 (setq default-directory Info-dir-contents-directory))
550 550
551 (defun Info-read-subfile (nodepos) 551 (defun Info-read-subfile (nodepos)
552 (set-buffer (marker-buffer Info-tag-table-marker)) 552 ;; NODEPOS is either a position (in the Info file as a whole,
553 (goto-char (point-min)) 553 ;; not relative to a subfile) or the name of a subfile.
554 (search-forward "\n\^_")
555 (let (lastfilepos 554 (let (lastfilepos
556 lastfilename) 555 lastfilename)
557 (forward-line 2) 556 (if (numberp nodepos)
558 (catch 'foo 557 (save-excursion
559 (while (not (looking-at "\^_")) 558 (set-buffer (marker-buffer Info-tag-table-marker))
560 (if (not (eolp)) 559 (goto-char (point-min))
561 (let ((beg (point)) 560 (search-forward "\n\^_")
562 thisfilepos thisfilename) 561 (forward-line 2)
563 (search-forward ": ") 562 (catch 'foo
564 (setq thisfilename (buffer-substring beg (- (point) 2))) 563 (while (not (looking-at "\^_"))
565 (setq thisfilepos (read (current-buffer))) 564 (if (not (eolp))
566 ;; read in version 19 stops at the end of number. 565 (let ((beg (point))
567 ;; Advance to the next line. 566 thisfilepos thisfilename)
568 (forward-line 1) 567 (search-forward ": ")
569 (if (> thisfilepos nodepos) 568 (setq thisfilename (buffer-substring beg (- (point) 2)))
570 (throw 'foo t)) 569 (setq thisfilepos (read (current-buffer)))
571 (setq lastfilename thisfilename) 570 ;; read in version 19 stops at the end of number.
572 (setq lastfilepos thisfilepos)) 571 ;; Advance to the next line.
573 (forward-line 1)))) 572 (forward-line 1)
573 (if (> thisfilepos nodepos)
574 (throw 'foo t))
575 (setq lastfilename thisfilename)
576 (setq lastfilepos thisfilepos))
577 (forward-line 1)))))
578 (setq lastfilename nodepos)
579 (setq lastfilepos 0))
574 (set-buffer (get-buffer "*info*")) 580 (set-buffer (get-buffer "*info*"))
575 (or (equal Info-current-subfile lastfilename) 581 (or (equal Info-current-subfile lastfilename)
576 (let ((buffer-read-only nil)) 582 (let ((buffer-read-only nil))
577 (setq buffer-file-name nil) 583 (setq buffer-file-name nil)
578 (widen) 584 (widen)
580 (info-insert-file-contents lastfilename) 586 (info-insert-file-contents lastfilename)
581 (set-buffer-modified-p nil) 587 (set-buffer-modified-p nil)
582 (setq Info-current-subfile lastfilename))) 588 (setq Info-current-subfile lastfilename)))
583 (goto-char (point-min)) 589 (goto-char (point-min))
584 (search-forward "\n\^_") 590 (search-forward "\n\^_")
585 (+ (- nodepos lastfilepos) (point)))) 591 (if (numberp nodepos)
592 (+ (- nodepos lastfilepos) (point)))))
586 593
587 ;; Select the info node that point is in. 594 ;; Select the info node that point is in.
588 (defun Info-select-node () 595 (defun Info-select-node ()
589 (save-excursion 596 (save-excursion
590 ;; Find beginning of node. 597 ;; Find beginning of node.
725 (setq Info-last-search regexp)) 732 (setq Info-last-search regexp))
726 (let ((found ()) current 733 (let ((found ()) current
727 (onode Info-current-node) 734 (onode Info-current-node)
728 (ofile Info-current-file) 735 (ofile Info-current-file)
729 (opoint (point)) 736 (opoint (point))
737 (ostart (window-start))
730 (osubfile Info-current-subfile)) 738 (osubfile Info-current-subfile))
731 (save-excursion 739 (save-excursion
732 (save-restriction 740 (save-restriction
733 (widen) 741 (widen)
734 (if (null Info-current-subfile) 742 (if (null Info-current-subfile)
769 (setq found (point) list ()))) 777 (setq found (point) list ())))
770 (if found 778 (if found
771 (message "") 779 (message "")
772 (signal 'search-failed (list regexp)))) 780 (signal 'search-failed (list regexp))))
773 (if (not found) 781 (if (not found)
774 (progn (Info-read-subfile opoint) 782 (progn (Info-read-subfile osubfile)
775 (goto-char opoint) 783 (goto-char opoint)
776 (Info-select-node))))) 784 (Info-select-node)
785 (set-window-start (selected-window) ostart)))))
777 (widen) 786 (widen)
778 (goto-char found) 787 (goto-char found)
779 (Info-select-node) 788 (Info-select-node)
780 ;; Use string-equal, not equal, to ignore text props. 789 ;; Use string-equal, not equal, to ignore text props.
781 (or (and (string-equal onode Info-current-node) 790 (or (and (string-equal onode Info-current-node)