comparison lisp/info.el @ 29164:71275ee34b42

(Info-find-node-2): Restructure [following "Vadim S. Solomin" <sovs@uic.nnov.ru>].
author Dave Love <fx@gnu.org>
date Wed, 24 May 2000 17:19:51 +0000
parents 602b7988fdb1
children 935f96194020
comparison
equal deleted inserted replaced
29163:ea19f6424132 29164:71275ee34b42
508 (concat "\\(Node:\\|Ref:\\) *\\(" 508 (concat "\\(Node:\\|Ref:\\) *\\("
509 (regexp-quote nodename) 509 (regexp-quote nodename)
510 "\\) *[,\t\n\177]")) 510 "\\) *[,\t\n\177]"))
511 (nodepos nil)) 511 (nodepos nil))
512 512
513 ;; First, search a tag table, if any 513 (catch 'foo
514 (if (marker-position Info-tag-table-marker) 514 ;; First, search a tag table, if any
515 (let ((found-in-tag-table t) 515 (if (marker-position Info-tag-table-marker)
516 found-anchor 516 (let (found-in-tag-table
517 found-mode 517 found-anchor
518 (m Info-tag-table-marker)) 518 found-mode
519 (save-excursion 519 (m Info-tag-table-marker))
520 (set-buffer (marker-buffer m)) 520 (save-excursion
521 (goto-char m) 521 (set-buffer (marker-buffer m))
522 (beginning-of-line) ; so re-search will work. 522 (goto-char m)
523 523 (beginning-of-line) ; so re-search will work.
524 ;; Search tag table 524
525 (catch 'foo 525 ;; Search tag table
526 (while (re-search-forward regexp nil t) 526 (setq found-in-tag-table
527 (setq found-anchor 527 (re-search-forward regexp nil t)
528 (string-equal "Ref:" (match-string 1))) 528 found-anchor
529 (or nodepos (setq nodepos (point)) 529 (string-equal "Ref:" (match-string 1)))
530 (if (string-equal (match-string 2) nodename) 530 (if found-in-tag-table
531 (throw 'foo t)))) 531 (setq guesspos (1+ (read (current-buffer)))))
532 (if nodepos 532 (setq found-mode major-mode))
533 (goto-char nodepos) 533
534 (setq found-in-tag-table nil))) 534 ;; Indirect file among split files
535 (if found-in-tag-table 535 (if found-in-tag-table
536 (setq guesspos (1+ (read (current-buffer))))) 536 (progn
537 (setq found-mode major-mode)) 537 ;; If this is an indirect file, determine
538 538 ;; which file really holds this node and
539 ;; Indirect file among split files 539 ;; read it in.
540 (if found-in-tag-table 540 (if (not (eq found-mode 'Info-mode))
541 (progn 541 ;; Note that the current buffer must be
542 ;; If this is an indirect file, determine 542 ;; the *info* buffer on entry to
543 ;; which file really holds this node and 543 ;; Info-read-subfile. Thus the hackery
544 ;; read it in. 544 ;; above.
545 (if (not (eq found-mode 'Info-mode)) 545 (setq guesspos (Info-read-subfile guesspos)))))
546 ;; Note that the current buffer must be 546
547 ;; the *info* buffer on entry to 547 ;; Handle anchor
548 ;; Info-read-subfile. Thus the hackery 548 (if found-anchor
549 ;; above. 549 (progn
550 (setq guesspos (Info-read-subfile guesspos))))) 550 (goto-char (setq anchorpos guesspos))
551 551 (throw 'foo t)))))
552 ;; Handle anchor 552
553 (if found-anchor 553 ;; Else we may have a node, which we search for:
554 (goto-char (setq anchorpos guesspos)) 554 (goto-char (max (point-min)
555 555 (- (byte-to-position guesspos) 1000)))
556 ;; Else we may have a node, which we search for: 556 ;; Now search from our advised position
557 (let ((guesschar 557 ;; (or from beg of buffer)
558 (or (byte-to-position guesspos)
559 (if (< (position-bytes (point-max)) guesspos)
560 (point-max)
561 (point-min)))))
562 (goto-char (max (point-min)
563 (- guesschar 1000))))
564 ;; Now search from our advised position
565 ;; (or from beg of buffer)
566 ;; to find the actual node.
567 ;; First, check whether the node is right
568 ;; where we are, in case the buffer begins
569 ;; with a node.
570 (setq nodepos nil)
571 (or (Info-node-at-bob-matching regexp)
572 (catch 'foo
573 (while (search-forward "\n\^_" nil t)
574 (forward-line 1)
575 (let ((beg (point)))
576 (forward-line 1)
577 (if (re-search-backward regexp beg t)
578 (if (string-equal (match-string 2) nodename)
579 (progn
580 (beginning-of-line)
581 (throw 'foo t))
582 (or nodepos
583 (setq nodepos (point)))))))
584 (if nodepos
585 (progn
586 (goto-char nodepos)
587 (beginning-of-line))
588 (error
589 "No such anchor in tag table or node in tag table or file: %s"
590 nodename))))))
591 (goto-char (max (point-min) (- guesspos 1000)))
592 ;; Now search from our advised position (or from beg of buffer)
593 ;; to find the actual node. 558 ;; to find the actual node.
594 ;; First, check whether the node is right where we are, in case 559 ;; First, check whether the node is right
595 ;; the buffer begins with a node. 560 ;; where we are, in case the buffer begins
596 (setq nodepos nil) 561 ;; with a node.
597 (or (Info-node-at-bob-matching regexp) 562 (or (Info-node-at-bob-matching regexp)
598 (catch 'foo 563 (while (search-forward "\n\^_" nil t)
599 (while (search-forward "\n\^_" nil t) 564 (forward-line 1)
565 (let ((beg (point)))
600 (forward-line 1) 566 (forward-line 1)
601 (let ((beg (point))) 567 (if (re-search-backward regexp beg t)
602 (forward-line 1) 568 (progn
603 (if (re-search-backward regexp beg t) 569 (beginning-of-line)
604 (if (string-equal (match-string 2) nodename) 570 (throw 'foo t)))))
605 (throw 'foo t) 571 (error
606 (or nodepos 572 "No such anchor in tag table or node in tag table or file: %s"
607 (setq nodepos (point))))))) 573 nodename)))
608 (if nodepos 574
609 (goto-char nodepos) 575 (Info-select-node)
610 (error "No such node: %s" nodename)))))) 576 (goto-char (or anchorpos (point-min))))))
611 (Info-select-node)
612 (goto-char (or anchorpos (point-min)))))
613 ;; If we did not finish finding the specified node, 577 ;; If we did not finish finding the specified node,
614 ;; go back to the previous one. 578 ;; go back to the previous one.
615 (or Info-current-node no-going-back (null Info-history) 579 (or Info-current-node no-going-back (null Info-history)
616 (let ((hist (car Info-history))) 580 (let ((hist (car Info-history)))
617 (setq Info-history (cdr Info-history)) 581 (setq Info-history (cdr Info-history))