diff options
| author | Juri Linkov | 2004-05-25 20:59:31 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-05-25 20:59:31 +0000 |
| commit | 50163b00ab93025a862d8d281d34cd7a0ab24aab (patch) | |
| tree | d4c939e1085596b84e62fe21ffe99eb075c4666b | |
| parent | 59de4ad0fcace2f33f2fb5101f84bce6ea29aab2 (diff) | |
| download | emacs-50163b00ab93025a862d8d281d34cd7a0ab24aab.tar.gz emacs-50163b00ab93025a862d8d281d34cd7a0ab24aab.zip | |
(Info-toc): Call Info-mode on intermediate buffer.
(Info-index-nodes): Enclose code in condition-case to catch errors.
(Info-index-node): Don't search all index nodes if request is only
for the current node and file is not in the cache of index nodes.
(Info-mode-map): Bind Info-copy-current-node-name to `w'
for consistency with dired-copy-filename-as-kill.
Bind `S' to Info-search-case-sensitively.
(Info-copy-current-node-name): New arg. With zero prefix arg put
the name inside a function call to `info'. Display copied text in
the echo area.
| -rw-r--r-- | lisp/info.el | 148 |
1 files changed, 87 insertions, 61 deletions
diff --git a/lisp/info.el b/lisp/info.el index 9f32c17b544..84ee6ac5e79 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -1691,6 +1691,7 @@ If SAME-FILE is non-nil, do not move to a different Info file." | |||
| 1691 | (if (not (bobp)) | 1691 | (if (not (bobp)) |
| 1692 | (let ((Info-hide-note-references 'hide) | 1692 | (let ((Info-hide-note-references 'hide) |
| 1693 | (Info-fontify-visited-nodes nil)) | 1693 | (Info-fontify-visited-nodes nil)) |
| 1694 | (Info-mode) | ||
| 1694 | (setq Info-current-file "toc" Info-current-node "Top") | 1695 | (setq Info-current-file "toc" Info-current-node "Top") |
| 1695 | (Info-fontify-node))) | 1696 | (Info-fontify-node))) |
| 1696 | (goto-char (point-min)) | 1697 | (goto-char (point-min)) |
| @@ -2349,78 +2350,97 @@ Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).") | |||
| 2349 | (defun Info-index-nodes (&optional file) | 2350 | (defun Info-index-nodes (&optional file) |
| 2350 | "Return a list of names of all index nodes in Info FILE. | 2351 | "Return a list of names of all index nodes in Info FILE. |
| 2351 | If FILE is omitted, it defaults to the current Info file. | 2352 | If FILE is omitted, it defaults to the current Info file. |
| 2352 | First look in a list of cached index node names. Then scan Info file | 2353 | First look in a list of cached index node names. Then scan Info |
| 2353 | and its subfiles for nodes with index cookie. Then try index nodes | 2354 | file and its subfiles for nodes with the index cookie. Then try |
| 2354 | starting from the first node in the top level menu whose name | 2355 | to find index nodes starting from the first node in the top level |
| 2355 | contains the word \"Index\", plus any immediately following nodes | 2356 | menu whose name contains the word \"Index\", plus any immediately |
| 2356 | whose names also contain the word \"Index\"." | 2357 | following nodes whose names also contain the word \"Index\"." |
| 2357 | (or file (setq file Info-current-file)) | 2358 | (or file (setq file Info-current-file)) |
| 2358 | (or (assoc file Info-index-nodes) | 2359 | (or (assoc file Info-index-nodes) |
| 2359 | ;; Skip virtual Info files | 2360 | ;; Skip virtual Info files |
| 2360 | (member file '("dir" "history" "toc" "apropos")) | 2361 | (and (member file '("dir" "history" "toc" "apropos")) |
| 2362 | (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) | ||
| 2363 | (not (stringp file)) | ||
| 2361 | ;; Find nodes with index cookie | 2364 | ;; Find nodes with index cookie |
| 2362 | (let* ((default-directory (or (and (stringp file) | 2365 | (let* ((default-directory (or (and (stringp file) |
| 2363 | (file-name-directory | 2366 | (file-name-directory |
| 2364 | (setq file (Info-find-file file)))) | 2367 | (setq file (Info-find-file file)))) |
| 2365 | default-directory)) | 2368 | default-directory)) |
| 2366 | (main-file file) | 2369 | Info-history Info-history-list Info-fontify-maximum-menu-size |
| 2367 | (Info-fontify-maximum-menu-size nil) | 2370 | (main-file file) subfiles nodes node) |
| 2368 | subfiles nodes node Info-history Info-history-list) | 2371 | (condition-case nil |
| 2369 | (with-temp-buffer | 2372 | (with-temp-buffer |
| 2370 | (while (or main-file subfiles) | 2373 | (while (or main-file subfiles) |
| 2371 | (erase-buffer) | 2374 | (erase-buffer) |
| 2372 | (info-insert-file-contents (or main-file (car subfiles))) | 2375 | (info-insert-file-contents (or main-file (car subfiles))) |
| 2373 | (goto-char (point-min)) | 2376 | (goto-char (point-min)) |
| 2374 | (while (search-forward "\0\10[index\0\10]" nil 'move) | 2377 | (while (search-forward "\0\b[index\0\b]" nil 'move) |
| 2375 | (save-excursion | 2378 | (save-excursion |
| 2376 | (re-search-backward "^\^_") | 2379 | (re-search-backward "^\^_") |
| 2377 | (search-forward "Node: ") | 2380 | (search-forward "Node: ") |
| 2378 | (setq nodes (cons (Info-following-node-name) nodes)))) | 2381 | (setq nodes (cons (Info-following-node-name) nodes)))) |
| 2379 | (if main-file | 2382 | (if main-file |
| 2380 | (save-excursion | 2383 | (save-excursion |
| 2381 | (goto-char (point-min)) | 2384 | (goto-char (point-min)) |
| 2382 | (if (search-forward "\n\^_\nIndirect:" nil t) | 2385 | (if (search-forward "\n\^_\nIndirect:" nil t) |
| 2383 | (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) | 2386 | (let ((bound (save-excursion (search-forward "\n\^_" nil t)))) |
| 2384 | (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) | 2387 | (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t) |
| 2385 | (setq subfiles (cons (match-string-no-properties 1) | 2388 | (setq subfiles (cons (match-string-no-properties 1) |
| 2386 | subfiles))))) | 2389 | subfiles))))) |
| 2387 | (setq subfiles (nreverse subfiles) | 2390 | (setq subfiles (nreverse subfiles) |
| 2388 | main-file nil)) | 2391 | main-file nil)) |
| 2389 | (setq subfiles (cdr subfiles))))) | 2392 | (setq subfiles (cdr subfiles))))) |
| 2393 | (error nil)) | ||
| 2390 | (if nodes | 2394 | (if nodes |
| 2391 | (setq nodes (nreverse nodes) | 2395 | (setq nodes (nreverse nodes) |
| 2392 | Info-index-nodes (cons (cons file nodes) Info-index-nodes))) | 2396 | Info-index-nodes (cons (cons file nodes) Info-index-nodes))) |
| 2393 | nodes) | 2397 | nodes) |
| 2394 | ;; Find nodes with string "Index" in node names | 2398 | ;; Find nodes with the word "Index" in the node name |
| 2395 | (let ((Info-fontify-maximum-menu-size nil) | 2399 | (let ((case-fold-search t) |
| 2396 | (case-fold-search t) | 2400 | Info-history Info-history-list Info-fontify-maximum-menu-size |
| 2397 | nodes node Info-history Info-history-list) | 2401 | nodes node) |
| 2398 | (with-temp-buffer | 2402 | (condition-case nil |
| 2399 | (Info-mode) | 2403 | (with-temp-buffer |
| 2400 | (Info-find-node file "Top") | 2404 | (Info-mode) |
| 2401 | (when (and (search-forward "\n* menu:" nil t) | 2405 | (Info-find-node file "Top") |
| 2402 | (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) | 2406 | (when (and (search-forward "\n* menu:" nil t) |
| 2403 | (goto-char (match-beginning 1)) | 2407 | (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)) |
| 2404 | (setq nodes (list (Info-extract-menu-node-name))) | 2408 | (goto-char (match-beginning 1)) |
| 2405 | (Info-goto-node (car nodes)) | 2409 | (setq nodes (list (Info-extract-menu-node-name))) |
| 2406 | (while (and (setq node (Info-extract-pointer "next" t)) | 2410 | (Info-goto-node (car nodes)) |
| 2407 | (string-match "\\<Index\\>" node)) | 2411 | (while (and (setq node (Info-extract-pointer "next" t)) |
| 2408 | (setq nodes (cons node nodes)) | 2412 | (string-match "\\<Index\\>" node)) |
| 2409 | (Info-goto-node node)))) | 2413 | (setq nodes (cons node nodes)) |
| 2414 | (Info-goto-node node)))) | ||
| 2415 | (error nil)) | ||
| 2410 | (if nodes | 2416 | (if nodes |
| 2411 | (setq nodes (nreverse nodes) | 2417 | (setq nodes (nreverse nodes) |
| 2412 | Info-index-nodes (cons (cons file nodes) Info-index-nodes))) | 2418 | Info-index-nodes (cons (cons file nodes) Info-index-nodes))) |
| 2413 | nodes) | 2419 | nodes) |
| 2414 | ;; Info file has no index nodes | 2420 | ;; If file has no index nodes, still add it to the cache |
| 2415 | (setq Info-index-nodes (cons (cons file nil) | 2421 | (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) |
| 2416 | Info-index-nodes))) | ||
| 2417 | (cdr (assoc file Info-index-nodes))) | 2422 | (cdr (assoc file Info-index-nodes))) |
| 2418 | 2423 | ||
| 2419 | (defun Info-index-node (&optional node file) | 2424 | (defun Info-index-node (&optional node file) |
| 2420 | "Return non-nil value if NODE is an index node. | 2425 | "Return non-nil value if NODE is an index node. |
| 2421 | If NODE is nil, check the current Info node. | 2426 | If NODE is nil, check the current Info node. |
| 2422 | If FILE is nil, check the current Info file." | 2427 | If FILE is nil, check the current Info file." |
| 2423 | (member (or node Info-current-node) (Info-index-nodes file))) | 2428 | (if (or (and node (not (equal node Info-current-node))) |
| 2429 | (assoc (or file Info-current-file) Info-index-nodes)) | ||
| 2430 | (member (or node Info-current-node) (Info-index-nodes file)) | ||
| 2431 | ;; Don't search all index nodes if request is only for the current node | ||
| 2432 | ;; and file is not in the cache of index nodes | ||
| 2433 | (or | ||
| 2434 | (save-match-data | ||
| 2435 | (string-match "\\<Index\\>" (or node Info-current-node ""))) | ||
| 2436 | (save-excursion | ||
| 2437 | (goto-char (+ (or (save-excursion | ||
| 2438 | (search-backward "\n\^_" nil t)) | ||
| 2439 | (point-min)) 2)) | ||
| 2440 | (search-forward "\0\b[index\0\b]" | ||
| 2441 | (or (save-excursion | ||
| 2442 | (search-forward "\n\^_" nil t)) | ||
| 2443 | (point-max)) t))))) | ||
| 2424 | 2444 | ||
| 2425 | (defun Info-goto-index () | 2445 | (defun Info-goto-index () |
| 2426 | "Go to the first index node." | 2446 | "Go to the first index node." |
| @@ -2771,11 +2791,14 @@ if point is in a menu item description, follow that menu item." | |||
| 2771 | (define-key Info-mode-map "p" 'Info-prev) | 2791 | (define-key Info-mode-map "p" 'Info-prev) |
| 2772 | (define-key Info-mode-map "q" 'Info-exit) | 2792 | (define-key Info-mode-map "q" 'Info-exit) |
| 2773 | (define-key Info-mode-map "s" 'Info-search) | 2793 | (define-key Info-mode-map "s" 'Info-search) |
| 2794 | (define-key Info-mode-map "S" 'Info-search-case-sensitively) | ||
| 2774 | ;; For consistency with Rmail. | 2795 | ;; For consistency with Rmail. |
| 2775 | (define-key Info-mode-map "\M-s" 'Info-search) | 2796 | (define-key Info-mode-map "\M-s" 'Info-search) |
| 2776 | (define-key Info-mode-map "\M-n" 'clone-buffer) | 2797 | (define-key Info-mode-map "\M-n" 'clone-buffer) |
| 2777 | (define-key Info-mode-map "t" 'Info-top-node) | 2798 | (define-key Info-mode-map "t" 'Info-top-node) |
| 2778 | (define-key Info-mode-map "u" 'Info-up) | 2799 | (define-key Info-mode-map "u" 'Info-up) |
| 2800 | ;; For consistency with dired-copy-filename-as-kill. | ||
| 2801 | (define-key Info-mode-map "w" 'Info-copy-current-node-name) | ||
| 2779 | (define-key Info-mode-map "," 'Info-index-next) | 2802 | (define-key Info-mode-map "," 'Info-index-next) |
| 2780 | (define-key Info-mode-map "\177" 'Info-scroll-down) | 2803 | (define-key Info-mode-map "\177" 'Info-scroll-down) |
| 2781 | (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) | 2804 | (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) |
| @@ -2920,20 +2943,23 @@ if point is in a menu item description, follow that menu item." | |||
| 2920 | (error (ding)))) | 2943 | (error (ding)))) |
| 2921 | 2944 | ||
| 2922 | 2945 | ||
| 2923 | (defun Info-copy-current-node-name () | 2946 | (defun Info-copy-current-node-name (&optional arg) |
| 2924 | "Put the name of the current info node into the kill ring. | 2947 | "Put the name of the current info node into the kill ring. |
| 2925 | The name of the info file is prepended to the node name in parentheses." | 2948 | The name of the info file is prepended to the node name in parentheses. |
| 2926 | (interactive) | 2949 | With a zero prefix arg, put the name inside a function call to `info'." |
| 2950 | (interactive "P") | ||
| 2927 | (unless Info-current-node | 2951 | (unless Info-current-node |
| 2928 | (error "No current info node")) | 2952 | (error "No current info node")) |
| 2929 | (kill-new | 2953 | (let ((node (concat "(" (file-name-nondirectory |
| 2930 | (concat "(" | 2954 | (or (and (stringp Info-current-file) |
| 2931 | (file-name-nondirectory | 2955 | Info-current-file) |
| 2932 | (if (stringp Info-current-file) | 2956 | buffer-file-name |
| 2933 | Info-current-file | 2957 | "")) |
| 2934 | (or buffer-file-name ""))) | 2958 | ")" Info-current-node))) |
| 2935 | ")" | 2959 | (if (zerop (prefix-numeric-value arg)) |
| 2936 | Info-current-node))) | 2960 | (setq node (concat "(info \"" node "\")"))) |
| 2961 | (kill-new node) | ||
| 2962 | (message "%s" node))) | ||
| 2937 | 2963 | ||
| 2938 | 2964 | ||
| 2939 | ;; Info mode is suitable only for specially formatted data. | 2965 | ;; Info mode is suitable only for specially formatted data. |