754
|
1 ;;; info.el --- info package for Emacs.
|
807
|
2
|
22733
|
3 ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98 Free Software
|
17154
|
4 ;; Foundation, Inc.
|
846
|
5
|
807
|
6 ;; Maintainer: FSF
|
811
|
7 ;; Keywords: help
|
807
|
8
|
325
|
9 ;; This file is part of GNU Emacs.
|
|
10
|
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
12 ;; it under the terms of the GNU General Public License as published by
|
807
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
325
|
14 ;; any later version.
|
|
15
|
|
16 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;; GNU General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
14169
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
24 ;; Boston, MA 02111-1307, USA.
|
325
|
25
|
807
|
26 ;;; Commentary:
|
|
27
|
14169
|
28 ;; Note that nowadays we expect info files to be made using makeinfo.
|
807
|
29
|
|
30 ;;; Code:
|
|
31
|
17430
|
32 (defgroup info nil
|
|
33 "Info subsystem"
|
|
34 :group 'help
|
|
35 :group 'docs)
|
|
36
|
|
37
|
325
|
38 (defvar Info-history nil
|
|
39 "List of info nodes user has visited.
|
|
40 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
|
|
41
|
17430
|
42 (defcustom Info-enable-edit nil
|
3084
|
43 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
|
680
|
44 This is convenient if you want to write info files by hand.
|
|
45 However, we recommend that you not do this.
|
|
46 It is better to write a Texinfo file and generate the Info file from that,
|
17430
|
47 because that gives you a printed manual as well."
|
|
48 :type 'boolean
|
|
49 :group 'info)
|
325
|
50
|
15177
|
51 (defvar Info-enable-active-nodes nil
|
325
|
52 "Non-nil allows Info to execute Lisp code associated with nodes.
|
|
53 The Lisp code is executed when the node is selected.")
|
15177
|
54 (put 'Info-enable-active-nodes 'risky-local-variable t)
|
325
|
55
|
17430
|
56 (defcustom Info-fontify t
|
|
57 "*Non-nil enables highlighting and fonts in Info nodes."
|
|
58 :type 'boolean
|
|
59 :group 'info)
|
4410
|
60
|
19043
|
61 (defface info-node
|
|
62 '((t (:bold t :italic t)))
|
|
63 "Face for Info node names."
|
|
64 :group 'info)
|
|
65
|
|
66 (defface info-menu-5
|
|
67 '((t (:underline t)))
|
|
68 "Face for the fifth and tenth `*' in an Info menu."
|
|
69 :group 'info)
|
|
70
|
|
71 (defface info-xref
|
|
72 '((t (:bold t)))
|
|
73 "Face for Info cross-references."
|
|
74 :group 'info)
|
|
75
|
17430
|
76 (defcustom Info-fontify-maximum-menu-size 30000
|
|
77 "*Maximum size of menu to fontify if `Info-fontify' is non-nil."
|
|
78 :type 'integer
|
|
79 :group 'info)
|
8480
|
80
|
3330
|
81 (defvar Info-directory-list
|
5482
|
82 (let ((path (getenv "INFOPATH"))
|
12294
3631443c706e
(Info-directory-list): If path-separator isn't available, bind it here.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
83 ;; This is for older Emacs versions
|
3631443c706e
(Info-directory-list): If path-separator isn't available, bind it here.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
84 ;; which might get this info.el from the Texinfo distribution.
|
3631443c706e
(Info-directory-list): If path-separator isn't available, bind it here.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
85 (path-separator (if (boundp 'path-separator) path-separator
|
3631443c706e
(Info-directory-list): If path-separator isn't available, bind it here.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
86 (if (eq system-type 'ms-dos) ";" ":")))
|
13620
|
87 (source (expand-file-name "info/" source-directory))
|
11781
|
88 (sibling (if installation-directory
|
13620
|
89 (expand-file-name "info/" installation-directory)))
|
|
90 alternative)
|
3330
|
91 (if path
|
|
92 (let ((list nil)
|
|
93 idx)
|
|
94 (while (> (length path) 0)
|
11959
|
95 (setq idx (or (string-match path-separator path) (length path))
|
3330
|
96 list (cons (substring path 0 idx) list)
|
|
97 path (substring path (min (1+ idx)
|
|
98 (length path)))))
|
|
99 (nreverse list))
|
13620
|
100 (if (and sibling (file-exists-p sibling))
|
|
101 (setq alternative sibling)
|
|
102 (setq alternative source))
|
|
103 (if (or (member alternative Info-default-directory-list)
|
|
104 (not (file-exists-p alternative))
|
9782
|
105 ;; On DOS/NT, we use movable executables always,
|
7990
|
106 ;; and we must always find the Info dir at run time.
|
9782
|
107 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
|
7990
|
108 nil
|
|
109 ;; Use invocation-directory for Info only if we used it for
|
|
110 ;; exec-directory also.
|
|
111 (not (string= exec-directory
|
11781
|
112 (expand-file-name "lib-src/"
|
|
113 installation-directory)))))
|
5482
|
114 Info-default-directory-list
|
13620
|
115 (reverse (cons alternative
|
|
116 (cdr (reverse Info-default-directory-list)))))))
|
325
|
117 "List of directories to search for Info documentation files.
|
540
|
118 nil means not yet initialized. In this case, Info uses the environment
|
1979
|
119 variable INFOPATH to initialize it, or `Info-default-directory-list'
|
7739
|
120 if there is no INFOPATH variable in the environment.
|
|
121 The last element of `Info-default-directory-list' is the directory
|
7753
|
122 where Emacs installs the Info files that come with it.
|
8461
|
123
|
|
124 If you run the Emacs executable from the `src' directory in the Emacs
|
|
125 source tree, the `info' directory in the source tree is used as the last
|
|
126 element, in place of the installation Info directory. This is useful
|
|
127 when you run a version of Emacs without installing it.")
|
325
|
128
|
17430
|
129 (defcustom Info-additional-directory-list nil
|
8480
|
130 "List of additional directories to search for Info documentation files.
|
17430
|
131 These directories are not searched for merging the `dir' file."
|
|
132 :type '(repeat directory)
|
|
133 :group 'info)
|
8480
|
134
|
325
|
135 (defvar Info-current-file nil
|
12646
|
136 "Info file that Info is now looking at, or nil.
|
|
137 This is the name that was specified in Info, not the actual file name.
|
|
138 It doesn't contain directory names or file name extensions added by Info.")
|
325
|
139
|
|
140 (defvar Info-current-subfile nil
|
|
141 "Info subfile that is actually in the *info* buffer now,
|
|
142 or nil if current info file is not split into subfiles.")
|
|
143
|
|
144 (defvar Info-current-node nil
|
|
145 "Name of node that Info is now looking at, or nil.")
|
|
146
|
16981
|
147 (defvar Info-tag-table-marker nil
|
325
|
148 "Marker pointing at beginning of current Info file's tag table.
|
|
149 Marker points nowhere if file has no tag table.")
|
|
150
|
16981
|
151 (defvar Info-tag-table-buffer nil
|
|
152 "Buffer used for indirect tag tables.")
|
|
153
|
4410
|
154 (defvar Info-current-file-completions nil
|
|
155 "Cached completion list for current Info file.")
|
|
156
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
157 (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>
diff
changeset
|
158 "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>
diff
changeset
|
159
|
4410
|
160 (defvar Info-standalone nil
|
|
161 "Non-nil if Emacs was started solely as an Info browser.")
|
|
162
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
163 (defvar Info-suffix-list
|
19937
|
164 ;; The MS-DOS list should work both when long file names are
|
|
165 ;; supported (Windows 9X), and when only 8+3 file names are available.
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
166 (if (eq system-type 'ms-dos)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
167 '( (".gz" . "gunzip")
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
168 (".z" . "gunzip")
|
19937
|
169 (".inz" . "gunzip")
|
|
170 (".igz" . "gunzip")
|
|
171 (".info.Z" . "gunzip")
|
|
172 (".info.gz" . "gunzip")
|
|
173 ("-info.Z" . "gunzip")
|
|
174 ("-info.gz" . "gunzip")
|
|
175 ("/index.gz". "gunzip")
|
|
176 ("/index.z" . "gunzip")
|
13004
|
177 (".inf" . nil)
|
19937
|
178 (".info" . nil)
|
|
179 ("-info" . nil)
|
|
180 ("/index" . nil)
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
181 ("" . nil))
|
17941
|
182 '( (".info.Z". "uncompress")
|
|
183 (".info.Y". "unyabba")
|
|
184 (".info.gz". "gunzip")
|
|
185 (".info.z". "gunzip")
|
|
186 (".info". nil)
|
|
187 ("-info.Z". "uncompress")
|
|
188 ("-info.Y". "unyabba")
|
|
189 ("-info.gz". "gunzip")
|
|
190 ("-info.z". "gunzip")
|
|
191 ("-info". nil)
|
|
192 ("/index.Z". "uncompress")
|
|
193 ("/index.Y". "unyabba")
|
|
194 ("/index.gz". "gunzip")
|
|
195 ("/index.z". "gunzip")
|
|
196 ("/index". nil)
|
|
197 (".Z". "uncompress")
|
|
198 (".Y". "unyabba")
|
|
199 (".gz". "gunzip")
|
|
200 (".z". "gunzip")
|
|
201 ("". nil)))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
202 "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>
diff
changeset
|
203 Each entry should be (SUFFIX . STRING); the file is given to
|
6566
|
204 the command as standard input. If STRING is nil, no decoding is done.
|
|
205 Because the SUFFIXes are tried in order, the empty string should
|
|
206 be last in the list.")
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
207
|
13562
|
208 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
209 ;; First, on ms-dos, delete some of the extension in FILENAME
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
210 ;; to make room.
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
211 (defun info-insert-file-contents-1 (filename suffix)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
212 (if (not (eq system-type 'ms-dos))
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
213 (concat filename suffix)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
214 (let* ((sans-exts (file-name-sans-extension filename))
|
13562
|
215 ;; How long is the extension in FILENAME (not counting the dot).
|
|
216 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
|
|
217 ext-left)
|
13004
|
218 ;; SUFFIX starts with a dot. If FILENAME already has one,
|
14577
|
219 ;; get rid of the one in SUFFIX (unless suffix is empty).
|
13562
|
220 (or (and (<= ext-len 0)
|
13004
|
221 (not (eq (aref filename (1- (length filename))) ?.)))
|
14577
|
222 (= (length suffix) 0)
|
13004
|
223 (setq suffix (substring suffix 1)))
|
13562
|
224 ;; How many chars of that extension should we keep?
|
|
225 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
226 ;; Get rid of the rest of the extension, and add SUFFIX.
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
227 (concat (substring filename 0 (- (length filename)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
228 (- ext-len ext-left)))
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
229 suffix))))
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
230
|
22067
|
231 (defun info-file-exists-p (filename)
|
|
232 (and (file-exists-p filename)
|
|
233 (not (file-directory-p filename))))
|
|
234
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
235 (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>
diff
changeset
|
236 "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>
diff
changeset
|
237 Do the right thing if the file has been compressed or zipped."
|
6566
|
238 (let ((tail Info-suffix-list)
|
|
239 fullname decoder)
|
|
240 (if (file-exists-p filename)
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
241 ;; FILENAME exists--see if that name contains a suffix.
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
242 ;; If so, set DECODE accordingly.
|
6566
|
243 (progn
|
|
244 (while (and tail
|
|
245 (not (string-match
|
|
246 (concat (regexp-quote (car (car tail))) "$")
|
|
247 filename)))
|
|
248 (setq tail (cdr tail)))
|
|
249 (setq fullname filename
|
|
250 decoder (cdr (car tail))))
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
251 ;; Try adding suffixes to FILENAME and see if we can find something.
|
6566
|
252 (while (and tail
|
22067
|
253 (not (info-file-exists-p (info-insert-file-contents-1
|
|
254 filename (car (car tail))))))
|
6566
|
255 (setq tail (cdr tail)))
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
256 ;; If we found a file with a suffix, set DECODER according to the suffix
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
257 ;; and set FULLNAME to the file's actual name.
|
13004
|
258 (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
|
6566
|
259 decoder (cdr (car tail)))
|
|
260 (or tail
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
261 (error "Can't find %s or any compressed version of it" filename)))
|
9588
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
262 ;; check for conflict with jka-compr
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
263 (if (and (featurep 'jka-compr)
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
264 (jka-compr-installed-p)
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
265 (jka-compr-get-compression-info fullname))
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
266 (setq decoder nil))
|
6566
|
267 (if decoder
|
19937
|
268 (progn
|
|
269 (insert-file-contents-literally fullname visit)
|
|
270 (let ((buffer-read-only nil)
|
|
271 (coding-system-for-write 'no-conversion)
|
|
272 (default-directory (or (file-name-directory fullname)
|
|
273 default-directory)))
|
|
274 (call-process-region (point-min) (point-max) decoder t t)))
|
|
275 (insert-file-contents fullname visit))))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
276
|
22471
|
277 ;;;###autoload
|
|
278 (defun info-other-window (&optional file)
|
|
279 "Like `info' but show the Info buffer in another window."
|
|
280 (interactive (if current-prefix-arg
|
|
281 (list (read-file-name "Info file name: " nil nil t))))
|
|
282 (let (same-window-buffer-names)
|
|
283 (info file)))
|
|
284
|
10978
|
285 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
|
10957
|
286
|
|
287 ;;;###autoload
|
325
|
288 (defun info (&optional file)
|
|
289 "Enter Info, the documentation browser.
|
|
290 Optional argument FILE specifies the file to examine;
|
|
291 the default is the top-level directory of Info.
|
|
292
|
|
293 In interactive use, a prefix argument directs this command
|
14529
|
294 to read a file name from the minibuffer.
|
|
295
|
|
296 The search path for Info files is in the variable `Info-directory-list'.
|
|
297 The top-level Info directory is made by combining all the files named `dir'
|
|
298 in all the directories in that path."
|
325
|
299 (interactive (if current-prefix-arg
|
|
300 (list (read-file-name "Info file name: " nil nil t))))
|
|
301 (if file
|
23175
|
302 (progn
|
|
303 (pop-to-buffer "*info*")
|
|
304 ;; If argument already contains parentheses, don't add another set
|
|
305 ;; since the argument will then be parsed improperly. This also
|
|
306 ;; has the added benefit of allowing node names to be included
|
|
307 ;; following the parenthesized filename.
|
|
308 (if (and (stringp file) (string-match "(.*)" file))
|
|
309 (Info-goto-node file)
|
|
310 (Info-goto-node (concat "(" file ")"))))
|
21704
|
311 (if (get-buffer "*info*")
|
|
312 (pop-to-buffer "*info*")
|
|
313 (Info-directory))))
|
325
|
314
|
4410
|
315 ;;;###autoload
|
|
316 (defun info-standalone ()
|
|
317 "Run Emacs as a standalone Info reader.
|
|
318 Usage: emacs -f info-standalone [filename]
|
|
319 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
|
|
320 (setq Info-standalone t)
|
|
321 (if (and command-line-args-left
|
|
322 (not (string-match "^-" (car command-line-args-left))))
|
|
323 (condition-case err
|
|
324 (progn
|
|
325 (info (car command-line-args-left))
|
|
326 (setq command-line-args-left (cdr command-line-args-left)))
|
|
327 (error (send-string-to-terminal
|
|
328 (format "%s\n" (if (eq (car-safe err) 'error)
|
|
329 (nth 1 err) err)))
|
|
330 (save-buffers-kill-emacs)))
|
|
331 (info)))
|
|
332
|
325
|
333 ;; Go to an info node specified as separate filename and nodename.
|
|
334 ;; no-going-back is non-nil if recovering from an error in this function;
|
|
335 ;; it says do not attempt further (recursive) error recovery.
|
|
336 (defun Info-find-node (filename nodename &optional no-going-back)
|
|
337 ;; Convert filename to lower case if not found as specified.
|
|
338 ;; Expand it.
|
|
339 (if filename
|
|
340 (let (temp temp-downcase found)
|
22692
|
341 (setq filename (substitute-in-file-name filename))
|
|
342 (if (string= (downcase filename) "dir")
|
|
343 (setq found t)
|
|
344 (let ((dirs (if (string-match "^\\./" filename)
|
|
345 ;; If specified name starts with `./'
|
|
346 ;; then just try current directory.
|
|
347 '("./")
|
|
348 (if (file-name-absolute-p filename)
|
|
349 ;; No point in searching for an
|
|
350 ;; absolute file name
|
|
351 '(nil)
|
|
352 (if Info-additional-directory-list
|
|
353 (append Info-directory-list
|
|
354 Info-additional-directory-list)
|
|
355 Info-directory-list)))))
|
|
356 ;; Search the directory list for file FILENAME.
|
|
357 (while (and dirs (not found))
|
|
358 (setq temp (expand-file-name filename (car dirs)))
|
|
359 (setq temp-downcase
|
|
360 (expand-file-name (downcase filename) (car dirs)))
|
|
361 ;; Try several variants of specified name.
|
|
362 (let ((suffix-list Info-suffix-list))
|
|
363 (while (and suffix-list (not found))
|
|
364 (cond ((info-file-exists-p
|
|
365 (info-insert-file-contents-1
|
|
366 temp (car (car suffix-list))))
|
|
367 (setq found temp))
|
|
368 ((info-file-exists-p
|
|
369 (info-insert-file-contents-1
|
|
370 temp-downcase (car (car suffix-list))))
|
|
371 (setq found temp-downcase)))
|
|
372 (setq suffix-list (cdr suffix-list))))
|
|
373 (setq dirs (cdr dirs)))))
|
|
374 (if found
|
|
375 (setq filename found)
|
|
376 (error "Info file %s does not exist" filename))))
|
|
377 ;; Record the node we are leaving.
|
|
378 (if (and Info-current-file (not no-going-back))
|
|
379 (setq Info-history
|
|
380 (cons (list Info-current-file Info-current-node (point))
|
|
381 Info-history)))
|
21704
|
382 ;; Go into info buffer.
|
|
383 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
|
|
384 (buffer-disable-undo (current-buffer))
|
|
385 (or (eq major-mode 'Info-mode)
|
|
386 (Info-mode))
|
325
|
387 (widen)
|
|
388 (setq Info-current-node nil)
|
|
389 (unwind-protect
|
22951
|
390 ;; Bind case-fold-search in case the user sets it to nil.
|
|
391 (let ((case-fold-search t))
|
22692
|
392 ;; Switch files if necessary
|
|
393 (or (null filename)
|
|
394 (equal Info-current-file filename)
|
|
395 (let ((buffer-read-only nil))
|
|
396 (setq Info-current-file nil
|
|
397 Info-current-subfile nil
|
|
398 Info-current-file-completions nil
|
|
399 buffer-file-name nil)
|
|
400 (erase-buffer)
|
|
401 (if (eq filename t)
|
|
402 (Info-insert-dir)
|
|
403 (info-insert-file-contents filename t)
|
|
404 (setq default-directory (file-name-directory filename)))
|
|
405 (set-buffer-modified-p nil)
|
|
406 ;; See whether file has a tag table. Record the location if yes.
|
|
407 (goto-char (point-max))
|
|
408 (forward-line -8)
|
|
409 ;; Use string-equal, not equal, to ignore text props.
|
|
410 (if (not (or (string-equal nodename "*")
|
|
411 (not
|
|
412 (search-forward "\^_\nEnd tag table\n" nil t))))
|
|
413 (let (pos)
|
|
414 ;; We have a tag table. Find its beginning.
|
|
415 ;; Is this an indirect file?
|
|
416 (search-backward "\nTag table:\n")
|
|
417 (setq pos (point))
|
|
418 (if (save-excursion
|
|
419 (forward-line 2)
|
|
420 (looking-at "(Indirect)\n"))
|
|
421 ;; It is indirect. Copy it to another buffer
|
|
422 ;; and record that the tag table is in that buffer.
|
|
423 (let ((buf (current-buffer))
|
|
424 (tagbuf
|
|
425 (or Info-tag-table-buffer
|
|
426 (generate-new-buffer " *info tag table*"))))
|
|
427 (setq Info-tag-table-buffer tagbuf)
|
|
428 (save-excursion
|
|
429 (set-buffer tagbuf)
|
1484
|
430 (buffer-disable-undo (current-buffer))
|
22692
|
431 (setq case-fold-search t)
|
|
432 (erase-buffer)
|
|
433 (insert-buffer-substring buf))
|
|
434 (set-marker Info-tag-table-marker
|
|
435 (match-end 0) tagbuf))
|
|
436 (set-marker Info-tag-table-marker pos)))
|
|
437 (set-marker Info-tag-table-marker nil))
|
|
438 (setq Info-current-file
|
|
439 (if (eq filename t) "dir" filename))))
|
|
440 ;; Use string-equal, not equal, to ignore text props.
|
|
441 (if (string-equal nodename "*")
|
|
442 (progn (setq Info-current-node nodename)
|
|
443 (Info-set-mode-line))
|
|
444 ;; Possibilities:
|
|
445 ;;
|
|
446 ;; 1. Anchor found in tag table
|
|
447 ;; 2. Anchor *not* in tag table
|
|
448 ;;
|
|
449 ;; 3. Node found in tag table
|
|
450 ;; 4. Node *not* found in tag table, but found in file
|
|
451 ;; 5. Node *not* in tag table, and *not* in file
|
|
452 ;;
|
|
453 ;; *Or* the same, but in an indirect subfile.
|
|
454
|
|
455 ;; Search file for a suitable node.
|
|
456 (let ((guesspos (point-min))
|
|
457 (regexp
|
|
458 (concat "\\(Node:\\|Ref:\\) *"
|
|
459 (regexp-quote nodename)
|
|
460 " *[,\t\n\177]")))
|
|
461
|
|
462 ;; First, search a tag table, if any
|
|
463 (if (marker-position Info-tag-table-marker)
|
|
464
|
|
465 (let (found-in-tag-table
|
|
466 found-mode
|
|
467 (m Info-tag-table-marker))
|
|
468 (save-excursion
|
|
469 (set-buffer (marker-buffer m))
|
|
470 (goto-char m)
|
|
471 (beginning-of-line) ; so re-search will work.
|
|
472
|
|
473 ;; Search tag table
|
|
474 (setq found-in-tag-table
|
|
475 (re-search-forward regexp nil t))
|
|
476 (if found-in-tag-table
|
|
477 (setq guesspos (read (current-buffer))))
|
|
478 (setq found-mode major-mode))
|
|
479
|
|
480 ;; Indirect file among split files
|
|
481 (if found-in-tag-table
|
|
482 (progn
|
|
483 ;; If this is an indirect file, determine
|
|
484 ;; which file really holds this node and
|
|
485 ;; read it in.
|
|
486 (if (not (eq found-mode 'Info-mode))
|
|
487 ;; Note that the current buffer must be
|
|
488 ;; the *info* buffer on entry to
|
|
489 ;; Info-read-subfile. Thus the hackery
|
|
490 ;; above.
|
|
491 (setq guesspos (Info-read-subfile guesspos)))))
|
|
492
|
|
493 ;; Handle anchor
|
|
494 (if (and found-in-tag-table
|
|
495 (string-equal "Ref:" (match-string 1)))
|
|
496 (goto-char guesspos)
|
|
497
|
|
498 ;; Else we may have a node, which we search for:
|
22902
|
499 (goto-char (max (point-min)
|
|
500 (- (byte-to-position guesspos) 1000)))
|
22692
|
501 ;; Now search from our advised position
|
|
502 ;; (or from beg of buffer)
|
|
503 ;; to find the actual node.
|
|
504 (catch 'foo
|
|
505 (while (search-forward "\n\^_" nil t)
|
|
506 (forward-line 1)
|
|
507 (let ((beg (point)))
|
|
508 (forward-line 1)
|
|
509 (if (re-search-backward regexp beg t)
|
|
510 (progn
|
|
511 (beginning-of-line)
|
|
512 (throw 'foo t)))))
|
|
513 (error
|
|
514 "No such anchor in tag table or node in tag table or file: %s"
|
23416
|
515 nodename))))
|
|
516 (goto-char (max (point-min) (- guesspos 1000)))
|
|
517 ;; Now search from our advised position (or from beg of buffer)
|
|
518 ;; to find the actual node.
|
|
519 (catch 'foo
|
|
520 (while (search-forward "\n\^_" nil t)
|
|
521 (forward-line 1)
|
|
522 (let ((beg (point)))
|
|
523 (forward-line 1)
|
|
524 (if (re-search-backward regexp beg t)
|
|
525 (throw 'foo t))))
|
|
526 (error "No such node: %s" nodename))))
|
22863
|
527 (Info-select-node)
|
|
528 (goto-char (point-min))))
|
325
|
529 ;; If we did not finish finding the specified node,
|
|
530 ;; go back to the previous one.
|
6716
|
531 (or Info-current-node no-going-back (null Info-history)
|
22692
|
532 (let ((hist (car Info-history)))
|
|
533 (setq Info-history (cdr Info-history))
|
|
534 (Info-find-node (nth 0 hist) (nth 1 hist) t)
|
|
535 (goto-char (nth 2 hist))))))
|
325
|
536
|
1979
|
537 ;; Cache the contents of the (virtual) dir file, once we have merged
|
|
538 ;; it for the first time, so we can save time subsequently.
|
1971
|
539 (defvar Info-dir-contents nil)
|
|
540
|
1979
|
541 ;; Cache for the directory we decided to use for the default-directory
|
|
542 ;; of the merged dir text.
|
|
543 (defvar Info-dir-contents-directory nil)
|
|
544
|
3836
|
545 ;; Record the file attributes of all the files from which we
|
|
546 ;; constructed Info-dir-contents.
|
|
547 (defvar Info-dir-file-attributes nil)
|
|
548
|
23416
|
549 (defvar Info-dir-file-name nil)
|
|
550
|
1971
|
551 ;; Construct the Info directory node by merging the files named `dir'
|
1979
|
552 ;; from various directories. Set the *info* buffer's
|
|
553 ;; default-directory to the first directory we actually get any text
|
|
554 ;; from.
|
1971
|
555 (defun Info-insert-dir ()
|
3836
|
556 (if (and Info-dir-contents Info-dir-file-attributes
|
|
557 ;; Verify that none of the files we used has changed
|
|
558 ;; since we used it.
|
|
559 (eval (cons 'and
|
|
560 (mapcar '(lambda (elt)
|
7911
|
561 (let ((curr (file-attributes (car elt))))
|
|
562 ;; Don't compare the access time.
|
|
563 (if curr (setcar (nthcdr 4 curr) 0))
|
|
564 (setcar (nthcdr 4 (cdr elt)) 0)
|
|
565 (equal (cdr elt) curr)))
|
3836
|
566 Info-dir-file-attributes))))
|
23416
|
567 (progn
|
|
568 (insert Info-dir-contents)
|
|
569 (goto-char (point-min)))
|
1971
|
570 (let ((dirs Info-directory-list)
|
22951
|
571 ;; Bind this in case the user sets it to nil.
|
|
572 (case-fold-search t)
|
23416
|
573 ;; This is set non-nil if we find a problem in some input files.
|
|
574 problems
|
3212
|
575 buffers buffer others nodes dirs-done)
|
1979
|
576
|
7911
|
577 (setq Info-dir-file-attributes nil)
|
|
578
|
1979
|
579 ;; Search the directory list for the directory file.
|
1971
|
580 (while dirs
|
5271
|
581 (let ((truename (file-truename (expand-file-name (car dirs)))))
|
|
582 (or (member truename dirs-done)
|
|
583 (member (directory-file-name truename) dirs-done)
|
|
584 ;; Try several variants of specified name.
|
|
585 ;; Try upcasing, appending `.info', or both.
|
7911
|
586 (let* (file
|
|
587 (attrs
|
|
588 (or
|
|
589 (progn (setq file (expand-file-name "dir" truename))
|
|
590 (file-attributes file))
|
|
591 (progn (setq file (expand-file-name "DIR" truename))
|
|
592 (file-attributes file))
|
|
593 (progn (setq file (expand-file-name "dir.info" truename))
|
|
594 (file-attributes file))
|
|
595 (progn (setq file (expand-file-name "DIR.INFO" truename))
|
|
596 (file-attributes file)))))
|
5271
|
597 (setq dirs-done
|
|
598 (cons truename
|
|
599 (cons (directory-file-name truename)
|
|
600 dirs-done)))
|
7911
|
601 (if attrs
|
|
602 (save-excursion
|
|
603 (or buffers
|
|
604 (message "Composing main Info directory..."))
|
20421
|
605 (set-buffer (generate-new-buffer " info dir"))
|
22863
|
606 (condition-case nil
|
|
607 (progn
|
|
608 (insert-file-contents file)
|
23416
|
609 (make-local-variable 'Info-dir-file-name)
|
|
610 (setq Info-dir-file-name file)
|
22863
|
611 (setq buffers (cons (current-buffer) buffers)
|
|
612 Info-dir-file-attributes
|
|
613 (cons (cons file attrs)
|
|
614 Info-dir-file-attributes)))
|
|
615 (error (kill-buffer (current-buffer))))))))
|
16462
|
616 (or (cdr dirs) (setq Info-dir-contents-directory
|
|
617 (file-name-as-directory (car dirs))))
|
7911
|
618 (setq dirs (cdr dirs))))
|
|
619
|
6716
|
620 (or buffers
|
14664
|
621 (error "Can't find the Info directory node"))
|
1979
|
622 ;; Distinguish the dir file that comes with Emacs from all the
|
3212
|
623 ;; others. Yes, that is really what this is supposed to do.
|
|
624 ;; If it doesn't work, fix it.
|
1971
|
625 (setq buffer (car buffers)
|
|
626 others (cdr buffers))
|
1979
|
627
|
15304
|
628 ;; Insert the entire original dir file as a start; note that we've
|
|
629 ;; already saved its default directory to use as the default
|
|
630 ;; directory for the whole concatenation.
|
1971
|
631 (insert-buffer buffer)
|
1979
|
632
|
1971
|
633 ;; Look at each of the other buffers one by one.
|
|
634 (while others
|
23416
|
635 (let ((other (car others))
|
|
636 this-buffer-nodes)
|
1971
|
637 ;; In each, find all the menus.
|
|
638 (save-excursion
|
|
639 (set-buffer other)
|
|
640 (goto-char (point-min))
|
|
641 ;; Find each menu, and add an elt to NODES for it.
|
|
642 (while (re-search-forward "^\\* Menu:" nil t)
|
|
643 (let (beg nodename end)
|
|
644 (forward-line 1)
|
|
645 (setq beg (point))
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
646 (search-backward "\n\^_")
|
1971
|
647 (search-forward "Node: ")
|
|
648 (setq nodename (Info-following-node-name))
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
649 (search-forward "\n\^_" nil 'move)
|
1971
|
650 (beginning-of-line)
|
|
651 (setq end (point))
|
23416
|
652 (setq this-buffer-nodes
|
|
653 (cons (list nodename other beg end)
|
|
654 this-buffer-nodes))))
|
|
655 (if (assoc-ignore-case "top" this-buffer-nodes)
|
|
656 (setq nodes (nconc this-buffer-nodes nodes))
|
|
657 (setq problems t)
|
|
658 (message "No `top' node in %s" Info-dir-file-name))))
|
1971
|
659 (setq others (cdr others)))
|
|
660 ;; Add to the main menu a menu item for each other node.
|
|
661 (re-search-forward "^\\* Menu:")
|
|
662 (forward-line 1)
|
|
663 (let ((menu-items '("top"))
|
|
664 (nodes nodes)
|
|
665 (case-fold-search t)
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
666 (end (save-excursion (search-forward "\^_" nil t) (point))))
|
1971
|
667 (while nodes
|
|
668 (let ((nodename (car (car nodes))))
|
6537
|
669 (save-excursion
|
|
670 (or (member (downcase nodename) menu-items)
|
21641
|
671 (re-search-forward (concat "^\\* +"
|
6537
|
672 (regexp-quote nodename)
|
|
673 "::")
|
|
674 end t)
|
|
675 (progn
|
|
676 (insert "* " nodename "::" "\n")
|
|
677 (setq menu-items (cons nodename menu-items))))))
|
1971
|
678 (setq nodes (cdr nodes))))
|
|
679 ;; Now take each node of each of the other buffers
|
|
680 ;; and merge it into the main buffer.
|
|
681 (while nodes
|
|
682 (let ((nodename (car (car nodes))))
|
|
683 (goto-char (point-min))
|
|
684 ;; Find the like-named node in the main buffer.
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
685 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
|
1971
|
686 (regexp-quote nodename)
|
|
687 "[,\n\t]")
|
|
688 nil t)
|
|
689 (progn
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
690 (search-forward "\n\^_" nil 'move)
|
8913
|
691 (beginning-of-line)
|
|
692 (insert "\n"))
|
1971
|
693 ;; If none exists, add one.
|
|
694 (goto-char (point-max))
|
8069
|
695 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
|
1971
|
696 ;; Merge the text from the other buffer's menu
|
|
697 ;; into the menu in the like-named node in the main buffer.
|
8913
|
698 (apply 'insert-buffer-substring (cdr (car nodes))))
|
1971
|
699 (setq nodes (cdr nodes)))
|
|
700 ;; Kill all the buffers we just made.
|
|
701 (while buffers
|
|
702 (kill-buffer (car buffers))
|
7911
|
703 (setq buffers (cdr buffers)))
|
23416
|
704 (goto-char (point-min))
|
|
705 (if problems
|
|
706 (message "Composing main Info directory...problems encountered, see `*Messages*'")
|
|
707 (message "Composing main Info directory...done")))
|
1979
|
708 (setq Info-dir-contents (buffer-string)))
|
|
709 (setq default-directory Info-dir-contents-directory))
|
1971
|
710
|
16981
|
711 ;; Note that on entry to this function the current-buffer must be the
|
|
712 ;; *info* buffer; not the info tags buffer.
|
325
|
713 (defun Info-read-subfile (nodepos)
|
16399
|
714 ;; NODEPOS is either a position (in the Info file as a whole,
|
|
715 ;; not relative to a subfile) or the name of a subfile.
|
325
|
716 (let (lastfilepos
|
|
717 lastfilename)
|
16399
|
718 (if (numberp nodepos)
|
|
719 (save-excursion
|
|
720 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
721 (goto-char (point-min))
|
|
722 (search-forward "\n\^_")
|
|
723 (forward-line 2)
|
|
724 (catch 'foo
|
|
725 (while (not (looking-at "\^_"))
|
|
726 (if (not (eolp))
|
|
727 (let ((beg (point))
|
|
728 thisfilepos thisfilename)
|
|
729 (search-forward ": ")
|
|
730 (setq thisfilename (buffer-substring beg (- (point) 2)))
|
|
731 (setq thisfilepos (read (current-buffer)))
|
|
732 ;; read in version 19 stops at the end of number.
|
|
733 ;; Advance to the next line.
|
|
734 (forward-line 1)
|
|
735 (if (> thisfilepos nodepos)
|
|
736 (throw 'foo t))
|
|
737 (setq lastfilename thisfilename)
|
|
738 (setq lastfilepos thisfilepos))
|
|
739 (forward-line 1)))))
|
|
740 (setq lastfilename nodepos)
|
|
741 (setq lastfilepos 0))
|
16981
|
742 ;; Assume previous buffer is in Info-mode.
|
|
743 ;; (set-buffer (get-buffer "*info*"))
|
325
|
744 (or (equal Info-current-subfile lastfilename)
|
|
745 (let ((buffer-read-only nil))
|
|
746 (setq buffer-file-name nil)
|
|
747 (widen)
|
|
748 (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>
diff
changeset
|
749 (info-insert-file-contents lastfilename)
|
325
|
750 (set-buffer-modified-p nil)
|
|
751 (setq Info-current-subfile lastfilename)))
|
|
752 (goto-char (point-min))
|
|
753 (search-forward "\n\^_")
|
16399
|
754 (if (numberp nodepos)
|
|
755 (+ (- nodepos lastfilepos) (point)))))
|
325
|
756
|
|
757 ;; Select the info node that point is in.
|
|
758 (defun Info-select-node ()
|
22951
|
759 ;; Bind this in case the user sets it to nil.
|
|
760 (let ((case-fold-search t))
|
|
761 (save-excursion
|
|
762 ;; Find beginning of node.
|
|
763 (search-backward "\n\^_")
|
|
764 (forward-line 2)
|
|
765 ;; Get nodename spelled as it is in the node.
|
|
766 (re-search-forward "Node:[ \t]*")
|
|
767 (setq Info-current-node
|
|
768 (buffer-substring-no-properties (point)
|
|
769 (progn
|
|
770 (skip-chars-forward "^,\t\n")
|
|
771 (point))))
|
|
772 (Info-set-mode-line)
|
|
773 ;; Find the end of it, and narrow.
|
|
774 (beginning-of-line)
|
|
775 (let (active-expression)
|
|
776 (narrow-to-region (point)
|
|
777 (if (re-search-forward "\n[\^_\f]" nil t)
|
|
778 (prog1
|
|
779 (1- (point))
|
|
780 (if (looking-at "[\n\^_\f]*execute: ")
|
|
781 (progn
|
|
782 (goto-char (match-end 0))
|
|
783 (setq active-expression
|
|
784 (read (current-buffer))))))
|
|
785 (point-max)))
|
|
786 (if Info-enable-active-nodes (eval active-expression))
|
|
787 (if Info-fontify (Info-fontify-node))
|
|
788 (run-hooks 'Info-selection-hook)))))
|
325
|
789
|
|
790 (defun Info-set-mode-line ()
|
|
791 (setq mode-line-buffer-identification
|
|
792 (concat
|
17859
|
793 " Info: ("
|
325
|
794 (if Info-current-file
|
|
795 (file-name-nondirectory Info-current-file)
|
|
796 "")
|
|
797 ")"
|
|
798 (or Info-current-node ""))))
|
|
799
|
|
800 ;; Go to an info node specified with a filename-and-nodename string
|
|
801 ;; of the sort that is found in pointers in nodes.
|
|
802
|
|
803 (defun Info-goto-node (nodename)
|
|
804 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME."
|
4410
|
805 (interactive (list (Info-read-node-name "Goto node: ")))
|
325
|
806 (let (filename)
|
|
807 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
|
|
808 nodename)
|
|
809 (setq filename (if (= (match-beginning 1) (match-end 1))
|
|
810 ""
|
|
811 (substring nodename (match-beginning 2) (match-end 2)))
|
|
812 nodename (substring nodename (match-beginning 3) (match-end 3)))
|
|
813 (let ((trim (string-match "\\s *\\'" filename)))
|
|
814 (if trim (setq filename (substring filename 0 trim))))
|
|
815 (let ((trim (string-match "\\s *\\'" nodename)))
|
|
816 (if trim (setq nodename (substring nodename 0 trim))))
|
12433
|
817 (if transient-mark-mode (deactivate-mark))
|
325
|
818 (Info-find-node (if (equal filename "") nil filename)
|
|
819 (if (equal nodename "") "Top" nodename))))
|
4410
|
820
|
22760
|
821 (defvar Info-read-node-completion-table)
|
|
822
|
12779
|
823 ;; This function is used as the "completion table" while reading a node name.
|
22760
|
824 ;; It does completion using the alist in Info-read-node-completion-table
|
12779
|
825 ;; unless STRING starts with an open-paren.
|
|
826 (defun Info-read-node-name-1 (string predicate code)
|
|
827 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
|
|
828 (cond ((eq code nil)
|
|
829 (if no-completion
|
|
830 string
|
22760
|
831 (try-completion string Info-read-node-completion-table predicate)))
|
12779
|
832 ((eq code t)
|
|
833 (if no-completion
|
|
834 nil
|
22760
|
835 (all-completions string Info-read-node-completion-table predicate)))
|
12779
|
836 ((eq code 'lambda)
|
|
837 (if no-completion
|
|
838 t
|
22760
|
839 (assoc string Info-read-node-completion-table))))))
|
12779
|
840
|
4410
|
841 (defun Info-read-node-name (prompt &optional default)
|
|
842 (let* ((completion-ignore-case t)
|
22760
|
843 (Info-read-node-completion-table (Info-build-node-completions))
|
17140
|
844 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
|
4410
|
845 (if (equal nodename "")
|
|
846 (or default
|
|
847 (Info-read-node-name prompt))
|
|
848 nodename)))
|
|
849
|
|
850 (defun Info-build-node-completions ()
|
|
851 (or Info-current-file-completions
|
22951
|
852 (let ((compl nil)
|
|
853 ;; Bind this in case the user sets it to nil.
|
|
854 (case-fold-search t))
|
4410
|
855 (save-excursion
|
|
856 (save-restriction
|
|
857 (if (marker-buffer Info-tag-table-marker)
|
16981
|
858 (let ((marker Info-tag-table-marker))
|
|
859 (set-buffer (marker-buffer marker))
|
6049
|
860 (widen)
|
16981
|
861 (goto-char marker)
|
4410
|
862 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
|
|
863 (setq compl
|
|
864 (cons (list (buffer-substring (match-beginning 1)
|
|
865 (match-end 1)))
|
|
866 compl))))
|
|
867 (widen)
|
|
868 (goto-char (point-min))
|
|
869 (while (search-forward "\n\^_" nil t)
|
|
870 (forward-line 1)
|
|
871 (let ((beg (point)))
|
|
872 (forward-line 1)
|
|
873 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
|
|
874 beg t)
|
|
875 (setq compl
|
|
876 (cons (list (buffer-substring (match-beginning 1)
|
|
877 (match-end 1)))
|
|
878 compl))))))))
|
|
879 (setq Info-current-file-completions compl))))
|
325
|
880
|
540
|
881 (defun Info-restore-point (hl)
|
|
882 "If this node has been visited, restore the point value when we left."
|
6049
|
883 (while hl
|
|
884 (if (and (equal (nth 0 (car hl)) Info-current-file)
|
11527
|
885 ;; Use string-equal, not equal, to ignore text props.
|
|
886 (string-equal (nth 1 (car hl)) Info-current-node))
|
6049
|
887 (progn
|
6121
|
888 (goto-char (nth 2 (car hl)))
|
|
889 (setq hl nil)) ;terminate the while at next iter
|
6049
|
890 (setq hl (cdr hl)))))
|
540
|
891
|
325
|
892 (defvar Info-last-search nil
|
3084
|
893 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
|
325
|
894
|
|
895 (defun Info-search (regexp)
|
|
896 "Search for REGEXP, starting from point, and select node it's found in."
|
|
897 (interactive "sSearch (regexp): ")
|
12433
|
898 (if transient-mark-mode (deactivate-mark))
|
325
|
899 (if (equal regexp "")
|
|
900 (setq regexp Info-last-search)
|
|
901 (setq Info-last-search regexp))
|
|
902 (let ((found ()) current
|
|
903 (onode Info-current-node)
|
|
904 (ofile Info-current-file)
|
|
905 (opoint (point))
|
16399
|
906 (ostart (window-start))
|
325
|
907 (osubfile Info-current-subfile))
|
|
908 (save-excursion
|
|
909 (save-restriction
|
|
910 (widen)
|
|
911 (if (null Info-current-subfile)
|
|
912 (progn (re-search-forward regexp) (setq found (point)))
|
|
913 (condition-case err
|
|
914 (progn (re-search-forward regexp) (setq found (point)))
|
|
915 (search-failed nil)))))
|
|
916 (if (not found) ;can only happen in subfile case -- else would have erred
|
|
917 (unwind-protect
|
|
918 (let ((list ()))
|
16981
|
919 (save-excursion
|
|
920 (set-buffer (marker-buffer Info-tag-table-marker))
|
325
|
921 (goto-char (point-min))
|
16981
|
922 (search-forward "\n\^_\nIndirect:")
|
|
923 (save-restriction
|
|
924 (narrow-to-region (point)
|
|
925 (progn (search-forward "\n\^_")
|
|
926 (1- (point))))
|
|
927 (goto-char (point-min))
|
|
928 (search-forward (concat "\n" osubfile ": "))
|
|
929 (beginning-of-line)
|
|
930 (while (not (eobp))
|
|
931 (re-search-forward "\\(^.*\\): [0-9]+$")
|
|
932 (goto-char (+ (match-end 1) 2))
|
|
933 (setq list (cons (cons (read (current-buffer))
|
|
934 (buffer-substring
|
|
935 (match-beginning 1) (match-end 1)))
|
|
936 list))
|
|
937 (goto-char (1+ (match-end 0))))
|
|
938 (setq list (nreverse list)
|
|
939 current (car (car list))
|
|
940 list (cdr list))))
|
325
|
941 (while list
|
|
942 (message "Searching subfile %s..." (cdr (car list)))
|
|
943 (Info-read-subfile (car (car list)))
|
|
944 (setq list (cdr list))
|
8069
|
945 ;; (goto-char (point-min))
|
325
|
946 (if (re-search-forward regexp nil t)
|
|
947 (setq found (point) list ())))
|
|
948 (if found
|
|
949 (message "")
|
|
950 (signal 'search-failed (list regexp))))
|
|
951 (if (not found)
|
16399
|
952 (progn (Info-read-subfile osubfile)
|
325
|
953 (goto-char opoint)
|
16399
|
954 (Info-select-node)
|
|
955 (set-window-start (selected-window) ostart)))))
|
325
|
956 (widen)
|
|
957 (goto-char found)
|
|
958 (Info-select-node)
|
11527
|
959 ;; Use string-equal, not equal, to ignore text props.
|
|
960 (or (and (string-equal onode Info-current-node)
|
325
|
961 (equal ofile Info-current-file))
|
|
962 (setq Info-history (cons (list ofile onode opoint)
|
|
963 Info-history)))))
|
|
964
|
|
965 ;; Extract the value of the node-pointer named NAME.
|
|
966 ;; If there is none, use ERRORNAME in the error message;
|
|
967 ;; if ERRORNAME is nil, just return nil.
|
|
968 (defun Info-extract-pointer (name &optional errorname)
|
22951
|
969 ;; Bind this in case the user sets it to nil.
|
|
970 (let ((case-fold-search t))
|
|
971 (save-excursion
|
|
972 (goto-char (point-min))
|
|
973 (forward-line 1)
|
|
974 (if (re-search-backward (concat name ":") nil t)
|
|
975 (progn
|
|
976 (goto-char (match-end 0))
|
|
977 (Info-following-node-name))
|
|
978 (if (eq errorname t)
|
|
979 nil
|
|
980 (error "Node has no %s" (capitalize (or errorname name))))))))
|
325
|
981
|
1971
|
982 ;; Return the node name in the buffer following point.
|
|
983 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
|
16981
|
984 ;; saying which chars may appear in the node name.
|
325
|
985 (defun Info-following-node-name (&optional allowedchars)
|
|
986 (skip-chars-forward " \t")
|
13287
|
987 (buffer-substring-no-properties
|
325
|
988 (point)
|
|
989 (progn
|
|
990 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
|
|
991 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
|
|
992 (if (looking-at "(")
|
|
993 (skip-chars-forward "^)")))
|
|
994 (skip-chars-backward " ")
|
|
995 (point))))
|
|
996
|
|
997 (defun Info-next ()
|
|
998 "Go to the next node of this node."
|
|
999 (interactive)
|
|
1000 (Info-goto-node (Info-extract-pointer "next")))
|
|
1001
|
|
1002 (defun Info-prev ()
|
|
1003 "Go to the previous node of this node."
|
|
1004 (interactive)
|
|
1005 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
|
|
1006
|
21910
|
1007 (defun Info-up (&optional same-file)
|
|
1008 "Go to the superior node of this node.
|
|
1009 If SAME-FILE is non-nil, do not move to a different Info file."
|
325
|
1010 (interactive)
|
21910
|
1011 (let ((node (Info-extract-pointer "up")))
|
|
1012 (and same-file
|
|
1013 (string-match "^(" node)
|
|
1014 (error "Up node is in another Info file"))
|
|
1015 (Info-goto-node node))
|
540
|
1016 (Info-restore-point Info-history))
|
325
|
1017
|
|
1018 (defun Info-last ()
|
|
1019 "Go back to the last node visited."
|
|
1020 (interactive)
|
|
1021 (or Info-history
|
|
1022 (error "This is the first Info node you looked at"))
|
|
1023 (let (filename nodename opoint)
|
|
1024 (setq filename (car (car Info-history)))
|
|
1025 (setq nodename (car (cdr (car Info-history))))
|
|
1026 (setq opoint (car (cdr (cdr (car Info-history)))))
|
|
1027 (setq Info-history (cdr Info-history))
|
|
1028 (Info-find-node filename nodename)
|
|
1029 (setq Info-history (cdr Info-history))
|
|
1030 (goto-char opoint)))
|
|
1031
|
|
1032 (defun Info-directory ()
|
|
1033 "Go to the Info directory node."
|
|
1034 (interactive)
|
|
1035 (Info-find-node "dir" "top"))
|
|
1036
|
|
1037 (defun Info-follow-reference (footnotename)
|
|
1038 "Follow cross reference named NAME to the node it refers to.
|
|
1039 NAME may be an abbreviation of the reference name."
|
|
1040 (interactive
|
|
1041 (let ((completion-ignore-case t)
|
22951
|
1042 (case-fold-search t)
|
5555
|
1043 completions default alt-default (start-point (point)) str i bol eol)
|
325
|
1044 (save-excursion
|
5555
|
1045 ;; Store end and beginning of line.
|
|
1046 (end-of-line)
|
|
1047 (setq eol (point))
|
|
1048 (beginning-of-line)
|
|
1049 (setq bol (point))
|
|
1050
|
325
|
1051 (goto-char (point-min))
|
|
1052 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
|
|
1053 (setq str (buffer-substring
|
|
1054 (match-beginning 1)
|
|
1055 (1- (point))))
|
|
1056 ;; See if this one should be the default.
|
|
1057 (and (null default)
|
5146
aa2236a14893
(Info-follow-reference): Correct one-off error in comparing start-point.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1058 (<= (match-beginning 0) start-point)
|
325
|
1059 (<= start-point (point))
|
|
1060 (setq default t))
|
5555
|
1061 ;; See if this one should be the alternate default.
|
|
1062 (and (null alt-default)
|
|
1063 (and (<= bol (match-beginning 0))
|
|
1064 (<= (point) eol))
|
|
1065 (setq alt-default t))
|
325
|
1066 (setq i 0)
|
|
1067 (while (setq i (string-match "[ \n\t]+" str i))
|
|
1068 (setq str (concat (substring str 0 i) " "
|
|
1069 (substring str (match-end 0))))
|
|
1070 (setq i (1+ i)))
|
|
1071 ;; Record as a completion and perhaps as default.
|
|
1072 (if (eq default t) (setq default str))
|
5555
|
1073 (if (eq alt-default t) (setq alt-default str))
|
16609
|
1074 ;; Don't add this string if it's a duplicate.
|
|
1075 ;; We use a loop instead of "(assoc str completions)" because
|
|
1076 ;; we want to do a case-insensitive compare.
|
|
1077 (let ((tail completions)
|
|
1078 (tem (downcase str)))
|
|
1079 (while (and tail
|
|
1080 (not (string-equal tem (downcase (car (car tail))))))
|
|
1081 (setq tail (cdr tail)))
|
|
1082 (or tail
|
|
1083 (setq completions
|
|
1084 (cons (cons str nil)
|
|
1085 completions))))))
|
5555
|
1086 ;; If no good default was found, try an alternate.
|
|
1087 (or default
|
|
1088 (setq default alt-default))
|
|
1089 ;; If only one cross-reference found, then make it default.
|
|
1090 (if (eq (length completions) 1)
|
|
1091 (setq default (car (car completions))))
|
325
|
1092 (if completions
|
3565
|
1093 (let ((input (completing-read (if default
|
|
1094 (concat "Follow reference named: ("
|
|
1095 default ") ")
|
|
1096 "Follow reference named: ")
|
|
1097 completions nil t)))
|
|
1098 (list (if (equal input "")
|
|
1099 default input)))
|
325
|
1100 (error "No cross-references in this node"))))
|
23038
|
1101
|
|
1102 (unless footnotename
|
|
1103 (error "No reference was specified"))
|
|
1104
|
22951
|
1105 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))
|
|
1106 (case-fold-search t))
|
325
|
1107 (while (setq i (string-match " " str i))
|
|
1108 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
|
|
1109 (setq i (+ i 6)))
|
|
1110 (save-excursion
|
|
1111 (goto-char (point-min))
|
|
1112 (or (re-search-forward str nil t)
|
|
1113 (error "No cross-reference named %s" footnotename))
|
|
1114 (goto-char (+ (match-beginning 0) 5))
|
|
1115 (setq target
|
|
1116 (Info-extract-menu-node-name "Bad format cross reference" t)))
|
|
1117 (while (setq i (string-match "[ \t\n]+" target i))
|
|
1118 (setq target (concat (substring target 0 i) " "
|
|
1119 (substring target (match-end 0))))
|
|
1120 (setq i (+ i 1)))
|
|
1121 (Info-goto-node target)))
|
|
1122
|
|
1123 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
|
|
1124 (skip-chars-forward " \t\n")
|
|
1125 (let ((beg (point))
|
|
1126 str i)
|
|
1127 (skip-chars-forward "^:")
|
|
1128 (forward-char 1)
|
|
1129 (setq str
|
|
1130 (if (looking-at ":")
|
13287
|
1131 (buffer-substring-no-properties beg (1- (point)))
|
325
|
1132 (skip-chars-forward " \t\n")
|
|
1133 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
|
|
1134 (while (setq i (string-match "\n" str i))
|
|
1135 (aset str i ?\ ))
|
10918
|
1136 ;; Collapse multiple spaces.
|
|
1137 (while (string-match " +" str)
|
|
1138 (setq str (replace-match " " t t str)))
|
325
|
1139 str))
|
|
1140
|
7837
|
1141 ;; No one calls this.
|
1484
|
1142 ;;(defun Info-menu-item-sequence (list)
|
|
1143 ;; (while list
|
7837
|
1144 ;; (Info-menu (car list))
|
1484
|
1145 ;; (setq list (cdr list))))
|
325
|
1146
|
22761
|
1147 (defvar Info-complete-menu-buffer)
|
|
1148
|
7837
|
1149 (defun Info-complete-menu-item (string predicate action)
|
|
1150 (let ((case-fold-search t))
|
|
1151 (cond ((eq action nil)
|
|
1152 (let (completions
|
21641
|
1153 (pattern (concat "\n\\* +\\("
|
7837
|
1154 (regexp-quote string)
|
|
1155 "[^:\t\n]*\\):")))
|
|
1156 (save-excursion
|
|
1157 (set-buffer Info-complete-menu-buffer)
|
|
1158 (goto-char (point-min))
|
13566
1121cd08e87f
(Info-complete-menu-item): Don't treat `* Menu:' as a menu item.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1159 (search-forward "\n* Menu:")
|
7837
|
1160 (while (re-search-forward pattern nil t)
|
|
1161 (setq completions (cons (cons (format "%s"
|
|
1162 (buffer-substring
|
|
1163 (match-beginning 1)
|
|
1164 (match-end 1)))
|
|
1165 (match-beginning 1))
|
|
1166 completions))))
|
|
1167 (try-completion string completions predicate)))
|
|
1168 ((eq action t)
|
|
1169 (let (completions
|
21641
|
1170 (pattern (concat "\n\\* +\\("
|
7837
|
1171 (regexp-quote string)
|
|
1172 "[^:\t\n]*\\):")))
|
|
1173 (save-excursion
|
|
1174 (set-buffer Info-complete-menu-buffer)
|
|
1175 (goto-char (point-min))
|
13566
1121cd08e87f
(Info-complete-menu-item): Don't treat `* Menu:' as a menu item.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1176 (search-forward "\n* Menu:")
|
7837
|
1177 (while (re-search-forward pattern nil t)
|
|
1178 (setq completions (cons (cons (format "%s"
|
|
1179 (buffer-substring
|
|
1180 (match-beginning 1)
|
|
1181 (match-end 1)))
|
|
1182 (match-beginning 1))
|
|
1183 completions))))
|
|
1184 (all-completions string completions predicate)))
|
|
1185 (t
|
|
1186 (save-excursion
|
|
1187 (set-buffer Info-complete-menu-buffer)
|
|
1188 (goto-char (point-min))
|
13566
1121cd08e87f
(Info-complete-menu-item): Don't treat `* Menu:' as a menu item.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1189 (search-forward "\n* Menu:")
|
21641
|
1190 (re-search-forward (concat "\n\\* +"
|
7837
|
1191 (regexp-quote string)
|
|
1192 ":")
|
|
1193 nil t))))))
|
|
1194
|
|
1195
|
325
|
1196 (defun Info-menu (menu-item)
|
|
1197 "Go to node for menu item named (or abbreviated) NAME.
|
|
1198 Completion is allowed, and the menu item point is on is the default."
|
|
1199 (interactive
|
|
1200 (let ((completions '())
|
|
1201 ;; If point is within a menu item, use that item as the default
|
|
1202 (default nil)
|
|
1203 (p (point))
|
10957
|
1204 beg
|
325
|
1205 (last nil))
|
|
1206 (save-excursion
|
|
1207 (goto-char (point-min))
|
|
1208 (if (not (search-forward "\n* menu:" nil t))
|
|
1209 (error "No menu in this node"))
|
7837
|
1210 (setq beg (point))
|
|
1211 (and (< (point) p)
|
|
1212 (save-excursion
|
|
1213 (goto-char p)
|
|
1214 (end-of-line)
|
21641
|
1215 (re-search-backward "\n\\* +\\([^:\t\n]*\\):" beg t)
|
7837
|
1216 (setq default (format "%s" (buffer-substring
|
|
1217 (match-beginning 1)
|
|
1218 (match-end 1)))))))
|
325
|
1219 (let ((item nil))
|
|
1220 (while (null item)
|
7837
|
1221 (setq item (let ((completion-ignore-case t)
|
|
1222 (Info-complete-menu-buffer (current-buffer)))
|
325
|
1223 (completing-read (if default
|
|
1224 (format "Menu item (default %s): "
|
|
1225 default)
|
|
1226 "Menu item: ")
|
7837
|
1227 'Info-complete-menu-item nil t)))
|
540
|
1228 ;; we rely on the fact that completing-read accepts an input
|
|
1229 ;; of "" even when the require-match argument is true and ""
|
|
1230 ;; is not a valid possibility
|
325
|
1231 (if (string= item "")
|
|
1232 (if default
|
|
1233 (setq item default)
|
|
1234 ;; ask again
|
|
1235 (setq item nil))))
|
|
1236 (list item))))
|
|
1237 ;; there is a problem here in that if several menu items have the same
|
|
1238 ;; name you can only go to the node of the first with this command.
|
|
1239 (Info-goto-node (Info-extract-menu-item menu-item)))
|
|
1240
|
|
1241 (defun Info-extract-menu-item (menu-item)
|
|
1242 (setq menu-item (regexp-quote menu-item))
|
22951
|
1243 (let ((case-fold-search t))
|
|
1244 (save-excursion
|
|
1245 (goto-char (point-min))
|
|
1246 (or (search-forward "\n* menu:" nil t)
|
|
1247 (error "No menu in this node"))
|
|
1248 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
|
|
1249 (re-search-forward (concat "\n\\* +" menu-item) nil t)
|
|
1250 (error "No such item in menu"))
|
|
1251 (beginning-of-line)
|
|
1252 (forward-char 2)
|
|
1253 (Info-extract-menu-node-name))))
|
325
|
1254
|
|
1255 ;; If COUNT is nil, use the last item in the menu.
|
|
1256 (defun Info-extract-menu-counting (count)
|
22951
|
1257 (let ((case-fold-search t))
|
|
1258 (save-excursion
|
|
1259 (goto-char (point-min))
|
|
1260 (or (search-forward "\n* menu:" nil t)
|
|
1261 (error "No menu in this node"))
|
|
1262 (if count
|
|
1263 (or (search-forward "\n* " nil t count)
|
|
1264 (error "Too few items in menu"))
|
|
1265 (while (search-forward "\n* " nil t)
|
|
1266 nil))
|
|
1267 (Info-extract-menu-node-name))))
|
325
|
1268
|
1666
|
1269 (defun Info-nth-menu-item ()
|
|
1270 "Go to the node of the Nth menu item.
|
|
1271 N is the digit argument used to invoke this command."
|
325
|
1272 (interactive)
|
1666
|
1273 (Info-goto-node
|
|
1274 (Info-extract-menu-counting
|
|
1275 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
|
325
|
1276
|
|
1277 (defun Info-top-node ()
|
|
1278 "Go to the Top node of this file."
|
|
1279 (interactive)
|
|
1280 (Info-goto-node "Top"))
|
|
1281
|
|
1282 (defun Info-final-node ()
|
|
1283 "Go to the final node in this file."
|
|
1284 (interactive)
|
|
1285 (Info-goto-node "Top")
|
|
1286 (let (Info-history)
|
|
1287 ;; Go to the last node in the menu of Top.
|
|
1288 (Info-goto-node (Info-extract-menu-counting nil))
|
|
1289 ;; If the last node in the menu is not last in pointer structure,
|
|
1290 ;; move forward until we can't go any farther.
|
|
1291 (while (Info-forward-node t t) nil)
|
|
1292 ;; Then keep moving down to last subnode, unless we reach an index.
|
|
1293 (while (and (not (string-match "\\<index\\>" Info-current-node))
|
|
1294 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
1295 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
1296
|
|
1297 (defun Info-forward-node (&optional not-down no-error)
|
|
1298 "Go forward one node, considering all nodes as forming one sequence."
|
|
1299 (interactive)
|
|
1300 (goto-char (point-min))
|
|
1301 (forward-line 1)
|
|
1302 ;; three possibilities, in order of priority:
|
|
1303 ;; 1. next node is in a menu in this node (but not in an index)
|
|
1304 ;; 2. next node is next at same level
|
|
1305 ;; 3. next node is up and next
|
|
1306 (cond ((and (not not-down)
|
|
1307 (save-excursion (search-forward "\n* menu:" nil t))
|
|
1308 (not (string-match "\\<index\\>" Info-current-node)))
|
2036
|
1309 (Info-goto-node (Info-extract-menu-counting 1))
|
325
|
1310 t)
|
|
1311 ((save-excursion (search-backward "next:" nil t))
|
|
1312 (Info-next)
|
|
1313 t)
|
|
1314 ((and (save-excursion (search-backward "up:" nil t))
|
11527
|
1315 ;; Use string-equal, not equal, to ignore text props.
|
|
1316 (not (string-equal (downcase (Info-extract-pointer "up"))
|
|
1317 "top")))
|
325
|
1318 (let ((old-node Info-current-node))
|
|
1319 (Info-up)
|
|
1320 (let (Info-history success)
|
|
1321 (unwind-protect
|
|
1322 (setq success (Info-forward-node t no-error))
|
|
1323 (or success (Info-goto-node old-node))))))
|
|
1324 (no-error nil)
|
|
1325 (t (error "No pointer forward from this node"))))
|
|
1326
|
|
1327 (defun Info-backward-node ()
|
|
1328 "Go backward one node, considering all nodes as forming one sequence."
|
|
1329 (interactive)
|
|
1330 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
|
|
1331 (upnode (Info-extract-pointer "up" t)))
|
|
1332 (cond ((and upnode (string-match "(" upnode))
|
|
1333 (error "First node in file"))
|
|
1334 ((and upnode (or (null prevnode)
|
11527
|
1335 ;; Use string-equal, not equal,
|
|
1336 ;; to ignore text properties.
|
|
1337 (string-equal (downcase prevnode)
|
|
1338 (downcase upnode))))
|
325
|
1339 (Info-up))
|
|
1340 (prevnode
|
|
1341 ;; If we move back at the same level,
|
|
1342 ;; go down to find the last subnode*.
|
|
1343 (Info-prev)
|
|
1344 (let (Info-history)
|
|
1345 (while (and (not (string-match "\\<index\\>" Info-current-node))
|
|
1346 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
1347 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
1348 (t
|
|
1349 (error "No pointer backward from this node")))))
|
|
1350
|
|
1351 (defun Info-exit ()
|
|
1352 "Exit Info by selecting some other buffer."
|
|
1353 (interactive)
|
4410
|
1354 (if Info-standalone
|
|
1355 (save-buffers-kill-emacs)
|
22331
|
1356 (quit-window)))
|
325
|
1357
|
929
|
1358 (defun Info-next-menu-item ()
|
|
1359 (interactive)
|
23533
|
1360 (let ((node
|
|
1361 (save-excursion
|
|
1362 (forward-line -1)
|
|
1363 (search-forward "\n* menu:" nil t)
|
|
1364 (and (search-forward "\n* " nil t)
|
|
1365 (Info-extract-menu-node-name)))))
|
|
1366 (if node (Info-goto-node node)
|
|
1367 (error "No more items in menu"))))
|
929
|
1368
|
|
1369 (defun Info-last-menu-item ()
|
|
1370 (interactive)
|
|
1371 (save-excursion
|
|
1372 (forward-line 1)
|
8489
|
1373 (let ((beg (save-excursion
|
|
1374 (and (search-backward "\n* menu:" nil t)
|
|
1375 (point)))))
|
|
1376 (or (and beg (search-backward "\n* " beg t))
|
|
1377 (error "No previous items in menu")))
|
|
1378 (Info-goto-node (save-excursion
|
|
1379 (goto-char (match-end 0))
|
|
1380 (Info-extract-menu-node-name)))))
|
929
|
1381
|
4410
|
1382 (defmacro Info-no-error (&rest body)
|
929
|
1383 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
|
|
1384
|
|
1385 (defun Info-next-preorder ()
|
8018
|
1386 "Go to the next subnode or the next node, or go up a level."
|
|
1387 (interactive)
|
|
1388 (cond ((Info-no-error (Info-next-menu-item)))
|
|
1389 ((Info-no-error (Info-next)))
|
21910
|
1390 ((Info-no-error (Info-up t))
|
12156
|
1391 ;; Since we have already gone thru all the items in this menu,
|
|
1392 ;; go up to the end of this node.
|
15575
|
1393 (goto-char (point-max))
|
|
1394 ;; Since logically we are done with the node with that menu,
|
|
1395 ;; move on from it.
|
|
1396 (Info-next-preorder))
|
8018
|
1397 (t
|
|
1398 (error "No more nodes"))))
|
929
|
1399
|
|
1400 (defun Info-last-preorder ()
|
|
1401 "Go to the last node, popping up a level if there is none."
|
|
1402 (interactive)
|
8489
|
1403 (cond ((Info-no-error
|
|
1404 (Info-last-menu-item)
|
|
1405 ;; If we go down a menu item, go to the end of the node
|
|
1406 ;; so we can scroll back through it.
|
12156
|
1407 (goto-char (point-max)))
|
15575
|
1408 ;; Keep going down, as long as there are nested menu nodes.
|
|
1409 (while (Info-no-error
|
|
1410 (Info-last-menu-item)
|
|
1411 ;; If we go down a menu item, go to the end of the node
|
|
1412 ;; so we can scroll back through it.
|
|
1413 (goto-char (point-max))))
|
12156
|
1414 (recenter -1))
|
21910
|
1415 ((and (not (equal (Info-extract-pointer "up")
|
|
1416 (Info-extract-pointer "prev"))))
|
|
1417 (Info-no-error (Info-prev))
|
12156
|
1418 (goto-char (point-max))
|
15575
|
1419 (while (Info-no-error
|
|
1420 (Info-last-menu-item)
|
|
1421 ;; If we go down a menu item, go to the end of the node
|
|
1422 ;; so we can scroll back through it.
|
|
1423 (goto-char (point-max))))
|
12156
|
1424 (recenter -1))
|
21910
|
1425 ((Info-no-error (Info-up t))
|
12156
|
1426 (goto-char (point-min))
|
|
1427 (or (search-forward "\n* Menu:" nil t)
|
|
1428 (goto-char (point-max))))
|
|
1429 (t (error "No previous nodes"))))
|
929
|
1430
|
|
1431 (defun Info-scroll-up ()
|
9222
|
1432 "Scroll one screenful forward in Info, considering all nodes as one sequence.
|
16498
|
1433 Once you scroll far enough in a node that its menu appears on the screen
|
|
1434 but after point, the next scroll moves into its first subnode.
|
|
1435
|
|
1436 When you scroll past the end of a node, that goes to the next node; if
|
|
1437 this node has no successor, it moves to the parent node's successor,
|
|
1438 and so on. If point is inside the menu of a node, it moves to
|
|
1439 subnode indicated by the following menu item. (That case won't
|
|
1440 normally result from this command, but can happen in other ways.)"
|
|
1441
|
929
|
1442 (interactive)
|
8489
|
1443 (if (or (< (window-start) (point-min))
|
|
1444 (> (window-start) (point-max)))
|
|
1445 (set-window-start (selected-window) (point)))
|
|
1446 (let ((virtual-end (save-excursion
|
|
1447 (goto-char (point-min))
|
|
1448 (if (search-forward "\n* Menu:" nil t)
|
|
1449 (point)
|
|
1450 (point-max)))))
|
|
1451 (if (or (< virtual-end (window-start))
|
|
1452 (pos-visible-in-window-p virtual-end))
|
|
1453 (Info-next-preorder)
|
|
1454 (scroll-up))))
|
929
|
1455
|
|
1456 (defun Info-scroll-down ()
|
9222
|
1457 "Scroll one screenful back in Info, considering all nodes as one sequence.
|
12156
|
1458 Within the menu of a node, this goes to its last subnode.
|
|
1459 When you scroll past the beginning of a node, that goes to the
|
|
1460 previous node or back up to the parent node."
|
929
|
1461 (interactive)
|
8489
|
1462 (if (or (< (window-start) (point-min))
|
|
1463 (> (window-start) (point-max)))
|
|
1464 (set-window-start (selected-window) (point)))
|
15575
|
1465 (let* ((current-point (point))
|
|
1466 (virtual-end (save-excursion
|
|
1467 (beginning-of-line)
|
|
1468 (setq current-point (point))
|
|
1469 (goto-char (point-min))
|
|
1470 (search-forward "\n* Menu:"
|
|
1471 current-point
|
|
1472 t))))
|
8489
|
1473 (if (or virtual-end (pos-visible-in-window-p (point-min)))
|
|
1474 (Info-last-preorder)
|
|
1475 (scroll-down))))
|
929
|
1476
|
15055
|
1477 (defun Info-next-reference (&optional recur)
|
4410
|
1478 "Move cursor to the next cross-reference or menu item in the node."
|
|
1479 (interactive)
|
|
1480 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
|
22951
|
1481 (old-pt (point))
|
|
1482 (case-fold-search t))
|
4410
|
1483 (or (eobp) (forward-char 1))
|
|
1484 (or (re-search-forward pat nil t)
|
|
1485 (progn
|
|
1486 (goto-char (point-min))
|
|
1487 (or (re-search-forward pat nil t)
|
|
1488 (progn
|
|
1489 (goto-char old-pt)
|
|
1490 (error "No cross references in this node")))))
|
|
1491 (goto-char (match-beginning 0))
|
|
1492 (if (looking-at "\\* Menu:")
|
15055
|
1493 (if recur
|
|
1494 (error "No cross references in this node")
|
|
1495 (Info-next-reference t)))))
|
4410
|
1496
|
15055
|
1497 (defun Info-prev-reference (&optional recur)
|
4410
|
1498 "Move cursor to the previous cross-reference or menu item in the node."
|
|
1499 (interactive)
|
|
1500 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
|
22951
|
1501 (old-pt (point))
|
|
1502 (case-fold-search t))
|
4410
|
1503 (or (re-search-backward pat nil t)
|
|
1504 (progn
|
|
1505 (goto-char (point-max))
|
|
1506 (or (re-search-backward pat nil t)
|
|
1507 (progn
|
|
1508 (goto-char old-pt)
|
|
1509 (error "No cross references in this node")))))
|
|
1510 (goto-char (match-beginning 0))
|
|
1511 (if (looking-at "\\* Menu:")
|
15055
|
1512 (if recur
|
|
1513 (error "No cross references in this node")
|
|
1514 (Info-prev-reference t)))))
|
4410
|
1515
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1516 (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>
diff
changeset
|
1517 "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>
diff
changeset
|
1518 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>
diff
changeset
|
1519 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>
diff
changeset
|
1520 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>
diff
changeset
|
1521 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>
diff
changeset
|
1522 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>
diff
changeset
|
1523 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>
diff
changeset
|
1524 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>
diff
changeset
|
1525 (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>
diff
changeset
|
1526 (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>
diff
changeset
|
1527 (rnode nil)
|
21641
|
1528 (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1529 (regexp-quote topic)))
|
22951
|
1530 node
|
|
1531 (case-fold-search t))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1532 (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>
diff
changeset
|
1533 (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>
diff
changeset
|
1534 (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>
diff
changeset
|
1535 (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>
diff
changeset
|
1536 (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>
diff
changeset
|
1537 (goto-char (match-beginning 1))
|
10758
|
1538 ;; Here, and subsequently in this function,
|
|
1539 ;; we bind Info-history to nil for internal node-switches
|
|
1540 ;; so that we don't put junk in the history.
|
|
1541 ;; In the first Info-goto-node call, above, we do update the history
|
|
1542 ;; because that is what the user's previous node choice into it.
|
|
1543 (let ((Info-history nil))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1544 (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>
diff
changeset
|
1545 (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>
diff
changeset
|
1546 (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>
diff
changeset
|
1547 (exact nil)
|
10758
|
1548 (Info-history nil)
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1549 found)
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1550 (while
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1551 (progn
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1552 (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>
diff
changeset
|
1553 (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>
diff
changeset
|
1554 (setq matches
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1555 (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>
diff
changeset
|
1556 (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>
diff
changeset
|
1557 (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>
diff
changeset
|
1558 (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>
diff
changeset
|
1559 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>
diff
changeset
|
1560 (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>
diff
changeset
|
1561 (buffer-substring
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1562 (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>
diff
changeset
|
1563 (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>
diff
changeset
|
1564 matches)))
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1565 (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>
diff
changeset
|
1566 (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>
diff
changeset
|
1567 (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>
diff
changeset
|
1568 (or matches
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1569 (progn
|
14664
|
1570 (Info-goto-node orignode)
|
14560
|
1571 (error "No `%s' in index" topic)))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1572 ;; 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>
diff
changeset
|
1573 (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>
diff
changeset
|
1574 (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>
diff
changeset
|
1575 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>
diff
changeset
|
1576 (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>
diff
changeset
|
1577 (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>
diff
changeset
|
1578
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1579 (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>
diff
changeset
|
1580 "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>
diff
changeset
|
1581 (interactive "p")
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1582 (or Info-index-alternatives
|
16790
|
1583 (error "No previous `i' command"))
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1584 (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>
diff
changeset
|
1585 (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>
diff
changeset
|
1586 (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>
diff
changeset
|
1587 (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>
diff
changeset
|
1588 (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>
diff
changeset
|
1589 (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>
diff
changeset
|
1590 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>
diff
changeset
|
1591 (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>
diff
changeset
|
1592 (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>
diff
changeset
|
1593 (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>
diff
changeset
|
1594 (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>
diff
changeset
|
1595 (let ((name (car (car Info-index-alternatives))))
|
14560
|
1596 (Info-find-index-name name)))
|
|
1597 (message "Found `%s' in %s. %s"
|
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1598 (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>
diff
changeset
|
1599 (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>
diff
changeset
|
1600 (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>
diff
changeset
|
1601 "(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>
diff
changeset
|
1602 "(Only match)")))
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1603
|
14560
|
1604 (defun Info-find-index-name (name)
|
|
1605 "Move point to the place within the current node where NAME is defined."
|
22951
|
1606 (let ((case-fold-search t))
|
|
1607 (if (or (re-search-forward (format
|
|
1608 "[a-zA-Z]+: %s\\( \\|$\\)"
|
|
1609 (regexp-quote name)) nil t)
|
|
1610 (search-forward (format "`%s'" name) nil t)
|
|
1611 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
|
|
1612 (search-forward
|
|
1613 (format "`%s'" (substring name 0 (match-beginning 1)))
|
|
1614 nil t))
|
|
1615 (search-forward name nil t))
|
|
1616 (beginning-of-line)
|
|
1617 (goto-char (point-min)))))
|
14560
|
1618
|
325
|
1619 (defun Info-undefined ()
|
|
1620 "Make command be undefined in Info."
|
|
1621 (interactive)
|
|
1622 (ding))
|
|
1623
|
|
1624 (defun Info-help ()
|
|
1625 "Enter the Info tutorial."
|
|
1626 (interactive)
|
|
1627 (delete-other-windows)
|
|
1628 (Info-find-node "info"
|
|
1629 (if (< (window-height) 23)
|
|
1630 "Help-Small-Screen"
|
|
1631 "Help")))
|
|
1632
|
|
1633 (defun Info-summary ()
|
|
1634 "Display a brief summary of all Info commands."
|
|
1635 (interactive)
|
|
1636 (save-window-excursion
|
|
1637 (switch-to-buffer "*Help*")
|
20910
|
1638 (setq buffer-read-only nil)
|
325
|
1639 (erase-buffer)
|
|
1640 (insert (documentation 'Info-mode))
|
9852
|
1641 (help-mode)
|
325
|
1642 (goto-char (point-min))
|
|
1643 (let (ch flag)
|
|
1644 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
|
|
1645 (message (if flag "Type Space to see more"
|
|
1646 "Type Space to return to Info"))
|
2032
|
1647 (if (not (eq ?\ (setq ch (read-event))))
|
1821
|
1648 (progn (setq unread-command-events (list ch)) nil)
|
325
|
1649 flag))
|
4410
|
1650 (scroll-up)))
|
|
1651 (bury-buffer "*Help*")))
|
325
|
1652
|
|
1653 (defun Info-get-token (pos start all &optional errorstring)
|
|
1654 "Return the token around POS,
|
|
1655 POS must be somewhere inside the token
|
|
1656 START is a regular expression which will match the
|
|
1657 beginning of the tokens delimited string
|
|
1658 ALL is a regular expression with a single
|
13990
|
1659 parenthesized subpattern which is the token to be
|
325
|
1660 returned. E.g. '{\(.*\)}' would return any string
|
|
1661 enclosed in braces around POS.
|
|
1662 SIG optional fourth argument, controls action on no match
|
|
1663 nil: return nil
|
|
1664 t: beep
|
|
1665 a string: signal an error, using that string."
|
22951
|
1666 (let ((case-fold-search t))
|
|
1667 (save-excursion
|
|
1668 (goto-char pos)
|
|
1669 ;; First look for a match for START that goes across POS.
|
|
1670 (while (and (not (bobp)) (> (point) (- pos (length start)))
|
|
1671 (not (looking-at start)))
|
|
1672 (forward-char -1))
|
|
1673 ;; If we did not find one, search back for START
|
|
1674 ;; (this finds only matches that end at or before POS).
|
|
1675 (or (looking-at start)
|
|
1676 (progn
|
|
1677 (goto-char pos)
|
|
1678 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
|
|
1679 (let (found)
|
|
1680 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
|
|
1681 (not (setq found (and (<= (match-beginning 0) pos)
|
|
1682 (> (match-end 0) pos))))))
|
|
1683 (if (and found (<= (match-beginning 0) pos)
|
|
1684 (> (match-end 0) pos))
|
|
1685 (buffer-substring (match-beginning 1) (match-end 1))
|
|
1686 (cond ((null errorstring)
|
|
1687 nil)
|
|
1688 ((eq errorstring t)
|
|
1689 (beep)
|
|
1690 nil)
|
|
1691 (t
|
|
1692 (error "No %s around position %d" errorstring pos))))))))
|
325
|
1693
|
7007
|
1694 (defun Info-mouse-follow-nearest-node (click)
|
1309
|
1695 "\\<Info-mode-map>Follow a node reference near point.
|
|
1696 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
|
7007
|
1697 At end of the node's text, moves to the next node, or up if none."
|
1309
|
1698 (interactive "e")
|
1484
|
1699 (let* ((start (event-start click))
|
|
1700 (window (car start))
|
|
1701 (pos (car (cdr start))))
|
|
1702 (select-window window)
|
|
1703 (goto-char pos))
|
7007
|
1704 (and (not (Info-try-follow-nearest-node))
|
|
1705 (save-excursion (forward-line 1) (eobp))
|
12156
|
1706 (Info-next-preorder)))
|
7007
|
1707
|
|
1708 (defun Info-follow-nearest-node ()
|
|
1709 "\\<Info-mode-map>Follow a node reference near point.
|
|
1710 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
|
|
1711 If no reference to follow, moves to the next node, or up if none."
|
|
1712 (interactive)
|
|
1713 (or (Info-try-follow-nearest-node)
|
12156
|
1714 (Info-next-preorder)))
|
7007
|
1715
|
|
1716 ;; Common subroutine.
|
|
1717 (defun Info-try-follow-nearest-node ()
|
|
1718 "Follow a node reference near point. Return non-nil if successful."
|
325
|
1719 (let (node)
|
|
1720 (cond
|
7007
|
1721 ((setq node (Info-get-token (point) "\\*note[ \n]"
|
|
1722 "\\*note[ \n]\\([^:]*\\):"))
|
325
|
1723 (Info-follow-reference node))
|
21641
|
1724 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
|
325
|
1725 (Info-goto-node node))
|
23019
|
1726 ((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):")
|
|
1727 (beginning-of-line)
|
|
1728 (forward-char 2)
|
|
1729 (setq node (Info-extract-menu-node-name))
|
|
1730 (Info-goto-node node))
|
3127
|
1731 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
|
325
|
1732 (Info-goto-node node))
|
3127
|
1733 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
|
325
|
1734 (Info-goto-node node))
|
3127
|
1735 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
|
325
|
1736 (Info-goto-node "Top"))
|
3127
|
1737 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
|
7007
|
1738 (Info-goto-node node)))
|
|
1739 node))
|
325
|
1740
|
|
1741 (defvar Info-mode-map nil
|
|
1742 "Keymap containing Info commands.")
|
|
1743 (if Info-mode-map
|
|
1744 nil
|
|
1745 (setq Info-mode-map (make-keymap))
|
|
1746 (suppress-keymap Info-mode-map)
|
|
1747 (define-key Info-mode-map "." 'beginning-of-buffer)
|
929
|
1748 (define-key Info-mode-map " " 'Info-scroll-up)
|
7007
|
1749 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
|
4410
|
1750 (define-key Info-mode-map "\t" 'Info-next-reference)
|
|
1751 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
|
1666
|
1752 (define-key Info-mode-map "1" 'Info-nth-menu-item)
|
|
1753 (define-key Info-mode-map "2" 'Info-nth-menu-item)
|
|
1754 (define-key Info-mode-map "3" 'Info-nth-menu-item)
|
|
1755 (define-key Info-mode-map "4" 'Info-nth-menu-item)
|
|
1756 (define-key Info-mode-map "5" 'Info-nth-menu-item)
|
|
1757 (define-key Info-mode-map "6" 'Info-nth-menu-item)
|
|
1758 (define-key Info-mode-map "7" 'Info-nth-menu-item)
|
|
1759 (define-key Info-mode-map "8" 'Info-nth-menu-item)
|
|
1760 (define-key Info-mode-map "9" 'Info-nth-menu-item)
|
1667
|
1761 (define-key Info-mode-map "0" 'undefined)
|
325
|
1762 (define-key Info-mode-map "?" 'Info-summary)
|
|
1763 (define-key Info-mode-map "]" 'Info-forward-node)
|
|
1764 (define-key Info-mode-map "[" 'Info-backward-node)
|
|
1765 (define-key Info-mode-map "<" 'Info-top-node)
|
|
1766 (define-key Info-mode-map ">" 'Info-final-node)
|
|
1767 (define-key Info-mode-map "b" 'beginning-of-buffer)
|
|
1768 (define-key Info-mode-map "d" 'Info-directory)
|
|
1769 (define-key Info-mode-map "e" 'Info-edit)
|
|
1770 (define-key Info-mode-map "f" 'Info-follow-reference)
|
|
1771 (define-key Info-mode-map "g" 'Info-goto-node)
|
|
1772 (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>
diff
changeset
|
1773 (define-key Info-mode-map "i" 'Info-index)
|
325
|
1774 (define-key Info-mode-map "l" 'Info-last)
|
|
1775 (define-key Info-mode-map "m" 'Info-menu)
|
|
1776 (define-key Info-mode-map "n" 'Info-next)
|
|
1777 (define-key Info-mode-map "p" 'Info-prev)
|
|
1778 (define-key Info-mode-map "q" 'Info-exit)
|
|
1779 (define-key Info-mode-map "s" 'Info-search)
|
8739
|
1780 ;; For consistency with Rmail.
|
|
1781 (define-key Info-mode-map "\M-s" 'Info-search)
|
3313
|
1782 (define-key Info-mode-map "t" 'Info-top-node)
|
325
|
1783 (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>
diff
changeset
|
1784 (define-key Info-mode-map "," 'Info-index-next)
|
930
|
1785 (define-key Info-mode-map "\177" 'Info-scroll-down)
|
7007
|
1786 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
|
540
|
1787 )
|
16043
|
1788
|
|
1789 (defun Info-check-pointer (item)
|
|
1790 ;; Non-nil if ITEM is present in this node.
|
|
1791 (condition-case nil
|
|
1792 (Info-extract-pointer item)
|
|
1793 (error nil)))
|
|
1794
|
|
1795 (easy-menu-define Info-mode-menu Info-mode-map
|
|
1796 "Menu for info files."
|
|
1797 '("Info"
|
|
1798 ["Up" Info-up (Info-check-pointer "up")]
|
|
1799 ["Next" Info-next (Info-check-pointer "next")]
|
|
1800 ["Previous" Info-prev (Info-check-pointer "prev[ious]*")]
|
|
1801 ("Menu item" ["You should never see this" report-emacs-bug t])
|
|
1802 ("Reference" ["You should never see this" report-emacs-bug t])
|
|
1803 ["Search..." Info-search t]
|
|
1804 ["Goto node..." Info-goto-node t]
|
|
1805 ["Last" Info-last Info-history]
|
|
1806 ["Exit" Info-exit t]))
|
|
1807
|
|
1808 (defvar Info-menu-last-node nil)
|
|
1809 ;; Last node the menu was created for.
|
21197
|
1810 ;; Value is a list, (FILE-NAME NODE-NAME).
|
16043
|
1811
|
|
1812 (defun Info-menu-update ()
|
|
1813 ;; Update the Info menu for the current node.
|
|
1814 (condition-case nil
|
|
1815 (if (or (not (eq major-mode 'Info-mode))
|
21197
|
1816 (equal (list Info-current-file Info-current-node)
|
|
1817 Info-menu-last-node))
|
16043
|
1818 ()
|
|
1819 ;; Update menu menu.
|
|
1820 (let* ((Info-complete-menu-buffer (current-buffer))
|
|
1821 (items (nreverse (condition-case nil
|
|
1822 (Info-complete-menu-item
|
|
1823 "" (lambda (e) t) t)
|
|
1824 (error nil))))
|
|
1825 entries current
|
|
1826 (number 0))
|
|
1827 (while (and items (< number 9))
|
|
1828 (setq current (car items)
|
|
1829 items (cdr items)
|
|
1830 number (1+ number))
|
|
1831 (setq entries (cons `[,current
|
|
1832 (Info-menu ,current)
|
|
1833 :keys ,(format "%d" number)]
|
|
1834 entries)))
|
|
1835 (if items
|
|
1836 (setq entries (cons ["Other..." Info-menu t] entries)))
|
|
1837 (or entries
|
|
1838 (setq entries (list ["No menu" nil nil])))
|
|
1839 (easy-menu-change '("Info") "Menu item" (nreverse entries)))
|
|
1840 ;; Update reference menu. Code stolen from `Info-follow-reference'.
|
|
1841 (let ((items nil)
|
|
1842 str i entries current
|
22951
|
1843 (number 0)
|
|
1844 (case-fold-search t))
|
16043
|
1845 (save-excursion
|
|
1846 (goto-char (point-min))
|
|
1847 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
|
|
1848 (setq str (buffer-substring
|
|
1849 (match-beginning 1)
|
|
1850 (1- (point))))
|
|
1851 (setq i 0)
|
|
1852 (while (setq i (string-match "[ \n\t]+" str i))
|
|
1853 (setq str (concat (substring str 0 i) " "
|
|
1854 (substring str (match-end 0))))
|
|
1855 (setq i (1+ i)))
|
|
1856 (setq items
|
|
1857 (cons str items))))
|
|
1858 (while (and items (< number 9))
|
|
1859 (setq current (car items)
|
|
1860 items (cdr items)
|
|
1861 number (1+ number))
|
|
1862 (setq entries (cons `[,current
|
|
1863 (Info-follow-reference ,current)
|
|
1864 t]
|
|
1865 entries)))
|
|
1866 (if items
|
|
1867 (setq entries (cons ["Other..." Info-follow-reference t]
|
|
1868 entries)))
|
|
1869 (or entries
|
|
1870 (setq entries (list ["No references" nil nil])))
|
|
1871 (easy-menu-change '("Info") "Reference" (nreverse entries)))
|
|
1872 ;; Update last seen node.
|
21197
|
1873 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
|
16043
|
1874 ;; Try to avoid entering infinite beep mode in case of errors.
|
|
1875 (error (ding))))
|
|
1876
|
325
|
1877
|
|
1878 ;; Info mode is suitable only for specially formatted data.
|
|
1879 (put 'info-mode 'mode-class 'special)
|
|
1880
|
|
1881 (defun Info-mode ()
|
|
1882 "\\<Info-mode-map>
|
|
1883 Info mode provides commands for browsing through the Info documentation tree.
|
|
1884 Documentation in Info is divided into \"nodes\", each of which discusses
|
|
1885 one topic and contains references to other nodes which discuss related
|
|
1886 topics. Info has commands to follow the references and show you other nodes.
|
|
1887
|
|
1888 \\[Info-help] Invoke the Info tutorial.
|
21806
|
1889 \\[Info-exit] Quit Info: reselect previously selected buffer.
|
325
|
1890
|
|
1891 Selecting other nodes:
|
8564
|
1892 \\[Info-mouse-follow-nearest-node]
|
|
1893 Follow a node reference you click on.
|
|
1894 This works with menu items, cross references, and
|
|
1895 the \"next\", \"previous\" and \"up\", depending on where you click.
|
21806
|
1896 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
|
325
|
1897 \\[Info-next] Move to the \"next\" node of this node.
|
3127
|
1898 \\[Info-prev] Move to the \"previous\" node of this node.
|
325
|
1899 \\[Info-up] Move \"up\" from this node.
|
|
1900 \\[Info-menu] Pick menu item specified by name (or abbreviation).
|
|
1901 Picking a menu item causes another node to be selected.
|
540
|
1902 \\[Info-directory] Go to the Info directory node.
|
325
|
1903 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
|
|
1904 \\[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>
diff
changeset
|
1905 \\[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>
diff
changeset
|
1906 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
|
21806
|
1907 \\[Info-top-node] Go to the Top node of this file.
|
|
1908 \\[Info-final-node] Go to the final node in this file.
|
|
1909 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
|
|
1910 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
|
325
|
1911
|
|
1912 Moving within a node:
|
20514
|
1913 \\[Info-scroll-up] Normally, scroll forward a full screen.
|
|
1914 Once you scroll far enough in a node that its menu appears on the screen
|
|
1915 but after point, the next scroll moves into its first subnode.
|
|
1916 When after all menu items (or if their is no menu), move up to
|
|
1917 the parent node.
|
|
1918 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
|
930
|
1919 already visible, try to go to the previous menu entry, or up if there is none.
|
|
1920 \\[beginning-of-buffer] Go to beginning of node.
|
325
|
1921
|
|
1922 Advanced commands:
|
|
1923 \\[Info-exit] Quit Info: reselect previously selected buffer.
|
|
1924 \\[Info-edit] Edit contents of selected node.
|
|
1925 1 Pick first item in node's menu.
|
|
1926 2, 3, 4, 5 Pick second ... fifth item in node's menu.
|
|
1927 \\[Info-goto-node] Move to node specified by name.
|
|
1928 You may include a filename as well, as (FILENAME)NODENAME.
|
4410
|
1929 \\[universal-argument] \\[info] Move to new Info file with completion.
|
325
|
1930 \\[Info-search] Search through this Info file for specified regexp,
|
930
|
1931 and select the node in which the next occurrence is found.
|
4410
|
1932 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
|
|
1933 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
|
325
|
1934 (kill-all-local-variables)
|
|
1935 (setq major-mode 'Info-mode)
|
|
1936 (setq mode-name "Info")
|
16672
|
1937 (setq tab-width 8)
|
325
|
1938 (use-local-map Info-mode-map)
|
16043
|
1939 (make-local-hook 'activate-menubar-hook)
|
|
1940 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
|
325
|
1941 (set-syntax-table text-mode-syntax-table)
|
|
1942 (setq local-abbrev-table text-mode-abbrev-table)
|
|
1943 (setq case-fold-search t)
|
|
1944 (setq buffer-read-only t)
|
|
1945 (make-local-variable 'Info-current-file)
|
|
1946 (make-local-variable 'Info-current-subfile)
|
|
1947 (make-local-variable 'Info-current-node)
|
|
1948 (make-local-variable 'Info-tag-table-marker)
|
16981
|
1949 (setq Info-tag-table-marker (make-marker))
|
|
1950 (make-local-variable 'Info-tag-table-buffer)
|
|
1951 (setq Info-tag-table-buffer nil)
|
325
|
1952 (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>
diff
changeset
|
1953 (make-local-variable 'Info-index-alternatives)
|
19043
|
1954 ;; This is for the sake of the invisible text we use handling titles.
|
|
1955 (make-local-variable 'line-move-ignore-invisible)
|
|
1956 (setq line-move-ignore-invisible t)
|
325
|
1957 (Info-set-mode-line)
|
|
1958 (run-hooks 'Info-mode-hook))
|
|
1959
|
|
1960 (defvar Info-edit-map nil
|
|
1961 "Local keymap used within `e' command of Info.")
|
|
1962 (if Info-edit-map
|
|
1963 nil
|
|
1964 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
|
|
1965 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
|
|
1966
|
|
1967 ;; Info-edit mode is suitable only for specially formatted data.
|
|
1968 (put 'info-edit-mode 'mode-class 'special)
|
|
1969
|
|
1970 (defun Info-edit-mode ()
|
|
1971 "Major mode for editing the contents of an Info node.
|
1477
|
1972 Like text mode with the addition of `Info-cease-edit'
|
325
|
1973 which returns to Info mode for browsing.
|
|
1974 \\{Info-edit-map}"
|
8805
|
1975 (use-local-map Info-edit-map)
|
|
1976 (setq major-mode 'Info-edit-mode)
|
|
1977 (setq mode-name "Info Edit")
|
|
1978 (kill-local-variable 'mode-line-buffer-identification)
|
|
1979 (setq buffer-read-only nil)
|
11580
|
1980 (force-mode-line-update)
|
8805
|
1981 (buffer-enable-undo (current-buffer))
|
|
1982 (run-hooks 'Info-edit-mode-hook))
|
325
|
1983
|
|
1984 (defun Info-edit ()
|
|
1985 "Edit the contents of this Info node.
|
|
1986 Allowed only if variable `Info-enable-edit' is non-nil."
|
|
1987 (interactive)
|
|
1988 (or Info-enable-edit
|
|
1989 (error "Editing info nodes is not enabled"))
|
8805
|
1990 (Info-edit-mode)
|
14319
e39a2eb75dbe
(Info-edit, Info-goto-emacs-command-node): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1991 (message "%s" (substitute-command-keys
|
8805
|
1992 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
|
325
|
1993
|
|
1994 (defun Info-cease-edit ()
|
|
1995 "Finish editing Info node; switch back to Info proper."
|
|
1996 (interactive)
|
|
1997 ;; Do this first, so nothing has changed if user C-g's at query.
|
|
1998 (and (buffer-modified-p)
|
|
1999 (y-or-n-p "Save the file? ")
|
|
2000 (save-buffer))
|
|
2001 (use-local-map Info-mode-map)
|
|
2002 (setq major-mode 'Info-mode)
|
|
2003 (setq mode-name "Info")
|
|
2004 (Info-set-mode-line)
|
|
2005 (setq buffer-read-only t)
|
11580
|
2006 (force-mode-line-update)
|
325
|
2007 (and (marker-position Info-tag-table-marker)
|
|
2008 (buffer-modified-p)
|
|
2009 (message "Tags may have changed. Use Info-tagify if necessary")))
|
359
|
2010
|
12889
|
2011 (defvar Info-file-list-for-emacs
|
|
2012 '("ediff" "forms" "gnus" "info" ("mh" . "mh-e") "sc")
|
|
2013 "List of Info files that describe Emacs commands.
|
|
2014 An element can be a file name, or a list of the form (PREFIX . FILE)
|
|
2015 where PREFIX is a name prefix and FILE is the file to look in.
|
|
2016 If the element is just a file name, the file name also serves as the prefix.")
|
|
2017
|
359
|
2018 (defun Info-find-emacs-command-nodes (command)
|
12889
|
2019 "Return a list of locations documenting COMMAND.
|
12892
|
2020 The `info-file' property of COMMAND says which Info manual to search.
|
|
2021 If COMMAND has no property, the variable `Info-file-list-for-emacs'
|
|
2022 defines heuristics for which Info manual to try.
|
359
|
2023 The locations are of the format used in Info-history, i.e.
|
|
2024 \(FILENAME NODENAME BUFFERPOS\)."
|
|
2025 (let ((where '())
|
21641
|
2026 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
|
12889
|
2027 ":\\s *\\(.*\\)\\.$"))
|
|
2028 (info-file "emacs")) ;default
|
|
2029 ;; Determine which info file this command is documented in.
|
|
2030 (if (get command 'info-file)
|
|
2031 (setq info-file (get command 'info-file))
|
|
2032 ;; If it doesn't say explicitly, test its name against
|
|
2033 ;; various prefixes that we know.
|
|
2034 (let ((file-list Info-file-list-for-emacs))
|
|
2035 (while file-list
|
|
2036 (let* ((elt (car file-list))
|
|
2037 (name (if (consp elt)
|
|
2038 (car elt)
|
|
2039 elt))
|
|
2040 (file (if (consp elt) (cdr elt) elt))
|
12892
|
2041 (regexp (concat "\\`" (regexp-quote name)
|
12889
|
2042 "\\(\\'\\|-\\)")))
|
|
2043 (if (string-match regexp (symbol-name command))
|
|
2044 (setq info-file file file-list nil))
|
|
2045 (setq file-list (cdr file-list))))))
|
359
|
2046 (save-excursion
|
12889
|
2047 (condition-case nil
|
|
2048 (Info-find-node info-file "Command Index")
|
|
2049 ;; Some manuals may not have a separate Command Index node,
|
|
2050 ;; so try just Index instead.
|
|
2051 (error
|
|
2052 (Info-find-node info-file "Index")))
|
359
|
2053 ;; Take the index node off the Info history.
|
|
2054 (setq Info-history (cdr Info-history))
|
|
2055 (goto-char (point-max))
|
|
2056 (while (re-search-backward cmd-desc nil t)
|
|
2057 (setq where (cons (list Info-current-file
|
|
2058 (buffer-substring
|
|
2059 (match-beginning 1)
|
|
2060 (match-end 1))
|
|
2061 0)
|
|
2062 where)))
|
|
2063 where)))
|
|
2064
|
|
2065 ;;;###autoload
|
|
2066 (defun Info-goto-emacs-command-node (command)
|
4468
5e9224dac452
(Info-goto-emacs-command-node, Info-goto-emacs-key-command-node): Doc fix.
Roland McGrath <roland@gnu.org>
diff
changeset
|
2067 "Go to the Info node in the Emacs manual for command COMMAND.
|
12889
|
2068 The command is found by looking up in Emacs manual's Command Index
|
12892
|
2069 or in another manual found via COMMAND's `info-file' property or
|
|
2070 the variable `Info-file-list-for-emacs'."
|
359
|
2071 (interactive "CFind documentation for command: ")
|
|
2072 (or (commandp command)
|
|
2073 (signal 'wrong-type-argument (list 'commandp command)))
|
|
2074 (let ((where (Info-find-emacs-command-nodes command)))
|
|
2075 (if where
|
|
2076 (let ((num-matches (length where)))
|
|
2077 ;; Get Info running, and pop to it in another window.
|
|
2078 (save-window-excursion
|
|
2079 (info))
|
16981
|
2080 ;; FIXME It would be cool if this could use a buffer other
|
|
2081 ;; than *info*.
|
359
|
2082 (pop-to-buffer "*info*")
|
|
2083 (Info-find-node (car (car where))
|
|
2084 (car (cdr (car where))))
|
|
2085 (if (> num-matches 1)
|
|
2086 (progn
|
|
2087 ;; Info-find-node already pushed (car where) onto
|
|
2088 ;; Info-history. Put the other nodes that were found on
|
|
2089 ;; the history.
|
|
2090 (setq Info-history (nconc (cdr where) Info-history))
|
14319
e39a2eb75dbe
(Info-edit, Info-goto-emacs-command-node): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2091 (message "Found %d other entr%s. Use %s to see %s."
|
6049
|
2092 (1- num-matches)
|
|
2093 (if (> num-matches 2) "ies" "y")
|
14319
e39a2eb75dbe
(Info-edit, Info-goto-emacs-command-node): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
2094 (substitute-command-keys "\\[Info-last]")
|
6049
|
2095 (if (> num-matches 2) "them" "it")))))
|
14355
|
2096 (error "Couldn't find documentation for %s" command))))
|
359
|
2097
|
|
2098 ;;;###autoload
|
|
2099 (defun Info-goto-emacs-key-command-node (key)
|
|
2100 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
|
4468
5e9224dac452
(Info-goto-emacs-command-node, Info-goto-emacs-key-command-node): Doc fix.
Roland McGrath <roland@gnu.org>
diff
changeset
|
2101 Interactively, if the binding is execute-extended-command, a command is read.
|
12889
|
2102 The command is found by looking up in Emacs manual's Command Index
|
12892
|
2103 or in another manual found via COMMAND's `info-file' property or
|
|
2104 the variable `Info-file-list-for-emacs'."
|
359
|
2105 (interactive "kFind documentation for key:")
|
|
2106 (let ((command (key-binding key)))
|
|
2107 (cond ((null command)
|
1484
|
2108 (message "%s is undefined" (key-description key)))
|
359
|
2109 ((and (interactive-p)
|
|
2110 (eq command 'execute-extended-command))
|
|
2111 (Info-goto-emacs-command-node
|
|
2112 (read-command "Find documentation for command: ")))
|
|
2113 (t
|
|
2114 (Info-goto-emacs-command-node command)))))
|
4410
|
2115
|
17430
|
2116 (defcustom Info-title-face-alist
|
13084
|
2117 '((?* bold underline)
|
|
2118 (?= bold-italic underline)
|
|
2119 (?- italic underline))
|
|
2120 "*Alist of face or list of faces to use for pseudo-underlined titles.
|
17430
|
2121 The alist key is the character the title is underlined with (?*, ?= or ?-)."
|
|
2122 :type '(repeat (list character face face))
|
|
2123 :group 'info)
|
13084
|
2124
|
4410
|
2125 (defun Info-fontify-node ()
|
|
2126 (save-excursion
|
22951
|
2127 (let ((buffer-read-only nil)
|
|
2128 (case-fold-search t))
|
4410
|
2129 (goto-char (point-min))
|
21704
|
2130 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
|
|
2131 (goto-char (match-end 0))
|
|
2132 (while
|
|
2133 (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
|
|
2134 (goto-char (match-end 0))
|
|
2135 (if (save-excursion
|
|
2136 (goto-char (match-beginning 1))
|
|
2137 (save-match-data (looking-at "Node:")))
|
|
2138 (put-text-property (match-beginning 2) (match-end 2)
|
|
2139 'face 'info-node)
|
|
2140 (put-text-property (match-beginning 2) (match-end 2)
|
|
2141 'face 'info-xref)
|
|
2142 (put-text-property (match-beginning 2) (match-end 2)
|
|
2143 'mouse-face 'highlight))))
|
4410
|
2144 (goto-char (point-min))
|
13084
|
2145 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
|
|
2146 nil t)
|
|
2147 (put-text-property (match-beginning 1) (match-end 1)
|
|
2148 'face
|
13085
|
2149 (cdr (assq (preceding-char) Info-title-face-alist)))
|
19043
|
2150 ;; This is a serious problem for trying to handle multiple
|
|
2151 ;; frame types at once. We want this text to be invisible
|
|
2152 ;; on frames that can display the font above.
|
|
2153 (if (memq (framep (selected-frame)) '(x pc w32))
|
|
2154 (put-text-property (match-end 1) (match-end 2)
|
|
2155 'invisible t)))
|
13084
|
2156 (goto-char (point-min))
|
7859
|
2157 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
|
4410
|
2158 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
|
|
2159 nil
|
|
2160 (put-text-property (match-beginning 1) (match-end 1)
|
6624
|
2161 'face 'info-xref)
|
|
2162 (put-text-property (match-beginning 1) (match-end 1)
|
|
2163 'mouse-face 'highlight)))
|
4410
|
2164 (goto-char (point-min))
|
|
2165 (if (and (search-forward "\n* Menu:" nil t)
|
|
2166 (not (string-match "\\<Index\\>" Info-current-node))
|
|
2167 ;; Don't take time to annotate huge menus
|
8193
|
2168 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
|
4410
|
2169 (let ((n 0))
|
21641
|
2170 (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t)
|
4410
|
2171 (setq n (1+ n))
|
|
2172 (if (memq n '(5 9)) ; visual aids to help with 1-9 keys
|
|
2173 (put-text-property (match-beginning 0)
|
|
2174 (1+ (match-beginning 0))
|
|
2175 'face 'info-menu-5))
|
|
2176 (put-text-property (match-beginning 1) (match-end 1)
|
21704
|
2177 'face 'info-xref)
|
6624
|
2178 (put-text-property (match-beginning 1) (match-end 1)
|
|
2179 'mouse-face 'highlight))))
|
4410
|
2180 (set-buffer-modified-p nil))))
|
16981
|
2181
|
|
2182
|
|
2183 ;; When an Info buffer is killed, make sure the associated tags buffer
|
|
2184 ;; is killed too.
|
|
2185 (defun Info-kill-buffer ()
|
|
2186 (and (eq major-mode 'Info-mode)
|
|
2187 Info-tag-table-buffer
|
|
2188 (kill-buffer Info-tag-table-buffer)))
|
|
2189
|
|
2190 (add-hook 'kill-buffer-hook 'Info-kill-buffer)
|
20755
|
2191
|
|
2192 ;;; Speedbar support:
|
|
2193 ;; These functions permit speedbar to display the "tags" in the
|
|
2194 ;; current info node.
|
22733
|
2195 (eval-when-compile (require 'speedbar))
|
20755
|
2196
|
22733
|
2197 (defvar Info-speedbar-key-map nil
|
|
2198 "Keymap used when in the info display mode.")
|
|
2199
|
|
2200 (defun Info-install-speedbar-variables ()
|
|
2201 "Install those variables used by speedbar to enhance Info."
|
|
2202 (if Info-speedbar-key-map
|
|
2203 nil
|
|
2204 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
|
20755
|
2205
|
22733
|
2206 ;; Basic tree features
|
|
2207 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
|
|
2208 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
|
|
2209 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
|
|
2210 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
|
|
2211 )
|
|
2212
|
|
2213 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
|
|
2214 Info-speedbar-key-map
|
|
2215 Info-speedbar-hierarchy-buttons)))
|
20755
|
2216
|
|
2217 (defvar Info-speedbar-menu-items
|
22733
|
2218 '(["Browse Node" speedbar-edit-line t]
|
|
2219 ["Expand Node" speedbar-expand-line
|
|
2220 (save-excursion (beginning-of-line)
|
|
2221 (looking-at "[0-9]+: *.\\+. "))]
|
|
2222 ["Contract Node" speedbar-contract-line
|
|
2223 (save-excursion (beginning-of-line)
|
|
2224 (looking-at "[0-9]+: *.-. "))]
|
|
2225 )
|
20755
|
2226 "Additional menu-items to add to speedbar frame.")
|
|
2227
|
22733
|
2228 ;; Make sure our special speedbar major mode is loaded
|
|
2229 (if (featurep 'speedbar)
|
|
2230 (Info-install-speedbar-variables)
|
|
2231 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
|
|
2232
|
|
2233 ;;; Info hierarchy display method
|
|
2234 ;;;###autoload
|
|
2235 (defun Info-speedbar-browser ()
|
|
2236 "Initialize speedbar to display an info node browser.
|
|
2237 This will add a speedbar major display mode."
|
|
2238 (interactive)
|
|
2239 (require 'speedbar)
|
|
2240 ;; Make sure that speedbar is active
|
|
2241 (speedbar-frame-mode 1)
|
|
2242 ;; Now, throw us into Info mode on speedbar.
|
|
2243 (speedbar-change-initial-expansion-list "Info")
|
|
2244 )
|
|
2245
|
|
2246 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
|
|
2247 "Display an Info directory hierarchy in speedbar.
|
|
2248 DIRECTORY is the current directory in the attached frame.
|
|
2249 DEPTH is the current indentation depth.
|
|
2250 NODE is an optional argument that is used to represent the
|
|
2251 specific node to expand."
|
|
2252 (if (and (not node)
|
|
2253 (save-excursion (goto-char (point-min))
|
22951
|
2254 (let ((case-fold-search t))
|
|
2255 (looking-at "Info Nodes:"))))
|
22733
|
2256 ;; Update our "current node" maybe?
|
|
2257 nil
|
|
2258 ;; We cannot use the generic list code, that depends on all leaves
|
|
2259 ;; being known at creation time.
|
|
2260 (if (not node)
|
|
2261 (speedbar-with-writable (insert "Info Nodes:\n")))
|
22894
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2262 (let ((completions nil)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2263 (cf (selected-frame)))
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2264 (select-frame speedbar-attached-frame)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2265 (save-window-excursion
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2266 (setq completions
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2267 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2268 (select-frame cf)
|
22733
|
2269 (if completions
|
|
2270 (speedbar-with-writable
|
|
2271 (while completions
|
|
2272 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
|
|
2273 (cdr (car completions))
|
|
2274 (car (car completions))
|
|
2275 'Info-speedbar-goto-node
|
|
2276 (cdr (car completions))
|
|
2277 'info-xref depth)
|
|
2278 (setq completions (cdr completions)))
|
|
2279 t)
|
|
2280 nil))))
|
|
2281
|
|
2282 (defun Info-speedbar-goto-node (text node indent)
|
|
2283 "When user clicks on TEXT, goto an info NODE.
|
|
2284 The INDENT level is ignored."
|
|
2285 (select-frame speedbar-attached-frame)
|
|
2286 (let* ((buff (or (get-buffer "*info*")
|
|
2287 (progn (info) (get-buffer "*info*"))))
|
|
2288 (bwin (get-buffer-window buff 0)))
|
|
2289 (if bwin
|
|
2290 (progn
|
|
2291 (select-window bwin)
|
|
2292 (raise-frame (window-frame bwin)))
|
|
2293 (if speedbar-power-click
|
|
2294 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
|
|
2295 (select-frame speedbar-attached-frame)
|
|
2296 (switch-to-buffer buff)))
|
|
2297 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
|
|
2298 (file (match-string 1 node))
|
|
2299 (node (match-string 2 node)))
|
|
2300 (Info-find-node file node)
|
|
2301 ;; If we do a find-node, and we were in info mode, restore
|
|
2302 ;; the old default method. Once we are in info mode, it makes
|
|
2303 ;; sense to return to whatever method the user was using before.
|
|
2304 (if (string= speedbar-initial-expansion-list-name "Info")
|
|
2305 (speedbar-change-initial-expansion-list
|
|
2306 speedbar-previously-used-expansion-list-name)))))
|
|
2307
|
|
2308 (defun Info-speedbar-expand-node (text token indent)
|
|
2309 "Expand the node the user clicked on.
|
|
2310 TEXT is the text of the button we clicked on, a + or - item.
|
|
2311 TOKEN is data related to this node (NAME . FILE).
|
|
2312 INDENT is the current indentation depth."
|
|
2313 (cond ((string-match "+" text) ;we have to expand this file
|
|
2314 (speedbar-change-expand-button-char ?-)
|
|
2315 (if (speedbar-with-writable
|
|
2316 (save-excursion
|
|
2317 (end-of-line) (forward-char 1)
|
|
2318 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
|
|
2319 (speedbar-change-expand-button-char ?-)
|
|
2320 (speedbar-change-expand-button-char ??)))
|
|
2321 ((string-match "-" text) ;we have to contract this node
|
|
2322 (speedbar-change-expand-button-char ?+)
|
|
2323 (speedbar-delete-subblock indent))
|
|
2324 (t (error "Ooops... not sure what to do")))
|
|
2325 (speedbar-center-buffer-smartly))
|
|
2326
|
|
2327 (defun Info-speedbar-fetch-file-nodes (nodespec)
|
|
2328 "Fetch the subnodes from the info NODESPEC.
|
|
2329 NODESPEC is a string of the form: (file)node.
|
|
2330 Optional THISFILE represends the filename of"
|
|
2331 (save-excursion
|
|
2332 ;; Set up a buffer we can use to fake-out Info.
|
|
2333 (set-buffer (get-buffer-create "*info-browse-tmp*"))
|
|
2334 (if (not (equal major-mode 'Info-mode))
|
|
2335 (Info-mode))
|
|
2336 ;; Get the node into this buffer
|
|
2337 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
|
|
2338 (file (match-string 1 nodespec))
|
|
2339 (node (match-string 2 nodespec)))
|
|
2340 (Info-find-node file node))
|
|
2341 ;; Scan the created buffer
|
|
2342 (goto-char (point-min))
|
|
2343 (let ((completions nil)
|
22951
|
2344 (case-fold-search t)
|
22733
|
2345 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
|
|
2346 (match-string 1 nodespec))))
|
|
2347 ;; Always skip the first one...
|
|
2348 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
2349 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
2350 (let ((name (match-string 1)))
|
|
2351 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
|
|
2352 (setq name (cons name (match-string 1)))
|
|
2353 (if (looking-at " *\\(([^)]+)\\)\\.")
|
|
2354 (setq name (cons name (concat (match-string 1) "Top")))
|
|
2355 (if (looking-at " \\([^.]+\\).")
|
|
2356 (setq name
|
|
2357 (cons name (concat "(" thisfile ")" (match-string 1))))
|
|
2358 (setq name (cons name (concat "(" thisfile ")" name))))))
|
|
2359 (setq completions (cons name completions))))
|
|
2360 (nreverse completions))))
|
|
2361
|
|
2362 ;;; Info mode node listing
|
20755
|
2363 (defun Info-speedbar-buttons (buffer)
|
|
2364 "Create a speedbar display to help navigation in an Info file.
|
|
2365 BUFFER is the buffer speedbar is requesting buttons for."
|
22733
|
2366 (if (save-excursion (goto-char (point-min))
|
22951
|
2367 (let ((case-fold-search t))
|
|
2368 (not (looking-at "Info Nodes:"))))
|
22733
|
2369 (erase-buffer))
|
|
2370 (Info-speedbar-hierarchy-buttons nil 0)
|
|
2371 )
|
584
|
2372
|
|
2373 (provide 'info)
|
|
2374
|
660
|
2375 ;;; info.el ends here
|