27 |
;;; Commentary: |
;;; Commentary: |
28 |
|
|
29 |
;; Note that nowadays we expect info files to be made using makeinfo. |
;; Note that nowadays we expect info files to be made using makeinfo. |
30 |
|
;; In particular we make these assumptions: |
31 |
|
;; - a menu item MAY contain colons but not colon-space ": " |
32 |
|
;; - a menu item ending with ": " (but not ":: ") is an index entry |
33 |
|
;; - a node name MAY NOT contain a colon |
34 |
|
|
35 |
;;; Code: |
;;; Code: |
36 |
|
|
588 |
(save-excursion |
(save-excursion |
589 |
(set-buffer (marker-buffer marker)) |
(set-buffer (marker-buffer marker)) |
590 |
(goto-char marker) |
(goto-char marker) |
591 |
|
|
592 |
;; Search tag table |
;; Search tag table |
593 |
(beginning-of-line) |
(beginning-of-line) |
594 |
(when (re-search-forward regexp nil t) |
(when (re-search-forward regexp nil t) |
632 |
(beginning-of-line) |
(beginning-of-line) |
633 |
(setq found (point))))) |
(setq found (point))))) |
634 |
found))) |
found))) |
635 |
|
|
636 |
(defun Info-find-node-in-buffer (regexp) |
(defun Info-find-node-in-buffer (regexp) |
637 |
"Find a node or anchor in the current buffer. |
"Find a node or anchor in the current buffer. |
638 |
REGEXP is a regular expression matching nodes or references. Its first |
REGEXP is a regular expression matching nodes or references. Its first |
642 |
a case-insensitive match is tried." |
a case-insensitive match is tried." |
643 |
(or (Info-find-node-in-buffer-1 regexp nil) |
(or (Info-find-node-in-buffer-1 regexp nil) |
644 |
(Info-find-node-in-buffer-1 regexp t))) |
(Info-find-node-in-buffer-1 regexp t))) |
645 |
|
|
646 |
(defun Info-find-node-2 (filename nodename &optional no-going-back) |
(defun Info-find-node-2 (filename nodename &optional no-going-back) |
647 |
(buffer-disable-undo (current-buffer)) |
(buffer-disable-undo (current-buffer)) |
648 |
(or (eq major-mode 'Info-mode) |
(or (eq major-mode 'Info-mode) |
725 |
(nodepos nil)) |
(nodepos nil)) |
726 |
|
|
727 |
(catch 'foo |
(catch 'foo |
728 |
|
|
729 |
;; First, search a tag table, if any |
;; First, search a tag table, if any |
730 |
(when (marker-position Info-tag-table-marker) |
(when (marker-position Info-tag-table-marker) |
731 |
(let* ((m Info-tag-table-marker) |
(let* ((m Info-tag-table-marker) |
732 |
(found (Info-find-in-tag-table m regexp))) |
(found (Info-find-in-tag-table m regexp))) |
733 |
|
|
734 |
(when found |
(when found |
735 |
;; FOUND is (ANCHOR POS MODE). |
;; FOUND is (ANCHOR POS MODE). |
736 |
(setq guesspos (nth 1 found)) |
(setq guesspos (nth 1 found)) |
737 |
|
|
738 |
;; If this is an indirect file, determine which |
;; If this is an indirect file, determine which |
739 |
;; file really holds this node and read it in. |
;; file really holds this node and read it in. |
740 |
(unless (eq (nth 2 found) 'Info-mode) |
(unless (eq (nth 2 found) 'Info-mode) |
751 |
;; Else we may have a node, which we search for: |
;; Else we may have a node, which we search for: |
752 |
(goto-char (max (point-min) |
(goto-char (max (point-min) |
753 |
(- (byte-to-position guesspos) 1000))) |
(- (byte-to-position guesspos) 1000))) |
754 |
|
|
755 |
;; Now search from our advised position (or from beg of |
;; Now search from our advised position (or from beg of |
756 |
;; buffer) to find the actual node. First, check |
;; buffer) to find the actual node. First, check |
757 |
;; whether the node is right where we are, in case the |
;; whether the node is right where we are, in case the |
995 |
(insert entry) |
(insert entry) |
996 |
(while (= (line-beginning-position 0) (1- (point))) |
(while (= (line-beginning-position 0) (1- (point))) |
997 |
(delete-region (1- (point)) (point)))) |
(delete-region (1- (point)) (point)))) |
998 |
|
|
999 |
;; Now remove duplicate entries under the same heading. |
;; Now remove duplicate entries under the same heading. |
1000 |
(let ((seen nil) |
(let ((seen nil) |
1001 |
(limit (point))) |
(limit (point))) |
2123 |
((setq node (Info-get-token (point) "\\*note[ \n]" |
((setq node (Info-get-token (point) "\\*note[ \n]" |
2124 |
"\\*note[ \n]\\([^:]*\\):")) |
"\\*note[ \n]\\([^:]*\\):")) |
2125 |
(Info-follow-reference node)) |
(Info-follow-reference node)) |
2126 |
|
;; explicit node name |
2127 |
((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::")) |
((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::")) |
2128 |
(Info-goto-node node)) |
(Info-goto-node node)) |
2129 |
|
;; index entry (Another approach is to combine this w/ the following cond |
2130 |
|
;; branch "other menu item", but that also requires fixing |
2131 |
|
;; Info-extract-menu-node-name -- stay tuned. --ttn) |
2132 |
|
((Info-get-token (point) "\\* +" "\\* +\\(.*\\):[ \t]") |
2133 |
|
(save-excursion |
2134 |
|
(re-search-forward ":[ \t]") |
2135 |
|
(setq node (Info-following-node-name "^."))) |
2136 |
|
(Info-goto-node node)) |
2137 |
|
;; other menu item |
2138 |
((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):") |
((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):") |
2139 |
(beginning-of-line) |
(beginning-of-line) |
2140 |
(forward-char 2) |
(forward-char 2) |
2754 |
(concat "No next, prev or up links -- " |
(concat "No next, prev or up links -- " |
2755 |
(buffer-substring (point) header-end))) |
(buffer-substring (point) header-end))) |
2756 |
(setq header (buffer-substring (point) header-end)))) |
(setq header (buffer-substring (point) header-end)))) |
2757 |
|
|
2758 |
(put-text-property (point-min) (1+ (point-min)) |
(put-text-property (point-min) (1+ (point-min)) |
2759 |
'header-line header) |
'header-line header) |
2760 |
;; Hide the part of the first line |
;; Hide the part of the first line |