Mercurial > emacs
comparison lisp/info.el @ 66602:f1d7e489a526
(Info-file-supports-index-cookies): New variable.
(Info-find-node-2): Check makeinfo version for index cookie support.
(Info-index-nodes): Search for nodes with index cookies only when
Info-file-supports-index-cookies is t. Otherwise, search nodes
with "Index" in the node name.
(Info-index-node): Search index cookie in the current node only when
Info-file-supports-index-cookies is t. Otherwise, check the word
"Index" in the node name.
(Info-find-emacs-command-nodes): Remove code that searches nodes
with "Index" node name in the top menu.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 01 Nov 2005 09:45:10 +0000 |
parents | bdc911746f64 |
children | 8c3381fde2cc |
comparison
equal
deleted
inserted
replaced
66601:2f18208cd84b | 66602:f1d7e489a526 |
---|---|
307 (defvar Info-tag-table-buffer nil | 307 (defvar Info-tag-table-buffer nil |
308 "Buffer used for indirect tag tables.") | 308 "Buffer used for indirect tag tables.") |
309 | 309 |
310 (defvar Info-current-file-completions nil | 310 (defvar Info-current-file-completions nil |
311 "Cached completion list for current Info file.") | 311 "Cached completion list for current Info file.") |
312 | |
313 (defvar Info-file-supports-index-cookies nil | |
314 "Non-nil if current Info file supports index cookies.") | |
312 | 315 |
313 (defvar Info-index-alternatives nil | 316 (defvar Info-index-alternatives nil |
314 "List of possible matches for last `Info-index' command.") | 317 "List of possible matches for last `Info-index' command.") |
315 | 318 |
316 (defvar Info-point-loc nil | 319 (defvar Info-point-loc nil |
840 (insert-buffer-substring " *info-toc*")) | 843 (insert-buffer-substring " *info-toc*")) |
841 (t | 844 (t |
842 (info-insert-file-contents filename nil) | 845 (info-insert-file-contents filename nil) |
843 (setq default-directory (file-name-directory filename)))) | 846 (setq default-directory (file-name-directory filename)))) |
844 (set-buffer-modified-p nil) | 847 (set-buffer-modified-p nil) |
848 | |
849 ;; Check makeinfo version for index cookie support | |
850 (let ((found nil)) | |
851 (goto-char (point-min)) | |
852 (condition-case () | |
853 (if (and (re-search-forward | |
854 "makeinfo version \\([0-9]+.[0-9]+\\)" | |
855 (line-beginning-position 3) t) | |
856 (not (version< (match-string 1) "4.7"))) | |
857 (setq found t)) | |
858 (error nil)) | |
859 (set (make-local-variable 'Info-file-supports-index-cookies) found)) | |
860 | |
845 ;; See whether file has a tag table. Record the location if yes. | 861 ;; See whether file has a tag table. Record the location if yes. |
846 (goto-char (point-max)) | 862 (goto-char (point-max)) |
847 (forward-line -8) | 863 (forward-line -8) |
848 ;; Use string-equal, not equal, to ignore text props. | 864 ;; Use string-equal, not equal, to ignore text props. |
849 (if (not (or (string-equal nodename "*") | 865 (if (not (or (string-equal nodename "*") |
2647 (or (assoc file Info-index-nodes) | 2663 (or (assoc file Info-index-nodes) |
2648 ;; Skip virtual Info files | 2664 ;; Skip virtual Info files |
2649 (and (member file '("dir" "history" "toc" "apropos")) | 2665 (and (member file '("dir" "history" "toc" "apropos")) |
2650 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) | 2666 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) |
2651 (not (stringp file)) | 2667 (not (stringp file)) |
2652 ;; Find nodes with index cookie | 2668 (if Info-file-supports-index-cookies |
2653 (let* ((default-directory (or (and (stringp file) | 2669 ;; Find nodes with index cookie |
2654 (file-name-directory | 2670 (let* ((default-directory (or (and (stringp file) |
2655 (setq file (Info-find-file file)))) | 2671 (file-name-directory |
2656 default-directory)) | 2672 (setq file (Info-find-file file)))) |
2657 Info-history Info-history-list Info-fontify-maximum-menu-size | 2673 default-directory)) |
2658 (main-file file) subfiles nodes node) | 2674 Info-history Info-history-list Info-fontify-maximum-menu-size |
2659 (condition-case nil | 2675 (main-file file) subfiles nodes node) |
2660 (with-temp-buffer | 2676 (condition-case nil |
2661 (while (or main-file subfiles) | 2677 (with-temp-buffer |
2662 (erase-buffer) | 2678 (while (or main-file subfiles) |
2663 (info-insert-file-contents (or main-file (car subfiles))) | 2679 (erase-buffer) |
2664 (goto-char (point-min)) | 2680 (info-insert-file-contents (or main-file (car subfiles))) |
2665 (while (search-forward "\0\b[index\0\b]" nil 'move) | 2681 (goto-char (point-min)) |
2666 (save-excursion | 2682 (while (search-forward "\0\b[index\0\b]" nil 'move) |
2667 (re-search-backward "^\^_") | 2683 (save-excursion |
2668 (search-forward "Node: ") | 2684 (re-search-backward "^\^_") |
2669 (setq nodes (cons (Info-following-node-name) nodes)))) | 2685 (search-forward "Node: ") |
2670 (if main-file | 2686 (setq nodes (cons (Info-following-node-name) nodes)))) |
2671 (save-excursion | 2687 (if main-file |
2672 (goto-char (point-min)) | 2688 (save-excursion |
2673 (if (search-forward "\n\^_\nIndirect:" nil t) | 2689 (goto-char (point-min)) |
2674 (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) | 2690 (if (search-forward "\n\^_\nIndirect:" nil t) |
2675 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) | 2691 (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) |
2676 (setq subfiles (cons (match-string-no-properties 1) | 2692 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) |
2677 subfiles))))) | 2693 (setq subfiles (cons (match-string-no-properties 1) |
2678 (setq subfiles (nreverse subfiles) | 2694 subfiles))))) |
2679 main-file nil)) | 2695 (setq subfiles (nreverse subfiles) |
2680 (setq subfiles (cdr subfiles))))) | 2696 main-file nil)) |
2681 (error nil)) | 2697 (setq subfiles (cdr subfiles))))) |
2682 (if nodes | 2698 (error nil)) |
2683 (setq nodes (nreverse nodes) | 2699 (if nodes |
2684 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) | 2700 (setq nodes (nreverse nodes) |
2685 nodes) | 2701 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) |
2686 ;; Find nodes with the word "Index" in the node name | 2702 nodes) |
2687 (let ((case-fold-search t) | 2703 ;; Else find nodes with the word "Index" in the node name |
2688 Info-history Info-history-list Info-fontify-maximum-menu-size | 2704 (let ((case-fold-search t) |
2689 nodes node) | 2705 Info-history Info-history-list Info-fontify-maximum-menu-size |
2690 (condition-case nil | 2706 nodes node) |
2691 (with-temp-buffer | 2707 (condition-case nil |
2692 (Info-mode) | 2708 (with-temp-buffer |
2693 (Info-find-node file "Top") | 2709 (Info-mode) |
2694 (when (and (search-forward "\n* menu:" nil t) | 2710 (Info-find-node file "Top") |
2695 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) | 2711 (when (and (search-forward "\n* menu:" nil t) |
2696 (goto-char (match-beginning 1)) | 2712 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) |
2697 (setq nodes (list (Info-extract-menu-node-name))) | 2713 (goto-char (match-beginning 1)) |
2698 (Info-goto-node (car nodes)) | 2714 (setq nodes (list (Info-extract-menu-node-name))) |
2699 (while (and (setq node (Info-extract-pointer "next" t)) | 2715 (Info-goto-node (car nodes)) |
2700 (string-match "\\<Index\\>" node)) | 2716 (while (and (setq node (Info-extract-pointer "next" t)) |
2701 (setq nodes (cons node nodes)) | 2717 (string-match "\\<Index\\>" node)) |
2702 (Info-goto-node node)))) | 2718 (setq nodes (cons node nodes)) |
2703 (error nil)) | 2719 (Info-goto-node node)))) |
2704 (if nodes | 2720 (error nil)) |
2705 (setq nodes (nreverse nodes) | 2721 (if nodes |
2706 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) | 2722 (setq nodes (nreverse nodes) |
2707 nodes) | 2723 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) |
2724 nodes)) | |
2708 ;; If file has no index nodes, still add it to the cache | 2725 ;; If file has no index nodes, still add it to the cache |
2709 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) | 2726 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) |
2710 (cdr (assoc file Info-index-nodes))) | 2727 (cdr (assoc file Info-index-nodes))) |
2711 | 2728 |
2712 (defun Info-index-node (&optional node file) | 2729 (defun Info-index-node (&optional node file) |
2716 (if (or (and node (not (equal node Info-current-node))) | 2733 (if (or (and node (not (equal node Info-current-node))) |
2717 (assoc (or file Info-current-file) Info-index-nodes)) | 2734 (assoc (or file Info-current-file) Info-index-nodes)) |
2718 (member (or node Info-current-node) (Info-index-nodes file)) | 2735 (member (or node Info-current-node) (Info-index-nodes file)) |
2719 ;; Don't search all index nodes if request is only for the current node | 2736 ;; Don't search all index nodes if request is only for the current node |
2720 ;; and file is not in the cache of index nodes | 2737 ;; and file is not in the cache of index nodes |
2721 (or | 2738 (if Info-file-supports-index-cookies |
2722 (save-match-data | 2739 (save-excursion |
2723 (string-match "\\<Index\\>" (or node Info-current-node ""))) | 2740 (goto-char (+ (or (save-excursion |
2724 (save-excursion | 2741 (search-backward "\n\^_" nil t)) |
2725 (goto-char (+ (or (save-excursion | 2742 (point-min)) 2)) |
2726 (search-backward "\n\^_" nil t)) | 2743 (search-forward "\0\b[index\0\b]" |
2727 (point-min)) 2)) | 2744 (or (save-excursion |
2728 (search-forward "\0\b[index\0\b]" | 2745 (search-forward "\n\^_" nil t)) |
2729 (or (save-excursion | 2746 (point-max)) t)) |
2730 (search-forward "\n\^_" nil t)) | 2747 (save-match-data |
2731 (point-max)) t))))) | 2748 (string-match "\\<Index\\>" (or node Info-current-node "")))))) |
2732 | 2749 |
2733 (defun Info-goto-index () | 2750 (defun Info-goto-index () |
2734 "Go to the first index node." | 2751 "Go to the first index node." |
2735 (let ((node (car (Info-index-nodes)))) | 2752 (let ((node (car (Info-index-nodes)))) |
2736 (or node (error "No index")) | 2753 (or node (error "No index")) |
3502 "\\(\\'\\|-\\)"))) | 3519 "\\(\\'\\|-\\)"))) |
3503 (if (string-match regexp (symbol-name command)) | 3520 (if (string-match regexp (symbol-name command)) |
3504 (setq info-file file file-list nil)) | 3521 (setq info-file file file-list nil)) |
3505 (setq file-list (cdr file-list)))))) | 3522 (setq file-list (cdr file-list)))))) |
3506 (Info-find-node info-file "Top") | 3523 (Info-find-node info-file "Top") |
3507 (or (and (search-forward "\n* menu:" nil t) | |
3508 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) | |
3509 (error "Info file `%s' appears to lack an index" info-file)) | |
3510 (goto-char (match-beginning 1)) | |
3511 ;; Bind Info-history to nil, to prevent the index nodes from | 3524 ;; Bind Info-history to nil, to prevent the index nodes from |
3512 ;; getting into the node history. | 3525 ;; getting into the node history. |
3513 (let ((Info-history nil) | 3526 (let ((Info-history nil) |
3514 (Info-history-list nil) | 3527 (Info-history-list nil) |
3515 node (nodes (Info-index-nodes))) | 3528 node (nodes (Info-index-nodes))) |