Changeset 3988 for vendor/emacs-CVS_HEAD/lisp/info.el
- Timestamp:
- 11/26/05 08:33:26 (3 years ago)
- Files:
-
- vendor/emacs-CVS_HEAD/lisp/info.el (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
vendor/emacs-CVS_HEAD/lisp/info.el
r3939 r3988 291 291 "Info file that Info is now looking at, or nil. 292 292 This is the name that was specified in Info, not the actual file name. 293 It doesn't contain directory names or file name extensions added by Info. 294 Can also be t when using `Info-on-current-buffer'.") 293 It doesn't contain directory names or file name extensions added by Info.") 295 294 296 295 (defvar Info-current-subfile nil … … 310 309 (defvar Info-current-file-completions nil 311 310 "Cached completion list for current Info file.") 311 312 (defvar Info-file-supports-index-cookies nil 313 "Non-nil if current Info file supports index cookies.") 312 314 313 315 (defvar Info-index-alternatives nil … … 689 691 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*")) 690 692 ;; Record the node we are leaving. 691 (if ( and Info-current-file (not no-going-back))693 (if (not no-going-back) 692 694 (setq Info-history 693 695 (cons (list Info-current-file Info-current-node (point)) … … 695 697 (Info-find-node-2 filename nodename no-going-back)) 696 698 699 ;;;###autoload 697 700 (defun Info-on-current-buffer (&optional nodename) 698 701 "Use the `Info-mode' to browse the current Info buffer. … … 706 709 (info-initialize) 707 710 (Info-mode) 708 (set (make-local-variable 'Info-current-file) t) 711 (set (make-local-variable 'Info-current-file) 712 (or buffer-file-name 713 ;; If called on a non-file buffer, make a fake file name. 714 (concat default-directory (buffer-name)))) 709 715 (Info-find-node-2 nil nodename)) 710 716 … … 724 730 (wline (count-lines (point-min) (window-start))) 725 731 (old-history Info-history) 726 (new-history (and Info-current-file 727 (list Info-current-file Info-current-node (point))))) 732 (new-history (list Info-current-file Info-current-node (point)))) 728 733 (kill-buffer (current-buffer)) 729 734 (Info-find-node filename nodename) … … 843 848 (setq default-directory (file-name-directory filename)))) 844 849 (set-buffer-modified-p nil) 850 851 ;; Check makeinfo version for index cookie support 852 (let ((found nil)) 853 (goto-char (point-min)) 854 (condition-case () 855 (if (and (re-search-forward 856 "makeinfo version \\([0-9]+.[0-9]+\\)" 857 (line-beginning-position 3) t) 858 (not (version< (match-string 1) "4.7"))) 859 (setq found t)) 860 (error nil)) 861 (set (make-local-variable 'Info-file-supports-index-cookies) found)) 862 845 863 ;; See whether file has a tag table. Record the location if yes. 846 864 (goto-char (point-max)) … … 1385 1403 (list 1386 1404 (concat " (" 1387 (file-name-nondirectory 1388 (if (stringp Info-current-file) 1389 Info-current-file 1390 (or buffer-file-name ""))) 1391 ") " 1392 (or Info-current-node "")))))) 1405 (if Info-current-file 1406 (file-name-nondirectory Info-current-file) 1407 " ") 1408 ") " (or Info-current-node "")))))) 1393 1409 1394 1410 ;; Go to an Info node specified with a filename-and-nodename string … … 1869 1885 (old-file Info-current-file) 1870 1886 (node (Info-extract-pointer "up")) p) 1871 (and (or same-file (not (stringp Info-current-file)))1887 (and same-file 1872 1888 (string-match "^(" node) 1873 1889 (error "Up node is in another Info file")) … … 1946 1962 (string-equal node curr-node)) 1947 1963 (setq p (point))) 1948 (insert "* " node ": (" (file-name-nondirectory file) 1964 (insert "* " node ": (" 1965 (propertize (or (file-name-directory file) "") 'invisible t) 1966 (file-name-nondirectory file) 1949 1967 ")" node ".\n")) 1950 1968 (setq hl (cdr hl)))))) … … 2650 2668 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) 2651 2669 (not (stringp file)) 2652 ;; Find nodes with index cookie 2653 (let* ((default-directory (or (and (stringp file) 2654 (file-name-directory 2655 (setq file (Info-find-file file)))) 2656 default-directory)) 2657 Info-history Info-history-list Info-fontify-maximum-menu-size 2658 (main-file file) subfiles nodes node) 2659 (condition-case nil 2660 (with-temp-buffer 2661 (while (or main-file subfiles) 2662 (erase-buffer) 2663 (info-insert-file-contents (or main-file (car subfiles))) 2664 (goto-char (point-min)) 2665 (while (search-forward "\0\b[index\0\b]" nil 'move) 2666 (save-excursion 2667 (re-search-backward "^\^_") 2668 (search-forward "Node: ") 2669 (setq nodes (cons (Info-following-node-name) nodes)))) 2670 (if main-file 2671 (save-excursion 2672 (goto-char (point-min)) 2673 (if (search-forward "\n\^_\nIndirect:" nil t) 2674 (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) 2675 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) 2676 (setq subfiles (cons (match-string-no-properties 1) 2677 subfiles))))) 2678 (setq subfiles (nreverse subfiles) 2679 main-file nil)) 2680 (setq subfiles (cdr subfiles))))) 2681 (error nil)) 2682 (if nodes 2683 (setq nodes (nreverse nodes) 2684 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) 2685 nodes) 2686 ;; Find nodes with the word "Index" in the node name 2687 (let ((case-fold-search t) 2688 Info-history Info-history-list Info-fontify-maximum-menu-size 2689 nodes node) 2690 (condition-case nil 2691 (with-temp-buffer 2692 (Info-mode) 2693 (Info-find-node file "Top") 2694 (when (and (search-forward "\n* menu:" nil t) 2695 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) 2696 (goto-char (match-beginning 1)) 2697 (setq nodes (list (Info-extract-menu-node-name))) 2698 (Info-goto-node (car nodes)) 2699 (while (and (setq node (Info-extract-pointer "next" t)) 2700 (string-match "\\<Index\\>" node)) 2701 (setq nodes (cons node nodes)) 2702 (Info-goto-node node)))) 2703 (error nil)) 2704 (if nodes 2705 (setq nodes (nreverse nodes) 2706 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) 2707 nodes) 2670 (if Info-file-supports-index-cookies 2671 ;; Find nodes with index cookie 2672 (let* ((default-directory (or (and (stringp file) 2673 (file-name-directory 2674 (setq file (Info-find-file file)))) 2675 default-directory)) 2676 Info-history Info-history-list Info-fontify-maximum-menu-size 2677 (main-file file) subfiles nodes node) 2678 (condition-case nil 2679 (with-temp-buffer 2680 (while (or main-file subfiles) 2681 (erase-buffer) 2682 (info-insert-file-contents (or main-file (car subfiles))) 2683 (goto-char (point-min)) 2684 (while (search-forward "\0\b[index\0\b]" nil 'move) 2685 (save-excursion 2686 (re-search-backward "^\^_") 2687 (search-forward "Node: ") 2688 (setq nodes (cons (Info-following-node-name) nodes)))) 2689 (if main-file 2690 (save-excursion 2691 (goto-char (point-min)) 2692 (if (search-forward "\n\^_\nIndirect:" nil t) 2693 (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) 2694 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) 2695 (setq subfiles (cons (match-string-no-properties 1) 2696 subfiles))))) 2697 (setq subfiles (nreverse subfiles) 2698 main-file nil)) 2699 (setq subfiles (cdr subfiles))))) 2700 (error nil)) 2701 (if nodes 2702 (setq nodes (nreverse nodes) 2703 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) 2704 nodes) 2705 ;; Else find nodes with the word "Index" in the node name 2706 (let ((case-fold-search t) 2707 Info-history Info-history-list Info-fontify-maximum-menu-size 2708 nodes node) 2709 (condition-case nil 2710 (with-temp-buffer 2711 (Info-mode) 2712 (Info-find-node file "Top") 2713 (when (and (search-forward "\n* menu:" nil t) 2714 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) 2715 (goto-char (match-beginning 1)) 2716 (setq nodes (list (Info-extract-menu-node-name))) 2717 (Info-goto-node (car nodes)) 2718 (while (and (setq node (Info-extract-pointer "next" t)) 2719 (string-match "\\<Index\\>" node)) 2720 (setq nodes (cons node nodes)) 2721 (Info-goto-node node)))) 2722 (error nil)) 2723 (if nodes 2724 (setq nodes (nreverse nodes) 2725 Info-index-nodes (cons (cons file nodes) Info-index-nodes))) 2726 nodes)) 2708 2727 ;; If file has no index nodes, still add it to the cache 2709 2728 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) … … 2719 2738 ;; Don't search all index nodes if request is only for the current node 2720 2739 ;; and file is not in the cache of index nodes 2721 ( or2722 (save-match-data 2723 (string-match "\\<Index\\>" (or node Info-current-node ""))) 2724 (save-excursion 2725 (goto-char (+ (or (save-excursion 2726 (search-backward "\n\^_" nil t)) 2727 (point-min)) 2)) 2728 (search-forward "\0\b[index\0\b]" 2729 (or (save-excursion 2730 (search-forward "\n\^_" nil t))2731 (point-max)) t)))))2740 (if Info-file-supports-index-cookies 2741 (save-excursion 2742 (goto-char (+ (or (save-excursion 2743 (search-backward "\n\^_" nil t)) 2744 (point-min)) 2)) 2745 (search-forward "\0\b[index\0\b]" 2746 (or (save-excursion 2747 (search-forward "\n\^_" nil t)) 2748 (point-max)) t)) 2749 (save-match-data 2750 (string-match "\\<Index\\>" (or node Info-current-node "")))))) 2732 2751 2733 2752 (defun Info-goto-index () … … 3163 3182 (let ((map (make-sparse-keymap))) 3164 3183 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map) 3165 (tool-bar-local-item-from-menu 'Info-prev " left-arrow" map Info-mode-map)3166 (tool-bar-local-item-from-menu 'Info-next " right-arrow" map Info-mode-map)3167 (tool-bar-local-item-from-menu 'Info-up "up- arrow" map Info-mode-map)3168 (tool-bar-local-item-from-menu 'Info-history-back " back-arrow" map Info-mode-map)3169 (tool-bar-local-item-from-menu 'Info-history-forward " fwd-arrow" map Info-mode-map)3184 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map) 3185 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map) 3186 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map) 3187 (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map) 3188 (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map) 3170 3189 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map) 3171 3190 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map) … … 3248 3267 (unless Info-current-node 3249 3268 (error "No current Info node")) 3250 (let ((node (concat "(" (file-name-nondirectory 3251 (or (and (stringp Info-current-file) 3252 Info-current-file) 3253 buffer-file-name 3254 "")) 3255 ")" Info-current-node))) 3269 (let ((node (concat "(" (file-name-nondirectory Info-current-file) ")" 3270 Info-current-node))) 3256 3271 (if (zerop (prefix-numeric-value arg)) 3257 3272 (setq node (concat "(info \"" node "\")"))) … … 3505 3520 (setq file-list (cdr file-list)))))) 3506 3521 (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 3522 ;; Bind Info-history to nil, to prevent the index nodes from 3512 3523 ;; getting into the node history. … … 3650 3661 (tbeg (match-beginning 1)) 3651 3662 (tag (match-string 1))) 3652 (if (string-equal tag "Node")3663 (if (string-equal (downcase tag) "node") 3653 3664 (put-text-property nbeg nend 'font-lock-face 'info-header-node) 3654 3665 (put-text-property nbeg nend 'font-lock-face 'info-header-xref) … … 3661 3672 ;; It will either be used in the buffer 3662 3673 ;; or copied in the header line. 3663 (put-text-property tbeg nend 'keymap 3664 (cond 3665 ((equal tag "Prev") Info-prev-link-keymap) 3666 ((equal tag "Next") Info-next-link-keymap) 3667 ((equal tag "Up") Info-up-link-keymap)))))) 3674 (put-text-property 3675 tbeg nend 'keymap 3676 (cond 3677 ((string-equal (downcase tag) "prev") Info-prev-link-keymap) 3678 ((string-equal (downcase tag) "next") Info-next-link-keymap) 3679 ((string-equal (downcase tag) "up" ) Info-up-link-keymap)))))) 3668 3680 (when Info-use-header-line 3669 3681 (goto-char (point-min)) … … 3707 3719 ;; counter example is when a continuation "..." is alone 3708 3720 ;; on a line. 3709 (= ( - (match-end 1) (match-beginning 1))3710 ( - (match-end 2) (match-beginning 2))))3721 (= (string-width (match-string 1)) 3722 (string-width (match-string 2)))) 3711 3723 (let* ((c (preceding-char)) 3712 3724 (face … … 3742 3754 (skip-syntax-backward " (")) 3743 3755 (setq other-tag 3744 (cond ((memq (char-before) '(nil ?\. ?! ??)) 3756 (cond ((save-match-data (looking-back "\\<see")) 3757 "") 3758 ((memq (char-before) '(nil ?\. ?! ??)) 3745 3759 "See ") 3746 3760 ((save-match-data … … 3787 3801 (match-string 4)) 3788 3802 (match-string 2))))) 3789 (file (file-name-nondirectory 3790 Info-current-file)) 3803 (file Info-current-file) 3791 3804 (hl Info-history-list) 3792 3805 res) 3793 3806 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node) 3794 (setq file (file-name-nondirectory 3795 (match-string 1 node)) 3807 (setq file (Info-find-file (match-string 1 node)) 3796 3808 node (if (equal (match-string 2 node) "") 3797 3809 "Top" 3798 3810 (match-string 2 node)))) 3799 (while hl 3800 (if (and (string-equal node (nth 1 (car hl))) 3801 (string-equal file 3802 (file-name-nondirectory 3803 (nth 0 (car hl))))) 3804 (setq res (car hl) hl nil) 3805 (setq hl (cdr hl)))) 3811 (while hl 3812 (if (and (string-equal node (nth 1 (car hl))) 3813 (string-equal file (nth 0 (car hl)))) 3814 (setq res (car hl) hl nil) 3815 (setq hl (cdr hl)))) 3806 3816 res))) 'info-xref-visited 'info-xref)) 3807 3817 ;; For multiline ref, unfontify newline and surrounding whitespace … … 3896 3906 (match-string 1) 3897 3907 (match-string 3))) 3898 (file (file-name-nondirectory Info-current-file))3908 (file Info-current-file) 3899 3909 (hl Info-history-list) 3900 3910 res) 3901 3911 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node) 3902 (setq file (file-name-nondirectory 3903 (match-string 1 node)) 3912 (setq file (Info-find-file (match-string 1 node)) 3904 3913 node (if (equal (match-string 2 node) "") 3905 3914 "Top" 3906 3915 (match-string 2 node)))) 3907 (while hl 3908 (if (and (string-equal node (nth 1 (car hl))) 3909 (string-equal file 3910 (file-name-nondirectory 3911 (nth 0 (car hl))))) 3912 (setq res (car hl) hl nil) 3913 (setq hl (cdr hl)))) 3916 (while hl 3917 (if (and (string-equal node (nth 1 (car hl))) 3918 (string-equal file (nth 0 (car hl)))) 3919 (setq res (car hl) hl nil) 3920 (setq hl (cdr hl)))) 3914 3921 res))) 'info-xref-visited 'info-xref))) 3915 3922 (when (and not-fontified-p (memq Info-hide-note-references '(t hide))) … … 4104 4111 (save-excursion 4105 4112 ;; Set up a buffer we can use to fake-out Info. 4106 (set-buffer (get-buffer-create " *info-browse-tmp*"))4113 (set-buffer (get-buffer-create " *info-browse-tmp*")) 4107 4114 (if (not (equal major-mode 'Info-mode)) 4108 4115 (Info-mode))
