comparison lisp/info.el @ 23904:74c3c643e90c

(Info-find-node): Add 1 to the position read from the tag table. Don't fail if the node delimiter ^_ is the first character in the file. (Info-insert-dir): Don't fail when the node delimiter ^_ is the first character in the file. (Info-read-subfile): Likewise. (Info-select-node): Likewise. (Info-build-node-completions): Likewise.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 16 Dec 1998 14:01:45 +0000
parents 2e335a66e659
children 950f2c278c9a
comparison
equal deleted inserted replaced
23903:7d1efca4eadc 23904:74c3c643e90c
472 472
473 ;; Search tag table 473 ;; Search tag table
474 (setq found-in-tag-table 474 (setq found-in-tag-table
475 (re-search-forward regexp nil t)) 475 (re-search-forward regexp nil t))
476 (if found-in-tag-table 476 (if found-in-tag-table
477 (setq guesspos (read (current-buffer)))) 477 (setq guesspos (1+ (read (current-buffer)))))
478 (setq found-mode major-mode)) 478 (setq found-mode major-mode))
479 479
480 ;; Indirect file among split files 480 ;; Indirect file among split files
481 (if found-in-tag-table 481 (if found-in-tag-table
482 (progn 482 (progn
500 (- (byte-to-position guesspos) 1000))) 500 (- (byte-to-position guesspos) 1000)))
501 ;; Now search from our advised position 501 ;; Now search from our advised position
502 ;; (or from beg of buffer) 502 ;; (or from beg of buffer)
503 ;; to find the actual node. 503 ;; to find the actual node.
504 (catch 'foo 504 (catch 'foo
505 (if (and (eq (point) (point-min))
506 (looking-at "\^_")
507 (= (forward-line 1) 0))
508 (let ((beg (point)))
509 (forward-line 1)
510 (if (re-search-backward regexp beg t)
511 (progn
512 (beginning-of-line)
513 (throw 'foo t)))))
505 (while (search-forward "\n\^_" nil t) 514 (while (search-forward "\n\^_" nil t)
506 (forward-line 1) 515 (forward-line 1)
507 (let ((beg (point))) 516 (let ((beg (point)))
508 (forward-line 1) 517 (forward-line 1)
509 (if (re-search-backward regexp beg t) 518 (if (re-search-backward regexp beg t)
515 nodename)))) 524 nodename))))
516 (goto-char (max (point-min) (- guesspos 1000))) 525 (goto-char (max (point-min) (- guesspos 1000)))
517 ;; Now search from our advised position (or from beg of buffer) 526 ;; Now search from our advised position (or from beg of buffer)
518 ;; to find the actual node. 527 ;; to find the actual node.
519 (catch 'foo 528 (catch 'foo
529 (if (and (eq (point) (point-min))
530 (looking-at "\^_")
531 (= (forward-line 1) 0))
532 (let ((beg (point)))
533 (forward-line 1)
534 (if (re-search-backward regexp beg t)
535 (progn
536 (beginning-of-line)
537 (throw 'foo t)))))
520 (while (search-forward "\n\^_" nil t) 538 (while (search-forward "\n\^_" nil t)
521 (forward-line 1) 539 (forward-line 1)
522 (let ((beg (point))) 540 (let ((beg (point)))
523 (forward-line 1) 541 (forward-line 1)
524 (if (re-search-backward regexp beg t) 542 (if (re-search-backward regexp beg t)
641 ;; Find each menu, and add an elt to NODES for it. 659 ;; Find each menu, and add an elt to NODES for it.
642 (while (re-search-forward "^\\* Menu:" nil t) 660 (while (re-search-forward "^\\* Menu:" nil t)
643 (let (beg nodename end) 661 (let (beg nodename end)
644 (forward-line 1) 662 (forward-line 1)
645 (setq beg (point)) 663 (setq beg (point))
646 (search-backward "\n\^_") 664 (or (search-backward "\n\^_" nil 'move)
665 (looking-at "\^_")
666 (signal 'search-failed (list "\n\^_")))
647 (search-forward "Node: ") 667 (search-forward "Node: ")
648 (setq nodename (Info-following-node-name)) 668 (setq nodename (Info-following-node-name))
649 (search-forward "\n\^_" nil 'move) 669 (search-forward "\n\^_" nil 'move)
650 (beginning-of-line) 670 (beginning-of-line)
651 (setq end (point)) 671 (setq end (point))
680 ;; and merge it into the main buffer. 700 ;; and merge it into the main buffer.
681 (while nodes 701 (while nodes
682 (let ((nodename (car (car nodes)))) 702 (let ((nodename (car (car nodes))))
683 (goto-char (point-min)) 703 (goto-char (point-min))
684 ;; Find the like-named node in the main buffer. 704 ;; Find the like-named node in the main buffer.
685 (if (re-search-forward (concat "\n\^_.*\n.*Node: " 705 (if (re-search-forward (concat "^\^_.*\n.*Node: "
686 (regexp-quote nodename) 706 (regexp-quote nodename)
687 "[,\n\t]") 707 "[,\n\t]")
688 nil t) 708 nil t)
689 (progn 709 (progn
690 (search-forward "\n\^_" nil 'move) 710 (search-forward "\n\^_" nil 'move)
717 lastfilename) 737 lastfilename)
718 (if (numberp nodepos) 738 (if (numberp nodepos)
719 (save-excursion 739 (save-excursion
720 (set-buffer (marker-buffer Info-tag-table-marker)) 740 (set-buffer (marker-buffer Info-tag-table-marker))
721 (goto-char (point-min)) 741 (goto-char (point-min))
722 (search-forward "\n\^_") 742 (or (looking-at "\^_")
743 (search-forward "\n\^_"))
723 (forward-line 2) 744 (forward-line 2)
724 (catch 'foo 745 (catch 'foo
725 (while (not (looking-at "\^_")) 746 (while (not (looking-at "\^_"))
726 (if (not (eolp)) 747 (if (not (eolp))
727 (let ((beg (point)) 748 (let ((beg (point))
748 (erase-buffer) 769 (erase-buffer)
749 (info-insert-file-contents lastfilename) 770 (info-insert-file-contents lastfilename)
750 (set-buffer-modified-p nil) 771 (set-buffer-modified-p nil)
751 (setq Info-current-subfile lastfilename))) 772 (setq Info-current-subfile lastfilename)))
752 (goto-char (point-min)) 773 (goto-char (point-min))
753 (search-forward "\n\^_") 774 (if (looking-at "\^_")
775 (forward-char 1)
776 (search-forward "\n\^_"))
754 (if (numberp nodepos) 777 (if (numberp nodepos)
755 (+ (- nodepos lastfilepos) (point))))) 778 (+ (- nodepos lastfilepos) (point)))))
756 779
757 ;; Select the info node that point is in. 780 ;; Select the info node that point is in.
758 (defun Info-select-node () 781 (defun Info-select-node ()
759 ;; Bind this in case the user sets it to nil. 782 ;; Bind this in case the user sets it to nil.
760 (let ((case-fold-search t)) 783 (let ((case-fold-search t))
761 (save-excursion 784 (save-excursion
762 ;; Find beginning of node. 785 ;; Find beginning of node.
763 (search-backward "\n\^_") 786 (if (search-backward "\n\^_" nil 'move)
764 (forward-line 2) 787 (forward-line 2)
788 (if (looking-at "\^_")
789 (forward-line 1)
790 (signal 'search-failed (list "\n\^_"))))
765 ;; Get nodename spelled as it is in the node. 791 ;; Get nodename spelled as it is in the node.
766 (re-search-forward "Node:[ \t]*") 792 (re-search-forward "Node:[ \t]*")
767 (setq Info-current-node 793 (setq Info-current-node
768 (buffer-substring-no-properties (point) 794 (buffer-substring-no-properties (point)
769 (progn 795 (progn
864 (cons (list (buffer-substring (match-beginning 1) 890 (cons (list (buffer-substring (match-beginning 1)
865 (match-end 1))) 891 (match-end 1)))
866 compl)))) 892 compl))))
867 (widen) 893 (widen)
868 (goto-char (point-min)) 894 (goto-char (point-min))
895 (if (and (looking-at "\^_")
896 (= (forward-line 1) 0))
897 (let ((beg (point)))
898 (forward-line 1)
899 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
900 beg t)
901 (setq compl
902 (list (buffer-substring (match-beginning 1)
903 (match-end 1)))))))
869 (while (search-forward "\n\^_" nil t) 904 (while (search-forward "\n\^_" nil t)
870 (forward-line 1) 905 (forward-line 1)
871 (let ((beg (point))) 906 (let ((beg (point)))
872 (forward-line 1) 907 (forward-line 1)
873 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]" 908 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"