Mercurial > emacs
annotate lisp/info.el @ 3377:68cd0dabfce7
(float_to_string): Skip `-' like digits when ensuring
result looks like a float.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 01 Jun 1993 03:33:40 +0000 |
parents | 1795290d0fc8 |
children | ef8ca321d049 |
rev | line source |
---|---|
754
b096f4af925c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1 ;;; info.el --- info package for Emacs. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
2 |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: help |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
7 |
325 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
325 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
24 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
25 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
26 ;;; Note that nowadays we expect info files to be made using makeinfo. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
27 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
28 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
29 |
325 | 30 (defvar Info-history nil |
31 "List of info nodes user has visited. | |
32 Each element of list is a list (FILENAME NODENAME BUFFERPOS).") | |
33 | |
34 (defvar Info-enable-edit nil | |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
35 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node. |
680
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
36 This is convenient if you want to write info files by hand. |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
37 However, we recommend that you not do this. |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
38 It is better to write a Texinfo file and generate the Info file from that, |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
39 because that gives you a printed manual as well.") |
325 | 40 |
41 (defvar Info-enable-active-nodes t | |
42 "Non-nil allows Info to execute Lisp code associated with nodes. | |
43 The Lisp code is executed when the node is selected.") | |
44 | |
540 | 45 (defvar Info-default-directory-list nil |
46 "List of default directories to search for Info documentation files. | |
47 This value is used as the default for `Info-directory-list'. It is set | |
48 in paths.el.") | |
49 | |
3330
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
50 (defvar Info-directory-list |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
51 (let ((path (getenv "INFOPATH"))) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
52 (if path |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
53 (let ((list nil) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
54 idx) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
55 (while (> (length path) 0) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
56 (setq idx (or (string-match ":" path) (length path)) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
57 list (cons (substring path 0 idx) list) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
58 path (substring path (min (1+ idx) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
59 (length path))))) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
60 (nreverse list)) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
61 Info-default-directory-list)) |
325 | 62 "List of directories to search for Info documentation files. |
540 | 63 nil means not yet initialized. In this case, Info uses the environment |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
64 variable INFOPATH to initialize it, or `Info-default-directory-list' |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
65 if there is no INFOPATH variable in the environment.") |
325 | 66 |
67 (defvar Info-current-file nil | |
68 "Info file that Info is now looking at, or nil.") | |
69 | |
70 (defvar Info-current-subfile nil | |
71 "Info subfile that is actually in the *info* buffer now, | |
72 or nil if current info file is not split into subfiles.") | |
73 | |
74 (defvar Info-current-node nil | |
75 "Name of node that Info is now looking at, or nil.") | |
76 | |
77 (defvar Info-tag-table-marker (make-marker) | |
78 "Marker pointing at beginning of current Info file's tag table. | |
79 Marker points nowhere if file has no tag table.") | |
80 | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
81 (defvar Info-index-alternatives nil |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
82 "List of possible matches for last Info-index command.") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
83 |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
84 (defvar Info-suffix-list '( ("" . nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
85 (".info" . nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
86 (".Z" . "uncompress") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
87 (".Y" . "unyabba") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
88 (".z" . "gunzip") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
89 (".info.Z" . "uncompress") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
90 (".info.Y" . "unyabba") |
3047
fa1b6b4e8409
(Info-suffix-list): Fix duplicate .z to .info.z.
Richard M. Stallman <rms@gnu.org>
parents:
2561
diff
changeset
|
91 (".info.z" . "gunzip")) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
92 "List of file name suffixes and associated decoding commands. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
93 Each entry should be (SUFFIX . STRING); the file is given to |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
94 the command as standard input. If STRING is nil, no decoding is done.") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
95 |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
96 (defun info-insert-file-contents (filename &optional visit) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
97 "Insert the contents of an info file in the current buffer. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
98 Do the right thing if the file has been compressed or zipped." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
99 (if (null (catch 'ok |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
100 (mapcar |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
101 (function |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
102 (lambda (x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
103 (let ((compressed (concat filename (car x)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
104 (if (file-exists-p compressed) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
105 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
106 (insert-file-contents compressed visit) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
107 (if (cdr x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
108 (let ((buffer-read-only nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
109 (shell-command-on-region |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
110 (point-min) (point-max) (cdr x) t))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
111 (throw 'ok t)))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
112 Info-suffix-list) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
113 nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
114 (error "Can't find %s or any compressed version of it!" filename))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
115 |
325 | 116 ;;;###autoload |
117 (defun info (&optional file) | |
118 "Enter Info, the documentation browser. | |
119 Optional argument FILE specifies the file to examine; | |
120 the default is the top-level directory of Info. | |
121 | |
122 In interactive use, a prefix argument directs this command | |
123 to read a file name from the minibuffer." | |
124 (interactive (if current-prefix-arg | |
125 (list (read-file-name "Info file name: " nil nil t)))) | |
126 (if file | |
127 (Info-goto-node (concat "(" file ")")) | |
128 (if (get-buffer "*info*") | |
129 (switch-to-buffer "*info*") | |
130 (Info-directory)))) | |
131 | |
132 ;; Go to an info node specified as separate filename and nodename. | |
133 ;; no-going-back is non-nil if recovering from an error in this function; | |
134 ;; it says do not attempt further (recursive) error recovery. | |
135 (defun Info-find-node (filename nodename &optional no-going-back) | |
136 ;; Convert filename to lower case if not found as specified. | |
137 ;; Expand it. | |
138 (if filename | |
139 (let (temp temp-downcase found) | |
140 (setq filename (substitute-in-file-name filename)) | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
141 (if (string= (downcase (file-name-nondirectory filename)) "dir") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
142 (setq found t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
143 (let ((dirs (if (string-match "^\\./" filename) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
144 ;; If specified name starts with `./' |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
145 ;; then just try current directory. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
146 '("./") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
147 Info-directory-list))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
148 ;; Search the directory list for file FILENAME. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
149 (while (and dirs (not found)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
150 (setq temp (expand-file-name filename (car dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
151 (setq temp-downcase |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
152 (expand-file-name (downcase filename) (car dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
153 ;; Try several variants of specified name. |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
154 (catch 'foundit |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
155 (mapcar |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
156 (function |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
157 (lambda (x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
158 (if (file-exists-p (concat temp (car x))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
159 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
160 (setq found temp) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
161 (throw 'foundit nil))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
162 (if (file-exists-p (concat temp-downcase (car x))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
163 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
164 (setq found temp-downcase) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
165 (throw 'foundit nil))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
166 Info-suffix-list)) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
167 (setq dirs (cdr dirs))))) |
325 | 168 (if found |
169 (setq filename found) | |
170 (error "Info file %s does not exist" filename)))) | |
171 ;; Record the node we are leaving. | |
172 (if (and Info-current-file (not no-going-back)) | |
173 (setq Info-history | |
174 (cons (list Info-current-file Info-current-node (point)) | |
175 Info-history))) | |
176 ;; Go into info buffer. | |
177 (switch-to-buffer "*info*") | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
178 (buffer-disable-undo (current-buffer)) |
325 | 179 (or (eq major-mode 'Info-mode) |
180 (Info-mode)) | |
181 (widen) | |
182 (setq Info-current-node nil) | |
183 (unwind-protect | |
184 (progn | |
185 ;; Switch files if necessary | |
186 (or (null filename) | |
187 (equal Info-current-file filename) | |
188 (let ((buffer-read-only nil)) | |
189 (setq Info-current-file nil | |
190 Info-current-subfile nil | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
191 Info-index-alternatives nil |
325 | 192 buffer-file-name nil) |
193 (erase-buffer) | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
194 (if (eq filename t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
195 (Info-insert-dir) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
196 (info-insert-file-contents filename t) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
197 (setq default-directory (file-name-directory filename))) |
325 | 198 (set-buffer-modified-p nil) |
199 ;; See whether file has a tag table. Record the location if yes. | |
200 (set-marker Info-tag-table-marker nil) | |
201 (goto-char (point-max)) | |
202 (forward-line -8) | |
203 (or (equal nodename "*") | |
204 (not (search-forward "\^_\nEnd tag table\n" nil t)) | |
205 (let (pos) | |
206 ;; We have a tag table. Find its beginning. | |
207 ;; Is this an indirect file? | |
208 (search-backward "\nTag table:\n") | |
209 (setq pos (point)) | |
210 (if (save-excursion | |
211 (forward-line 2) | |
212 (looking-at "(Indirect)\n")) | |
213 ;; It is indirect. Copy it to another buffer | |
214 ;; and record that the tag table is in that buffer. | |
215 (save-excursion | |
216 (let ((buf (current-buffer))) | |
217 (set-buffer (get-buffer-create " *info tag table*")) | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
218 (buffer-disable-undo (current-buffer)) |
325 | 219 (setq case-fold-search t) |
220 (erase-buffer) | |
221 (insert-buffer-substring buf) | |
222 (set-marker Info-tag-table-marker | |
223 (match-end 0)))) | |
998 | 224 (set-marker Info-tag-table-marker pos)))) |
325 | 225 (setq Info-current-file |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
226 (if (eq filename t) "dir" |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
227 (file-name-sans-versions buffer-file-name))))) |
325 | 228 (if (equal nodename "*") |
229 (progn (setq Info-current-node nodename) | |
230 (Info-set-mode-line)) | |
231 ;; Search file for a suitable node. | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
232 (let ((guesspos (point-min)) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
233 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]"))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
234 ;; First get advice from tag table if file has one. |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
235 ;; Also, if this is an indirect info file, |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
236 ;; read the proper subfile into this buffer. |
325 | 237 (if (marker-position Info-tag-table-marker) |
238 (save-excursion | |
239 (set-buffer (marker-buffer Info-tag-table-marker)) | |
240 (goto-char Info-tag-table-marker) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
241 (if (re-search-forward regexp nil t) |
325 | 242 (progn |
243 (setq guesspos (read (current-buffer))) | |
244 ;; If this is an indirect file, | |
245 ;; determine which file really holds this node | |
246 ;; and read it in. | |
247 (if (not (eq (current-buffer) (get-buffer "*info*"))) | |
248 (setq guesspos | |
249 (Info-read-subfile guesspos)))) | |
250 (error "No such node: \"%s\"" nodename)))) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
251 (goto-char (max (point-min) (- guesspos 1000))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
252 ;; Now search from our advised position (or from beg of buffer) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
253 ;; to find the actual node. |
325 | 254 (catch 'foo |
255 (while (search-forward "\n\^_" nil t) | |
256 (forward-line 1) | |
257 (let ((beg (point))) | |
258 (forward-line 1) | |
259 (if (re-search-backward regexp beg t) | |
260 (throw 'foo t)))) | |
261 (error "No such node: %s" nodename))) | |
262 (Info-select-node))) | |
263 ;; If we did not finish finding the specified node, | |
264 ;; go back to the previous one. | |
265 (or Info-current-node no-going-back | |
266 (let ((hist (car Info-history))) | |
267 (setq Info-history (cdr Info-history)) | |
268 (Info-find-node (nth 0 hist) (nth 1 hist) t) | |
269 (goto-char (nth 2 hist))))) | |
270 (goto-char (point-min))) | |
271 | |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
272 ;; Cache the contents of the (virtual) dir file, once we have merged |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
273 ;; it for the first time, so we can save time subsequently. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
274 (defvar Info-dir-contents nil) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
275 |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
276 ;; Cache for the directory we decided to use for the default-directory |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
277 ;; of the merged dir text. |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
278 (defvar Info-dir-contents-directory nil) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
279 |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
280 ;; Construct the Info directory node by merging the files named `dir' |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
281 ;; from various directories. Set the *info* buffer's |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
282 ;; default-directory to the first directory we actually get any text |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
283 ;; from. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
284 (defun Info-insert-dir () |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
285 (if Info-dir-contents |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
286 (insert Info-dir-contents) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
287 (let ((dirs Info-directory-list) |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
288 buffers buffer others nodes dirs-done) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
289 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
290 ;; Search the directory list for the directory file. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
291 (while dirs |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
292 (or (member (file-truename (expand-file-name (car dirs))) dirs-done) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
293 (member (directory-file-name (file-truename (expand-file-name (car dirs)))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
294 dirs-done) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
295 ;; Try several variants of specified name. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
296 ;; Try upcasing, appending `.info', or both. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
297 (let* (temp |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
298 (buffer |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
299 (cond |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
300 ((progn (setq temp (expand-file-name "DIR" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
301 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
302 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
303 ((progn (setq temp (expand-file-name "dir" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
304 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
305 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
306 ((progn (setq temp (expand-file-name "DIR.INFO" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
307 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
308 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
309 ((progn (setq temp (expand-file-name "dir.info" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
310 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
311 (find-file-noselect temp))))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
312 (setq dirs-done |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
313 (cons (file-truename (expand-file-name (car dirs))) |
3225
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
314 (cons (directory-file-name |
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
315 (file-truename (expand-file-name (car dirs)))) |
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
316 dirs-done))) |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
317 (if buffer (setq buffers (cons buffer buffers))))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
318 (setq dirs (cdr dirs))) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
319 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
320 ;; Distinguish the dir file that comes with Emacs from all the |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
321 ;; others. Yes, that is really what this is supposed to do. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
322 ;; If it doesn't work, fix it. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
323 (setq buffer (car buffers) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
324 others (cdr buffers)) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
325 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
326 ;; Insert the entire original dir file as a start; use its |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
327 ;; default directory as the default directory for the whole |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
328 ;; concatenation. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
329 (insert-buffer buffer) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
330 (setq Info-dir-contents-directory (save-excursion |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
331 (set-buffer buffer) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
332 default-directory)) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
333 |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
334 ;; Look at each of the other buffers one by one. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
335 (while others |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
336 (let ((other (car others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
337 ;; In each, find all the menus. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
338 (save-excursion |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
339 (set-buffer other) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
340 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
341 ;; Find each menu, and add an elt to NODES for it. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
342 (while (re-search-forward "^\\* Menu:" nil t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
343 (let (beg nodename end) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
344 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
345 (setq beg (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
346 (search-backward "\n") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
347 (search-forward "Node: ") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
348 (setq nodename (Info-following-node-name)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
349 (search-forward "\n" nil 'move) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
350 (beginning-of-line) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
351 (setq end (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
352 (setq nodes (cons (list nodename other beg end) nodes)))))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
353 (setq others (cdr others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
354 ;; Add to the main menu a menu item for each other node. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
355 (re-search-forward "^\\* Menu:") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
356 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
357 (let ((menu-items '("top")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
358 (nodes nodes) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
359 (case-fold-search t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
360 (end (save-excursion (search-forward "" nil t) (point)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
361 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
362 (let ((nodename (car (car nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
363 (or (member (downcase nodename) menu-items) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
364 (re-search-forward (concat "^\\* " (regexp-quote nodename) ":") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
365 end t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
366 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
367 (insert "* " nodename "\n") |
2038
dd9ab1e9467e
(Info-insert-dir): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2036
diff
changeset
|
368 (setq menu-items (cons nodename menu-items))))) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
369 (setq nodes (cdr nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
370 ;; Now take each node of each of the other buffers |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
371 ;; and merge it into the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
372 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
373 (let ((nodename (car (car nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
374 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
375 ;; Find the like-named node in the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
376 (if (re-search-forward (concat "\n.*\n.*Node: " |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
377 (regexp-quote nodename) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
378 "[,\n\t]") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
379 nil t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
380 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
381 (search-forward "\n" nil 'move) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
382 (beginning-of-line)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
383 ;; If none exists, add one. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
384 (goto-char (point-max)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
385 (insert "\nFile: dir\tnode: " nodename "\n\n* Menu:\n\n")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
386 ;; Merge the text from the other buffer's menu |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
387 ;; into the menu in the like-named node in the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
388 (apply 'insert-buffer-substring (cdr (car nodes))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
389 (insert "\n")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
390 (setq nodes (cdr nodes))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
391 ;; Kill all the buffers we just made. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
392 (while buffers |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
393 (kill-buffer (car buffers)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
394 (setq buffers (cdr buffers)))) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
395 (setq Info-dir-contents (buffer-string))) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
396 (setq default-directory Info-dir-contents-directory)) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
397 |
325 | 398 (defun Info-read-subfile (nodepos) |
399 (set-buffer (marker-buffer Info-tag-table-marker)) | |
400 (goto-char (point-min)) | |
401 (search-forward "\n\^_") | |
402 (let (lastfilepos | |
403 lastfilename) | |
404 (forward-line 2) | |
405 (catch 'foo | |
406 (while (not (looking-at "\^_")) | |
407 (if (not (eolp)) | |
408 (let ((beg (point)) | |
409 thisfilepos thisfilename) | |
410 (search-forward ": ") | |
411 (setq thisfilename (buffer-substring beg (- (point) 2))) | |
412 (setq thisfilepos (read (current-buffer))) | |
413 ;; read in version 19 stops at the end of number. | |
414 ;; Advance to the next line. | |
415 (forward-line 1) | |
416 (if (> thisfilepos nodepos) | |
417 (throw 'foo t)) | |
418 (setq lastfilename thisfilename) | |
419 (setq lastfilepos thisfilepos)) | |
420 (forward-line 1)))) | |
421 (set-buffer (get-buffer "*info*")) | |
422 (or (equal Info-current-subfile lastfilename) | |
423 (let ((buffer-read-only nil)) | |
424 (setq buffer-file-name nil) | |
425 (widen) | |
426 (erase-buffer) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
427 (info-insert-file-contents lastfilename) |
325 | 428 (set-buffer-modified-p nil) |
429 (setq Info-current-subfile lastfilename))) | |
430 (goto-char (point-min)) | |
431 (search-forward "\n\^_") | |
432 (+ (- nodepos lastfilepos) (point)))) | |
433 | |
434 ;; Select the info node that point is in. | |
435 (defun Info-select-node () | |
436 (save-excursion | |
437 ;; Find beginning of node. | |
438 (search-backward "\n\^_") | |
439 (forward-line 2) | |
440 ;; Get nodename spelled as it is in the node. | |
441 (re-search-forward "Node:[ \t]*") | |
442 (setq Info-current-node | |
443 (buffer-substring (point) | |
444 (progn | |
445 (skip-chars-forward "^,\t\n") | |
446 (point)))) | |
447 (Info-set-mode-line) | |
448 ;; Find the end of it, and narrow. | |
449 (beginning-of-line) | |
450 (let (active-expression) | |
451 (narrow-to-region (point) | |
452 (if (re-search-forward "\n[\^_\f]" nil t) | |
453 (prog1 | |
454 (1- (point)) | |
455 (if (looking-at "[\n\^_\f]*execute: ") | |
456 (progn | |
457 (goto-char (match-end 0)) | |
458 (setq active-expression | |
459 (read (current-buffer)))))) | |
460 (point-max))) | |
461 (if Info-enable-active-nodes (eval active-expression))))) | |
462 | |
463 (defun Info-set-mode-line () | |
464 (setq mode-line-buffer-identification | |
465 (concat | |
466 "Info: (" | |
467 (if Info-current-file | |
468 (file-name-nondirectory Info-current-file) | |
469 "") | |
470 ")" | |
471 (or Info-current-node "")))) | |
472 | |
473 ;; Go to an info node specified with a filename-and-nodename string | |
474 ;; of the sort that is found in pointers in nodes. | |
475 | |
476 (defun Info-goto-node (nodename) | |
477 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME." | |
478 (interactive "sGoto node: ") | |
479 (let (filename) | |
480 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" | |
481 nodename) | |
482 (setq filename (if (= (match-beginning 1) (match-end 1)) | |
483 "" | |
484 (substring nodename (match-beginning 2) (match-end 2))) | |
485 nodename (substring nodename (match-beginning 3) (match-end 3))) | |
486 (let ((trim (string-match "\\s *\\'" filename))) | |
487 (if trim (setq filename (substring filename 0 trim)))) | |
488 (let ((trim (string-match "\\s *\\'" nodename))) | |
489 (if trim (setq nodename (substring nodename 0 trim)))) | |
490 (Info-find-node (if (equal filename "") nil filename) | |
491 (if (equal nodename "") "Top" nodename)))) | |
492 | |
540 | 493 (defun Info-restore-point (hl) |
494 "If this node has been visited, restore the point value when we left." | |
495 (if hl | |
496 (if (and (equal (nth 0 (car hl)) Info-current-file) | |
497 (equal (nth 1 (car hl)) Info-current-node)) | |
498 (goto-char (nth 2 (car hl))) | |
499 (Info-restore-point (cdr hl))))) | |
500 | |
325 | 501 (defvar Info-last-search nil |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
502 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.") |
325 | 503 |
504 (defun Info-search (regexp) | |
505 "Search for REGEXP, starting from point, and select node it's found in." | |
506 (interactive "sSearch (regexp): ") | |
507 (if (equal regexp "") | |
508 (setq regexp Info-last-search) | |
509 (setq Info-last-search regexp)) | |
510 (let ((found ()) current | |
511 (onode Info-current-node) | |
512 (ofile Info-current-file) | |
513 (opoint (point)) | |
514 (osubfile Info-current-subfile)) | |
515 (save-excursion | |
516 (save-restriction | |
517 (widen) | |
518 (if (null Info-current-subfile) | |
519 (progn (re-search-forward regexp) (setq found (point))) | |
520 (condition-case err | |
521 (progn (re-search-forward regexp) (setq found (point))) | |
522 (search-failed nil))))) | |
523 (if (not found) ;can only happen in subfile case -- else would have erred | |
524 (unwind-protect | |
525 (let ((list ())) | |
526 (set-buffer (marker-buffer Info-tag-table-marker)) | |
527 (goto-char (point-min)) | |
528 (search-forward "\n\^_\nIndirect:") | |
529 (save-restriction | |
530 (narrow-to-region (point) | |
531 (progn (search-forward "\n\^_") | |
532 (1- (point)))) | |
533 (goto-char (point-min)) | |
534 (search-forward (concat "\n" osubfile ": ")) | |
535 (beginning-of-line) | |
536 (while (not (eobp)) | |
537 (re-search-forward "\\(^.*\\): [0-9]+$") | |
538 (goto-char (+ (match-end 1) 2)) | |
539 (setq list (cons (cons (read (current-buffer)) | |
540 (buffer-substring (match-beginning 1) | |
541 (match-end 1))) | |
542 list)) | |
543 (goto-char (1+ (match-end 0)))) | |
544 (setq list (nreverse list) | |
545 current (car (car list)) | |
546 list (cdr list))) | |
547 (while list | |
548 (message "Searching subfile %s..." (cdr (car list))) | |
549 (Info-read-subfile (car (car list))) | |
550 (setq list (cdr list)) | |
551 (goto-char (point-min)) | |
552 (if (re-search-forward regexp nil t) | |
553 (setq found (point) list ()))) | |
554 (if found | |
555 (message "") | |
556 (signal 'search-failed (list regexp)))) | |
557 (if (not found) | |
558 (progn (Info-read-subfile opoint) | |
559 (goto-char opoint) | |
560 (Info-select-node))))) | |
561 (widen) | |
562 (goto-char found) | |
563 (Info-select-node) | |
564 (or (and (equal onode Info-current-node) | |
565 (equal ofile Info-current-file)) | |
566 (setq Info-history (cons (list ofile onode opoint) | |
567 Info-history))))) | |
568 | |
569 ;; Extract the value of the node-pointer named NAME. | |
570 ;; If there is none, use ERRORNAME in the error message; | |
571 ;; if ERRORNAME is nil, just return nil. | |
572 (defun Info-extract-pointer (name &optional errorname) | |
573 (save-excursion | |
574 (goto-char (point-min)) | |
575 (forward-line 1) | |
576 (if (re-search-backward (concat name ":") nil t) | |
577 (progn | |
578 (goto-char (match-end 0)) | |
579 (Info-following-node-name)) | |
580 (if (eq errorname t) | |
581 nil | |
582 (error (concat "Node has no " (capitalize (or errorname name)))))))) | |
583 | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
584 ;; Return the node name in the buffer following point. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
585 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
586 ;; saying which chas may appear in the node name. |
325 | 587 (defun Info-following-node-name (&optional allowedchars) |
588 (skip-chars-forward " \t") | |
589 (buffer-substring | |
590 (point) | |
591 (progn | |
592 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) | |
593 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) | |
594 (if (looking-at "(") | |
595 (skip-chars-forward "^)"))) | |
596 (skip-chars-backward " ") | |
597 (point)))) | |
598 | |
599 (defun Info-next () | |
600 "Go to the next node of this node." | |
601 (interactive) | |
602 (Info-goto-node (Info-extract-pointer "next"))) | |
603 | |
604 (defun Info-prev () | |
605 "Go to the previous node of this node." | |
606 (interactive) | |
607 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))) | |
608 | |
609 (defun Info-up () | |
610 "Go to the superior node of this node." | |
611 (interactive) | |
540 | 612 (Info-goto-node (Info-extract-pointer "up")) |
613 (Info-restore-point Info-history)) | |
325 | 614 |
615 (defun Info-last () | |
616 "Go back to the last node visited." | |
617 (interactive) | |
618 (or Info-history | |
619 (error "This is the first Info node you looked at")) | |
620 (let (filename nodename opoint) | |
621 (setq filename (car (car Info-history))) | |
622 (setq nodename (car (cdr (car Info-history)))) | |
623 (setq opoint (car (cdr (cdr (car Info-history))))) | |
624 (setq Info-history (cdr Info-history)) | |
625 (Info-find-node filename nodename) | |
626 (setq Info-history (cdr Info-history)) | |
627 (goto-char opoint))) | |
628 | |
629 (defun Info-directory () | |
630 "Go to the Info directory node." | |
631 (interactive) | |
632 (Info-find-node "dir" "top")) | |
633 | |
634 (defun Info-follow-reference (footnotename) | |
635 "Follow cross reference named NAME to the node it refers to. | |
636 NAME may be an abbreviation of the reference name." | |
637 (interactive | |
638 (let ((completion-ignore-case t) | |
639 completions default (start-point (point)) str i) | |
640 (save-excursion | |
641 (goto-char (point-min)) | |
642 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) | |
643 (setq str (buffer-substring | |
644 (match-beginning 1) | |
645 (1- (point)))) | |
646 ;; See if this one should be the default. | |
647 (and (null default) | |
648 (< (match-beginning 0) start-point) | |
649 (<= start-point (point)) | |
650 (setq default t)) | |
651 (setq i 0) | |
652 (while (setq i (string-match "[ \n\t]+" str i)) | |
653 (setq str (concat (substring str 0 i) " " | |
654 (substring str (match-end 0)))) | |
655 (setq i (1+ i))) | |
656 ;; Record as a completion and perhaps as default. | |
657 (if (eq default t) (setq default str)) | |
658 (setq completions | |
659 (cons (cons str nil) | |
660 completions)))) | |
661 (if completions | |
662 (list (completing-read (if default | |
663 (concat "Follow reference named: (" | |
664 default ") ") | |
665 "Follow reference named: ") | |
666 completions default t)) | |
667 (error "No cross-references in this node")))) | |
668 (let (target beg i (str (concat "\\*note " footnotename))) | |
669 (while (setq i (string-match " " str i)) | |
670 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) | |
671 (setq i (+ i 6))) | |
672 (save-excursion | |
673 (goto-char (point-min)) | |
674 (or (re-search-forward str nil t) | |
675 (error "No cross-reference named %s" footnotename)) | |
676 (goto-char (+ (match-beginning 0) 5)) | |
677 (setq target | |
678 (Info-extract-menu-node-name "Bad format cross reference" t))) | |
679 (while (setq i (string-match "[ \t\n]+" target i)) | |
680 (setq target (concat (substring target 0 i) " " | |
681 (substring target (match-end 0)))) | |
682 (setq i (+ i 1))) | |
683 (Info-goto-node target))) | |
684 | |
685 (defun Info-extract-menu-node-name (&optional errmessage multi-line) | |
686 (skip-chars-forward " \t\n") | |
687 (let ((beg (point)) | |
688 str i) | |
689 (skip-chars-forward "^:") | |
690 (forward-char 1) | |
691 (setq str | |
692 (if (looking-at ":") | |
693 (buffer-substring beg (1- (point))) | |
694 (skip-chars-forward " \t\n") | |
695 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) | |
696 (while (setq i (string-match "\n" str i)) | |
697 (aset str i ?\ )) | |
698 str)) | |
699 | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
700 ;; No one calls this and Info-menu-item doesn't exist. |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
701 ;;(defun Info-menu-item-sequence (list) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
702 ;; (while list |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
703 ;; (Info-menu-item (car list)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
704 ;; (setq list (cdr list)))) |
325 | 705 |
706 (defun Info-menu (menu-item) | |
707 "Go to node for menu item named (or abbreviated) NAME. | |
708 Completion is allowed, and the menu item point is on is the default." | |
709 (interactive | |
710 (let ((completions '()) | |
711 ;; If point is within a menu item, use that item as the default | |
712 (default nil) | |
713 (p (point)) | |
714 (last nil)) | |
715 (save-excursion | |
716 (goto-char (point-min)) | |
717 (if (not (search-forward "\n* menu:" nil t)) | |
718 (error "No menu in this node")) | |
719 (while (re-search-forward | |
720 "\n\\* \\([^:\t\n]*\\):" nil t) | |
721 (if (and (null default) | |
722 (prog1 (if last (< last p) nil) | |
723 (setq last (match-beginning 0))) | |
724 (<= p last)) | |
725 (setq default (car (car completions)))) | |
726 (setq completions (cons (cons (buffer-substring | |
727 (match-beginning 1) | |
728 (match-end 1)) | |
729 (match-beginning 1)) | |
730 completions))) | |
731 (if (and (null default) last | |
732 (< last p) | |
733 (<= p (progn (end-of-line) (point)))) | |
734 (setq default (car (car completions))))) | |
735 (let ((item nil)) | |
736 (while (null item) | |
737 (setq item (let ((completion-ignore-case t)) | |
738 (completing-read (if default | |
739 (format "Menu item (default %s): " | |
740 default) | |
741 "Menu item: ") | |
742 completions nil t))) | |
540 | 743 ;; we rely on the fact that completing-read accepts an input |
744 ;; of "" even when the require-match argument is true and "" | |
745 ;; is not a valid possibility | |
325 | 746 (if (string= item "") |
747 (if default | |
748 (setq item default) | |
749 ;; ask again | |
750 (setq item nil)))) | |
751 (list item)))) | |
752 ;; there is a problem here in that if several menu items have the same | |
753 ;; name you can only go to the node of the first with this command. | |
754 (Info-goto-node (Info-extract-menu-item menu-item))) | |
755 | |
756 (defun Info-extract-menu-item (menu-item) | |
757 (setq menu-item (regexp-quote menu-item)) | |
758 (save-excursion | |
759 (goto-char (point-min)) | |
760 (or (search-forward "\n* menu:" nil t) | |
761 (error "No menu in this node")) | |
762 (or (re-search-forward (concat "\n* " menu-item ":") nil t) | |
763 (re-search-forward (concat "\n* " menu-item) nil t) | |
764 (error "No such item in menu")) | |
765 (beginning-of-line) | |
766 (forward-char 2) | |
767 (Info-extract-menu-node-name))) | |
768 | |
769 ;; If COUNT is nil, use the last item in the menu. | |
770 (defun Info-extract-menu-counting (count) | |
771 (save-excursion | |
772 (goto-char (point-min)) | |
773 (or (search-forward "\n* menu:" nil t) | |
774 (error "No menu in this node")) | |
775 (if count | |
776 (or (search-forward "\n* " nil t count) | |
777 (error "Too few items in menu")) | |
778 (while (search-forward "\n* " nil t) | |
779 nil)) | |
780 (Info-extract-menu-node-name))) | |
781 | |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
782 (defun Info-nth-menu-item () |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
783 "Go to the node of the Nth menu item. |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
784 N is the digit argument used to invoke this command." |
325 | 785 (interactive) |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
786 (Info-goto-node |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
787 (Info-extract-menu-counting |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
788 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0)))) |
325 | 789 |
790 (defun Info-top-node () | |
791 "Go to the Top node of this file." | |
792 (interactive) | |
793 (Info-goto-node "Top")) | |
794 | |
795 (defun Info-final-node () | |
796 "Go to the final node in this file." | |
797 (interactive) | |
798 (Info-goto-node "Top") | |
799 (let (Info-history) | |
800 ;; Go to the last node in the menu of Top. | |
801 (Info-goto-node (Info-extract-menu-counting nil)) | |
802 ;; If the last node in the menu is not last in pointer structure, | |
803 ;; move forward until we can't go any farther. | |
804 (while (Info-forward-node t t) nil) | |
805 ;; Then keep moving down to last subnode, unless we reach an index. | |
806 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
807 (save-excursion (search-forward "\n* Menu:" nil t))) | |
808 (Info-goto-node (Info-extract-menu-counting nil))))) | |
809 | |
810 (defun Info-forward-node (&optional not-down no-error) | |
811 "Go forward one node, considering all nodes as forming one sequence." | |
812 (interactive) | |
813 (goto-char (point-min)) | |
814 (forward-line 1) | |
815 ;; three possibilities, in order of priority: | |
816 ;; 1. next node is in a menu in this node (but not in an index) | |
817 ;; 2. next node is next at same level | |
818 ;; 3. next node is up and next | |
819 (cond ((and (not not-down) | |
820 (save-excursion (search-forward "\n* menu:" nil t)) | |
821 (not (string-match "\\<index\\>" Info-current-node))) | |
2036
a71101e5abff
(Info-forward-node): Properly go to first menu item.
Richard M. Stallman <rms@gnu.org>
parents:
2032
diff
changeset
|
822 (Info-goto-node (Info-extract-menu-counting 1)) |
325 | 823 t) |
824 ((save-excursion (search-backward "next:" nil t)) | |
825 (Info-next) | |
826 t) | |
827 ((and (save-excursion (search-backward "up:" nil t)) | |
828 (not (equal (downcase (Info-extract-pointer "up")) "top"))) | |
829 (let ((old-node Info-current-node)) | |
830 (Info-up) | |
831 (let (Info-history success) | |
832 (unwind-protect | |
833 (setq success (Info-forward-node t no-error)) | |
834 (or success (Info-goto-node old-node)))))) | |
835 (no-error nil) | |
836 (t (error "No pointer forward from this node")))) | |
837 | |
838 (defun Info-backward-node () | |
839 "Go backward one node, considering all nodes as forming one sequence." | |
840 (interactive) | |
841 (let ((prevnode (Info-extract-pointer "prev[ious]*" t)) | |
842 (upnode (Info-extract-pointer "up" t))) | |
843 (cond ((and upnode (string-match "(" upnode)) | |
844 (error "First node in file")) | |
845 ((and upnode (or (null prevnode) | |
846 (equal (downcase prevnode) (downcase upnode)))) | |
847 (Info-up)) | |
848 (prevnode | |
849 ;; If we move back at the same level, | |
850 ;; go down to find the last subnode*. | |
851 (Info-prev) | |
852 (let (Info-history) | |
853 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
854 (save-excursion (search-forward "\n* Menu:" nil t))) | |
855 (Info-goto-node (Info-extract-menu-counting nil))))) | |
856 (t | |
857 (error "No pointer backward from this node"))))) | |
858 | |
859 (defun Info-exit () | |
860 "Exit Info by selecting some other buffer." | |
861 (interactive) | |
862 (switch-to-buffer (prog1 (other-buffer (current-buffer)) | |
863 (bury-buffer (current-buffer))))) | |
864 | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
865 (defun Info-next-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
866 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
867 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
868 (forward-line -1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
869 (search-forward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
870 (or (search-forward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
871 (error "No more items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
872 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
873 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
874 (defun Info-last-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
875 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
876 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
877 (forward-line 1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
878 (search-backward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
879 (or (search-backward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
880 (error "No previous items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
881 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
882 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
883 (defmacro no-error (&rest body) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
884 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
885 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
886 (defun Info-next-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
887 "Go to the next node, popping up a level if there is none." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
888 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
889 (cond ((no-error (Info-next-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
890 ((no-error (Info-up)) (forward-line 1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
891 (t (error "No more nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
892 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
893 (defun Info-last-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
894 "Go to the last node, popping up a level if there is none." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
895 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
896 (cond ((no-error (Info-last-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
897 ((no-error (Info-up)) (forward-line -1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
898 (t (error "No previous nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
899 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
900 (defun Info-scroll-up () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
901 "Read the next screen. If end of buffer is visible, go to next entry." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
902 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
903 (if (pos-visible-in-window-p (point-max)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
904 (Info-next-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
905 (scroll-up)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
906 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
907 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
908 (defun Info-scroll-down () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
909 "Read the previous screen. If start of buffer is visible, go to last entry." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
910 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
911 (if (pos-visible-in-window-p (point-min)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
912 (Info-last-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
913 (scroll-down)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
914 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
915 |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
916 (defun Info-index (topic) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
917 "Look up a string in the index for this file. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
918 The index is defined as the first node in the top-level menu whose |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
919 name contains the word \"Index\", plus any immediately following |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
920 nodes whose names also contain the word \"Index\". |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
921 If there are no exact matches to the specified topic, this chooses |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
922 the first match which is a case-insensitive substring of a topic. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
923 Use the `,' command to see the other matches. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
924 Give a blank topic name to go to the Index node itself." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
925 (interactive "sIndex topic: ") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
926 (let ((orignode Info-current-node) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
927 (rnode nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
928 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
929 (regexp-quote topic))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
930 node) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
931 (Info-goto-node "Top") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
932 (or (search-forward "\n* menu:" nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
933 (error "No index")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
934 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
935 (error "No index")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
936 (goto-char (match-beginning 1)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
937 (let ((Info-keeping-history nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
938 (Info-goto-node (Info-extract-menu-node-name))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
939 (or (equal topic "") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
940 (let ((matches nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
941 (exact nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
942 (Info-keeping-history nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
943 found) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
944 (while |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
945 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
946 (goto-char (point-min)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
947 (while (re-search-forward pattern nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
948 (setq matches |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
949 (cons (list (buffer-substring (match-beginning 1) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
950 (match-end 1)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
951 (buffer-substring (match-beginning 2) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
952 (match-end 2)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
953 Info-current-node |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
954 (string-to-int (concat "0" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
955 (buffer-substring |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
956 (match-beginning 3) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
957 (match-end 3))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
958 matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
959 (and (setq node (Info-extract-pointer "next" t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
960 (string-match "\\<Index\\>" node))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
961 (Info-goto-node node)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
962 (or matches |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
963 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
964 (Info-last) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
965 (error "No \"%s\" in index" topic))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
966 ;; Here it is a feature that assoc is case-sensitive. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
967 (while (setq found (assoc topic matches)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
968 (setq exact (cons found exact) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
969 matches (delq found matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
970 (setq Info-index-alternatives (nconc exact (nreverse matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
971 (Info-index-next 0))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
972 |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
973 (defun Info-index-next (num) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
974 "Go to the next matching index item from the last `i' command." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
975 (interactive "p") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
976 (or Info-index-alternatives |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
977 (error "No previous `i' command in this file")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
978 (while (< num 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
979 (setq num (+ num (length Info-index-alternatives)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
980 (while (> num 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
981 (setq Info-index-alternatives |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
982 (nconc (cdr Info-index-alternatives) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
983 (list (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
984 num (1- num))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
985 (Info-goto-node (nth 1 (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
986 (if (> (nth 3 (car Info-index-alternatives)) 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
987 (forward-line (nth 3 (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
988 (forward-line 3) ; don't search in headers |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
989 (let ((name (car (car Info-index-alternatives)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
990 (if (or (re-search-forward (format |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
991 "\\(Function\\|Command\\): %s\\( \\|$\\)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
992 (regexp-quote name)) nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
993 (search-forward (format "`%s'" name) nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
994 (and (string-match "\\`.*\\( (.*)\\)\\'" name) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
995 (search-forward |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
996 (format "`%s'" (substring name 0 (match-beginning 1))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
997 nil t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
998 (search-forward name nil t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
999 (beginning-of-line) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1000 (goto-char (point-min))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1001 (message "Found \"%s\" in %s. %s" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1002 (car (car Info-index-alternatives)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1003 (nth 2 (car Info-index-alternatives)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1004 (if (cdr Info-index-alternatives) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1005 "(Press `,' for more)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1006 "(Only match)"))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1007 |
325 | 1008 (defun Info-undefined () |
1009 "Make command be undefined in Info." | |
1010 (interactive) | |
1011 (ding)) | |
1012 | |
1013 (defun Info-help () | |
1014 "Enter the Info tutorial." | |
1015 (interactive) | |
1016 (delete-other-windows) | |
1017 (Info-find-node "info" | |
1018 (if (< (window-height) 23) | |
1019 "Help-Small-Screen" | |
1020 "Help"))) | |
1021 | |
1022 (defun Info-summary () | |
1023 "Display a brief summary of all Info commands." | |
1024 (interactive) | |
1025 (save-window-excursion | |
1026 (switch-to-buffer "*Help*") | |
1027 (erase-buffer) | |
1028 (insert (documentation 'Info-mode)) | |
1029 (goto-char (point-min)) | |
1030 (let (ch flag) | |
1031 (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) | |
1032 (message (if flag "Type Space to see more" | |
1033 "Type Space to return to Info")) | |
2032
20cc6c34421c
(Info-summary): Handle any event when flushing the display.
Richard M. Stallman <rms@gnu.org>
parents:
1979
diff
changeset
|
1034 (if (not (eq ?\ (setq ch (read-event)))) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1667
diff
changeset
|
1035 (progn (setq unread-command-events (list ch)) nil) |
325 | 1036 flag)) |
1037 (scroll-up))))) | |
1038 | |
1039 (defun Info-get-token (pos start all &optional errorstring) | |
1040 "Return the token around POS, | |
1041 POS must be somewhere inside the token | |
1042 START is a regular expression which will match the | |
1043 beginning of the tokens delimited string | |
1044 ALL is a regular expression with a single | |
1045 parenthized subpattern which is the token to be | |
1046 returned. E.g. '{\(.*\)}' would return any string | |
1047 enclosed in braces around POS. | |
1048 SIG optional fourth argument, controls action on no match | |
1049 nil: return nil | |
1050 t: beep | |
1051 a string: signal an error, using that string." | |
1052 (save-excursion | |
1053 (goto-char pos) | |
1054 (re-search-backward start (max (point-min) (- pos 200)) 'yes) | |
3351
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1055 (let (found) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1056 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1057 (not (setq found (and (<= (match-beginning 0) pos) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1058 (> (match-end 0) pos)))))) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1059 (if (and found (<= (match-beginning 0) pos) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1060 (> (match-end 0) pos)) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1061 (buffer-substring (match-beginning 1) (match-end 1)) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1062 (cond ((null errorstring) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1063 nil) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1064 ((eq errorstring t) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1065 (beep) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1066 nil) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1067 (t |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1068 (error "No %s around position %d" errorstring pos))))))) |
325 | 1069 |
540 | 1070 (defun Info-follow-nearest-node (click) |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1071 "\\<Info-mode-map>Follow a node reference near point. |
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1072 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click. |
325 | 1073 At end of the node's text, moves to the next node." |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1074 (interactive "e") |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1075 (let* ((start (event-start click)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1076 (window (car start)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1077 (pos (car (cdr start)))) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1078 (select-window window) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1079 (goto-char pos)) |
325 | 1080 (let (node) |
1081 (cond | |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1082 ((setq node (Info-get-token (point) "\\*note[ \n]" "\\*note[ \n]\\([^:]*\\):")) |
325 | 1083 (Info-follow-reference node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1084 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::")) |
325 | 1085 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1086 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):")) |
325 | 1087 (Info-menu node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1088 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)")) |
325 | 1089 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1090 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)")) |
325 | 1091 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1092 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)")) |
325 | 1093 (Info-goto-node "Top")) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1094 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) |
325 | 1095 (Info-goto-node node)) |
1096 ((save-excursion (forward-line 1) (eobp)) | |
1097 (Info-next))) | |
1098 )) | |
1099 | |
1100 (defvar Info-mode-map nil | |
1101 "Keymap containing Info commands.") | |
1102 (if Info-mode-map | |
1103 nil | |
1104 (setq Info-mode-map (make-keymap)) | |
1105 (suppress-keymap Info-mode-map) | |
1106 (define-key Info-mode-map "." 'beginning-of-buffer) | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
1107 (define-key Info-mode-map " " 'Info-scroll-up) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
1108 (define-key Info-mode-map "\C-m" 'Info-next-preorder) |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1109 (define-key Info-mode-map "1" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1110 (define-key Info-mode-map "2" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1111 (define-key Info-mode-map "3" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1112 (define-key Info-mode-map "4" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1113 (define-key Info-mode-map "5" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1114 (define-key Info-mode-map "6" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1115 (define-key Info-mode-map "7" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1116 (define-key Info-mode-map "8" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1117 (define-key Info-mode-map "9" 'Info-nth-menu-item) |
1667
9c0e14881b8f
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1666
diff
changeset
|
1118 (define-key Info-mode-map "0" 'undefined) |
325 | 1119 (define-key Info-mode-map "?" 'Info-summary) |
1120 (define-key Info-mode-map "]" 'Info-forward-node) | |
1121 (define-key Info-mode-map "[" 'Info-backward-node) | |
1122 (define-key Info-mode-map "<" 'Info-top-node) | |
1123 (define-key Info-mode-map ">" 'Info-final-node) | |
1124 (define-key Info-mode-map "b" 'beginning-of-buffer) | |
1125 (define-key Info-mode-map "d" 'Info-directory) | |
1126 (define-key Info-mode-map "e" 'Info-edit) | |
1127 (define-key Info-mode-map "f" 'Info-follow-reference) | |
1128 (define-key Info-mode-map "g" 'Info-goto-node) | |
1129 (define-key Info-mode-map "h" 'Info-help) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1130 (define-key Info-mode-map "i" 'Info-index) |
325 | 1131 (define-key Info-mode-map "l" 'Info-last) |
1132 (define-key Info-mode-map "m" 'Info-menu) | |
1133 (define-key Info-mode-map "n" 'Info-next) | |
1134 (define-key Info-mode-map "p" 'Info-prev) | |
1135 (define-key Info-mode-map "q" 'Info-exit) | |
1136 (define-key Info-mode-map "s" 'Info-search) | |
3313
34f2db3916fe
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3225
diff
changeset
|
1137 (define-key Info-mode-map "t" 'Info-top-node) |
325 | 1138 (define-key Info-mode-map "u" 'Info-up) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1139 (define-key Info-mode-map "," 'Info-index-next) |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1140 (define-key Info-mode-map "\177" 'Info-scroll-down) |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1141 (define-key Info-mode-map [mouse-3] 'Info-follow-nearest-node) |
540 | 1142 ) |
325 | 1143 |
1144 ;; Info mode is suitable only for specially formatted data. | |
1145 (put 'info-mode 'mode-class 'special) | |
1146 | |
1147 (defun Info-mode () | |
1148 "\\<Info-mode-map> | |
1149 Info mode provides commands for browsing through the Info documentation tree. | |
1150 Documentation in Info is divided into \"nodes\", each of which discusses | |
1151 one topic and contains references to other nodes which discuss related | |
1152 topics. Info has commands to follow the references and show you other nodes. | |
1153 | |
1154 \\[Info-help] Invoke the Info tutorial. | |
1155 | |
1156 Selecting other nodes: | |
1157 \\[Info-next] Move to the \"next\" node of this node. | |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1158 \\[Info-prev] Move to the \"previous\" node of this node. |
325 | 1159 \\[Info-up] Move \"up\" from this node. |
1160 \\[Info-menu] Pick menu item specified by name (or abbreviation). | |
1161 Picking a menu item causes another node to be selected. | |
540 | 1162 \\[Info-directory] Go to the Info directory node. |
325 | 1163 \\[Info-follow-reference] Follow a cross reference. Reads name of reference. |
1164 \\[Info-last] Move to the last node you were at. | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1165 \\[Info-index] Look up a topic in this file's Index and move to that node. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1166 \\[Info-index-next] (comma) Move to the next match from a previous `i' command. |
325 | 1167 |
1168 Moving within a node: | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1169 \\[scroll-up] Normally, scroll forward a full screen. If the end of the buffer is |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1170 already visible, try to go to the next menu entry, or up if there is none. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1171 \\[scroll-down] Normally, scroll backward. If the beginning of the buffer is |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1172 already visible, try to go to the previous menu entry, or up if there is none. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1173 \\[beginning-of-buffer] Go to beginning of node. |
325 | 1174 |
1175 Advanced commands: | |
1176 \\[Info-exit] Quit Info: reselect previously selected buffer. | |
1177 \\[Info-edit] Edit contents of selected node. | |
1178 1 Pick first item in node's menu. | |
1179 2, 3, 4, 5 Pick second ... fifth item in node's menu. | |
1180 \\[Info-goto-node] Move to node specified by name. | |
1181 You may include a filename as well, as (FILENAME)NODENAME. | |
1182 \\[Info-search] Search through this Info file for specified regexp, | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1183 and select the node in which the next occurrence is found. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1184 \\[Info-next-preorder] Next-preorder; that is, try to go to the next menu item, |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1185 and if that fails try to move up, and if that fails, tell user |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1186 he/she is done reading." |
325 | 1187 (kill-all-local-variables) |
1188 (setq major-mode 'Info-mode) | |
1189 (setq mode-name "Info") | |
1190 (use-local-map Info-mode-map) | |
1191 (set-syntax-table text-mode-syntax-table) | |
1192 (setq local-abbrev-table text-mode-abbrev-table) | |
1193 (setq case-fold-search t) | |
1194 (setq buffer-read-only t) | |
1195 (make-local-variable 'Info-current-file) | |
1196 (make-local-variable 'Info-current-subfile) | |
1197 (make-local-variable 'Info-current-node) | |
1198 (make-local-variable 'Info-tag-table-marker) | |
1199 (make-local-variable 'Info-history) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1200 (make-local-variable 'Info-index-alternatives) |
325 | 1201 (Info-set-mode-line) |
1202 (run-hooks 'Info-mode-hook)) | |
1203 | |
1204 (defvar Info-edit-map nil | |
1205 "Local keymap used within `e' command of Info.") | |
1206 (if Info-edit-map | |
1207 nil | |
1208 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map)) | |
1209 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) | |
1210 | |
1211 ;; Info-edit mode is suitable only for specially formatted data. | |
1212 (put 'info-edit-mode 'mode-class 'special) | |
1213 | |
1214 (defun Info-edit-mode () | |
1215 "Major mode for editing the contents of an Info node. | |
1477 | 1216 Like text mode with the addition of `Info-cease-edit' |
325 | 1217 which returns to Info mode for browsing. |
1218 \\{Info-edit-map}" | |
1219 ) | |
1220 | |
1221 (defun Info-edit () | |
1222 "Edit the contents of this Info node. | |
1223 Allowed only if variable `Info-enable-edit' is non-nil." | |
1224 (interactive) | |
1225 (or Info-enable-edit | |
1226 (error "Editing info nodes is not enabled")) | |
1227 (use-local-map Info-edit-map) | |
1228 (setq major-mode 'Info-edit-mode) | |
1229 (setq mode-name "Info Edit") | |
1230 (kill-local-variable 'mode-line-buffer-identification) | |
1231 (setq buffer-read-only nil) | |
1232 ;; Make mode line update. | |
1233 (set-buffer-modified-p (buffer-modified-p)) | |
1234 (message (substitute-command-keys | |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
1235 "Editing: Type \\<Info-mode-map>\\[Info-cease-edit] to return to info"))) |
325 | 1236 |
1237 (defun Info-cease-edit () | |
1238 "Finish editing Info node; switch back to Info proper." | |
1239 (interactive) | |
1240 ;; Do this first, so nothing has changed if user C-g's at query. | |
1241 (and (buffer-modified-p) | |
1242 (y-or-n-p "Save the file? ") | |
1243 (save-buffer)) | |
1244 (use-local-map Info-mode-map) | |
1245 (setq major-mode 'Info-mode) | |
1246 (setq mode-name "Info") | |
1247 (Info-set-mode-line) | |
1248 (setq buffer-read-only t) | |
1249 ;; Make mode line update. | |
1250 (set-buffer-modified-p (buffer-modified-p)) | |
1251 (and (marker-position Info-tag-table-marker) | |
1252 (buffer-modified-p) | |
1253 (message "Tags may have changed. Use Info-tagify if necessary"))) | |
359 | 1254 |
1255 (defun Info-find-emacs-command-nodes (command) | |
1256 "Return a list of locations documenting COMMAND in the Emacs Info manual. | |
1257 The locations are of the format used in Info-history, i.e. | |
1258 \(FILENAME NODENAME BUFFERPOS\)." | |
1259 (require 'info) | |
1260 (let ((where '()) | |
1261 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) | |
1262 ":\\s *\\(.*\\)\\.$"))) | |
1263 (save-excursion | |
1264 (Info-find-node "emacs" "Command Index") | |
1265 ;; Take the index node off the Info history. | |
1266 (setq Info-history (cdr Info-history)) | |
1267 (goto-char (point-max)) | |
1268 (while (re-search-backward cmd-desc nil t) | |
1269 (setq where (cons (list Info-current-file | |
1270 (buffer-substring | |
1271 (match-beginning 1) | |
1272 (match-end 1)) | |
1273 0) | |
1274 where))) | |
1275 where))) | |
1276 | |
1277 ;;;###autoload | |
1278 (defun Info-goto-emacs-command-node (command) | |
1279 "Go to the Info node in the Emacs manual for command COMMAND." | |
1280 (interactive "CFind documentation for command: ") | |
1281 (or (commandp command) | |
1282 (signal 'wrong-type-argument (list 'commandp command))) | |
1283 (let ((where (Info-find-emacs-command-nodes command))) | |
1284 (if where | |
1285 (let ((num-matches (length where))) | |
1286 ;; Get Info running, and pop to it in another window. | |
1287 (save-window-excursion | |
1288 (info)) | |
1289 (pop-to-buffer "*info*") | |
1290 (Info-find-node (car (car where)) | |
1291 (car (cdr (car where)))) | |
1292 (if (> num-matches 1) | |
1293 (progn | |
1294 ;; Info-find-node already pushed (car where) onto | |
1295 ;; Info-history. Put the other nodes that were found on | |
1296 ;; the history. | |
1297 (setq Info-history (nconc (cdr where) Info-history)) | |
1298 (message (substitute-command-keys | |
1299 "Found %d other entr%. Use \\[Info-last] to see %s." | |
1300 (1- num-matches) | |
1301 (if (> num-matches 2) "ies" "y") | |
1302 (if (> num-matches 2) "them" "it")))))) | |
1303 (error "Couldn't find documentation for %s." command)))) | |
1304 | |
1305 ;;;###autoload | |
1306 (defun Info-goto-emacs-key-command-node (key) | |
1307 "Go to the Info node in the Emacs manual the command bound to KEY, a string. | |
1308 Interactively, if the binding is execute-extended-command, a command is read." | |
1309 (interactive "kFind documentation for key:") | |
1310 (let ((command (key-binding key))) | |
1311 (cond ((null command) | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1312 (message "%s is undefined" (key-description key))) |
359 | 1313 ((and (interactive-p) |
1314 (eq command 'execute-extended-command)) | |
1315 (Info-goto-emacs-command-node | |
1316 (read-command "Find documentation for command: "))) | |
1317 (t | |
1318 (Info-goto-emacs-command-node command))))) | |
584 | 1319 |
1320 (provide 'info) | |
1321 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1322 ;;; info.el ends here |