38412
|
1 ;;; info.el --- info package for Emacs
|
807
|
2
|
45767
|
3 ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
|
36634
|
4 ;; Free Software 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
|
25869
|
32 (eval-when-compile (require 'jka-compr))
|
|
33
|
17430
|
34 (defgroup info nil
|
|
35 "Info subsystem"
|
|
36 :group 'help
|
|
37 :group 'docs)
|
|
38
|
|
39
|
325
|
40 (defvar Info-history nil
|
|
41 "List of info nodes user has visited.
|
|
42 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
|
|
43
|
17430
|
44 (defcustom Info-enable-edit nil
|
3084
|
45 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
|
680
|
46 This is convenient if you want to write info files by hand.
|
|
47 However, we recommend that you not do this.
|
|
48 It is better to write a Texinfo file and generate the Info file from that,
|
17430
|
49 because that gives you a printed manual as well."
|
|
50 :type 'boolean
|
|
51 :group 'info)
|
325
|
52
|
15177
|
53 (defvar Info-enable-active-nodes nil
|
325
|
54 "Non-nil allows Info to execute Lisp code associated with nodes.
|
|
55 The Lisp code is executed when the node is selected.")
|
15177
|
56 (put 'Info-enable-active-nodes 'risky-local-variable t)
|
325
|
57
|
19043
|
58 (defface info-node
|
42455
|
59 '((((class color) (background light)) (:foreground "brown" :weight bold :slant italic))
|
|
60 (((class color) (background dark)) (:foreground "white" :weight bold :slant italic))
|
|
61 (t (:weight bold :slant italic)))
|
19043
|
62 "Face for Info node names."
|
|
63 :group 'info)
|
|
64
|
|
65 (defface info-menu-5
|
26738
407a5a4056e8
(info-node, info-menu-5, info-xref): Define colors for Info faces if
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
66 '((((class color)) (:foreground "red1"))
|
407a5a4056e8
(info-node, info-menu-5, info-xref): Define colors for Info faces if
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
67 (t (:underline t)))
|
46029
|
68 "Face for every third `*' in an Info menu."
|
19043
|
69 :group 'info)
|
|
70
|
|
71 (defface info-xref
|
42455
|
72 '((((class color) (background light)) (:foreground "magenta4" :weight bold))
|
|
73 (((class color) (background dark)) (:foreground "cyan" :weight bold))
|
|
74 (t (:weight bold)))
|
19043
|
75 "Face for Info cross-references."
|
|
76 :group 'info)
|
|
77
|
28168
|
78 (defcustom Info-fontify-maximum-menu-size 100000
|
46029
|
79 "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
|
17430
|
80 :type 'integer
|
|
81 :group 'info)
|
8480
|
82
|
31660
|
83 (defcustom Info-use-header-line t
|
46326
|
84 "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
|
31660
|
85 A header-line does not scroll with the rest of the buffer."
|
|
86 :type 'boolean
|
|
87 :group 'info)
|
|
88
|
|
89 (defface info-header-xref
|
31666
|
90 '((t (:inherit info-xref)))
|
31660
|
91 "Face for Info cross-references in a node header."
|
|
92 :group 'info)
|
|
93
|
|
94 (defface info-header-node
|
32566
|
95 '((t (:inherit info-node)))
|
31660
|
96 "Face for Info nodes in a node header."
|
|
97 :group 'info)
|
|
98
|
25145
|
99 (defvar Info-directory-list nil
|
325
|
100 "List of directories to search for Info documentation files.
|
46252
|
101 If nil, meaning not yet initialized, Info uses the environment
|
1979
|
102 variable INFOPATH to initialize it, or `Info-default-directory-list'
|
7739
|
103 if there is no INFOPATH variable in the environment.
|
31324
|
104
|
|
105 When `Info-directory-list' is initialized from the value of
|
34574
|
106 `Info-default-directory-list', and Emacs is installed in one of the
|
|
107 standard directories, the directory of Info files that come with Emacs
|
|
108 is put last (so that local Info files override standard ones).
|
|
109
|
|
110 When `Info-directory-list' is initialized from the value of
|
|
111 `Info-default-directory-list', and Emacs is not installed in one
|
|
112 of the standard directories, the first element of the resulting
|
31324
|
113 list is the directory where Emacs installs the Info files that
|
|
114 come with it. This is so that Emacs's own manual, which suits the
|
34574
|
115 version of Emacs you are using, will always be found first. This
|
|
116 is useful when you install an experimental version of Emacs without
|
|
117 removing the standard installation.
|
|
118
|
|
119 If you want to override the order of directories in
|
|
120 `Info-default-directory-list', set INFOPATH in the environment.
|
8461
|
121
|
|
122 If you run the Emacs executable from the `src' directory in the Emacs
|
31324
|
123 source tree, and INFOPATH is not defined, the `info' directory in the
|
|
124 source tree is used as the first element of `Info-directory-list', in
|
|
125 place of the installation Info directory. This is useful when you run
|
|
126 a version of Emacs without installing it.")
|
325
|
127
|
17430
|
128 (defcustom Info-additional-directory-list nil
|
8480
|
129 "List of additional directories to search for Info documentation files.
|
37473
|
130 These directories are searched after those in `Info-directory-list', and
|
37351
|
131 they are not searched for merging the `dir' file."
|
17430
|
132 :type '(repeat directory)
|
|
133 :group 'info)
|
8480
|
134
|
34182
|
135 (defcustom Info-scroll-prefer-subnodes t
|
|
136 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
|
|
137 If this is non-nil, and you scroll far enough in a node that its menu
|
|
138 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
|
|
139 moves to a subnode indicated by the following menu item. This means
|
|
140 that you visit a subnode before getting to the end of the menu.
|
|
141
|
|
142 Setting this option to nil results in behavior similar to the stand-alone
|
|
143 Info reader program, which visits the first subnode from the menu only
|
|
144 when you hit the end of the current node."
|
|
145 :type 'boolean
|
|
146 :group 'info)
|
|
147
|
45478
eee4256b91ff
(Info-mode-hook): Change `font-lock-mode' to `turn-on-font-lock'.
Colin Walters <walters@gnu.org>
diff
changeset
|
148 (defcustom Info-mode-hook '(turn-on-font-lock)
|
45458
|
149 "Hooks run when `info-mode' is called."
|
|
150 :type 'hook
|
|
151 :group 'info)
|
|
152
|
325
|
153 (defvar Info-current-file nil
|
12646
|
154 "Info file that Info is now looking at, or nil.
|
|
155 This is the name that was specified in Info, not the actual file name.
|
26004
|
156 It doesn't contain directory names or file name extensions added by Info.
|
|
157 Can also be t when using `Info-on-current-buffer'.")
|
325
|
158
|
|
159 (defvar Info-current-subfile nil
|
29621
|
160 "Info subfile that is actually in the *info* buffer now.
|
|
161 nil if current info file is not split into subfiles.")
|
325
|
162
|
|
163 (defvar Info-current-node nil
|
|
164 "Name of node that Info is now looking at, or nil.")
|
|
165
|
16981
|
166 (defvar Info-tag-table-marker nil
|
325
|
167 "Marker pointing at beginning of current Info file's tag table.
|
|
168 Marker points nowhere if file has no tag table.")
|
|
169
|
16981
|
170 (defvar Info-tag-table-buffer nil
|
|
171 "Buffer used for indirect tag tables.")
|
|
172
|
4410
|
173 (defvar Info-current-file-completions nil
|
|
174 "Cached completion list for current Info file.")
|
|
175
|
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
|
176 (defvar Info-index-alternatives nil
|
29621
|
177 "List of possible matches for last `Info-index' 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
|
178
|
4410
|
179 (defvar Info-standalone nil
|
|
180 "Non-nil if Emacs was started solely as an Info browser.")
|
25145
|
181
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
182 (defvar Info-suffix-list
|
19937
|
183 ;; The MS-DOS list should work both when long file names are
|
|
184 ;; 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
|
185 (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
|
186 '( (".gz" . "gunzip")
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
187 (".z" . "gunzip")
|
34503
|
188 (".bz2" . ("bzip2" "-dc"))
|
19937
|
189 (".inz" . "gunzip")
|
|
190 (".igz" . "gunzip")
|
|
191 (".info.Z" . "gunzip")
|
|
192 (".info.gz" . "gunzip")
|
|
193 ("-info.Z" . "gunzip")
|
|
194 ("-info.gz" . "gunzip")
|
|
195 ("/index.gz". "gunzip")
|
|
196 ("/index.z" . "gunzip")
|
13004
|
197 (".inf" . nil)
|
19937
|
198 (".info" . nil)
|
|
199 ("-info" . nil)
|
|
200 ("/index" . nil)
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
201 ("" . nil))
|
17941
|
202 '( (".info.Z". "uncompress")
|
|
203 (".info.Y". "unyabba")
|
|
204 (".info.gz". "gunzip")
|
|
205 (".info.z". "gunzip")
|
34503
|
206 (".info.bz2" . ("bzip2" "-dc"))
|
17941
|
207 (".info". nil)
|
|
208 ("-info.Z". "uncompress")
|
|
209 ("-info.Y". "unyabba")
|
|
210 ("-info.gz". "gunzip")
|
34503
|
211 ("-info.bz2" . ("bzip2" "-dc"))
|
17941
|
212 ("-info.z". "gunzip")
|
|
213 ("-info". nil)
|
|
214 ("/index.Z". "uncompress")
|
|
215 ("/index.Y". "unyabba")
|
|
216 ("/index.gz". "gunzip")
|
|
217 ("/index.z". "gunzip")
|
34503
|
218 ("/index.bz2". ("bzip2" "-dc"))
|
17941
|
219 ("/index". nil)
|
|
220 (".Z". "uncompress")
|
|
221 (".Y". "unyabba")
|
|
222 (".gz". "gunzip")
|
|
223 (".z". "gunzip")
|
34503
|
224 (".bz2" . ("bzip2" "-dc"))
|
17941
|
225 ("". 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
|
226 "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
|
227 Each entry should be (SUFFIX . STRING); the file is given to
|
34503
|
228 the command as standard input.
|
|
229
|
|
230 STRING may be a list of strings. In that case, the first element is
|
|
231 the command name, and the rest are arguments to that command.
|
|
232
|
|
233 If STRING is nil, no decoding is done.
|
6566
|
234 Because the SUFFIXes are tried in order, the empty string should
|
|
235 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
|
236
|
13562
|
237 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
|
36452
|
238 ;; First, on MS-DOS with no long file names support, delete some of
|
|
239 ;; the extension in FILENAME to make room.
|
|
240 (defun info-insert-file-contents-1 (filename suffix lfn)
|
|
241 (if lfn ; long file names are supported
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
242 (concat filename suffix)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
243 (let* ((sans-exts (file-name-sans-extension filename))
|
13562
|
244 ;; How long is the extension in FILENAME (not counting the dot).
|
|
245 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
|
|
246 ext-left)
|
13004
|
247 ;; SUFFIX starts with a dot. If FILENAME already has one,
|
14577
|
248 ;; get rid of the one in SUFFIX (unless suffix is empty).
|
13562
|
249 (or (and (<= ext-len 0)
|
13004
|
250 (not (eq (aref filename (1- (length filename))) ?.)))
|
14577
|
251 (= (length suffix) 0)
|
13004
|
252 (setq suffix (substring suffix 1)))
|
13562
|
253 ;; How many chars of that extension should we keep?
|
|
254 (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
|
255 ;; 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
|
256 (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
|
257 (- 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
|
258 suffix))))
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
259
|
22067
|
260 (defun info-file-exists-p (filename)
|
|
261 (and (file-exists-p filename)
|
|
262 (not (file-directory-p filename))))
|
|
263
|
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
|
264 (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
|
265 "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
|
266 Do the right thing if the file has been compressed or zipped."
|
36452
|
267 (let* ((tail Info-suffix-list)
|
|
268 (lfn (or (not (fboundp 'msdos-long-file-names))
|
|
269 (msdos-long-file-names)))
|
|
270 (check-short (and (fboundp 'msdos-long-file-names)
|
|
271 lfn))
|
|
272 fullname decoder done)
|
38679
|
273 (if (info-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
|
274 ;; 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
|
275 ;; If so, set DECODE accordingly.
|
6566
|
276 (progn
|
|
277 (while (and tail
|
|
278 (not (string-match
|
|
279 (concat (regexp-quote (car (car tail))) "$")
|
|
280 filename)))
|
|
281 (setq tail (cdr tail)))
|
|
282 (setq fullname filename
|
|
283 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
|
284 ;; Try adding suffixes to FILENAME and see if we can find something.
|
36452
|
285 (while (and tail (not done))
|
|
286 (setq fullname (info-insert-file-contents-1 filename
|
|
287 (car (car tail)) lfn))
|
|
288 (if (info-file-exists-p fullname)
|
|
289 (setq done t
|
|
290 ;; If we found a file with a suffix, set DECODER
|
|
291 ;; according to the suffix.
|
|
292 decoder (cdr (car tail)))
|
|
293 ;; When the MS-DOS port runs on Windows, we need to check
|
|
294 ;; the short variant of a long file name as well.
|
|
295 (when check-short
|
|
296 (setq fullname (info-insert-file-contents-1 filename
|
|
297 (car (car tail)) nil))
|
|
298 (if (info-file-exists-p fullname)
|
|
299 (setq done t
|
|
300 decoder (cdr (car tail))))))
|
6566
|
301 (setq tail (cdr tail)))
|
|
302 (or tail
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
303 (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
|
304 ;; 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
|
305 (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
|
306 (jka-compr-installed-p)
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
307 (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
|
308 (setq decoder nil))
|
6566
|
309 (if decoder
|
19937
|
310 (progn
|
|
311 (insert-file-contents-literally fullname visit)
|
|
312 (let ((buffer-read-only nil)
|
|
313 (coding-system-for-write 'no-conversion)
|
|
314 (default-directory (or (file-name-directory fullname)
|
|
315 default-directory)))
|
34503
|
316 (or (consp decoder)
|
|
317 (setq decoder (list decoder)))
|
|
318 (apply 'call-process-region (point-min) (point-max)
|
|
319 (car decoder) t t nil (cdr decoder))))
|
19937
|
320 (insert-file-contents fullname visit))))
|
25145
|
321
|
|
322 (defun info-initialize ()
|
29621
|
323 "Initialize `Info-directory-list', if that hasn't been done yet."
|
25145
|
324 (unless Info-directory-list
|
|
325 (let ((path (getenv "INFOPATH"))
|
|
326 (source (expand-file-name "info/" source-directory))
|
|
327 (sibling (if installation-directory
|
35864
|
328 (expand-file-name "info/" installation-directory)
|
35934
|
329 (if invocation-directory
|
35864
|
330 (let ((infodir (expand-file-name
|
|
331 "../info/"
|
|
332 invocation-directory)))
|
|
333 (if (file-exists-p infodir)
|
|
334 infodir
|
|
335 (setq infodir (expand-file-name
|
|
336 "../../../info/"
|
|
337 invocation-directory))
|
|
338 (and (file-exists-p infodir)
|
|
339 infodir))))))
|
25145
|
340 alternative)
|
|
341 (setq Info-directory-list
|
30020
|
342 (prune-directory-list
|
|
343 (if path
|
|
344 (split-string path (regexp-quote path-separator))
|
|
345 (if (and sibling (file-exists-p sibling))
|
|
346 ;; Uninstalled, Emacs builddir != srcdir.
|
|
347 (setq alternative sibling)
|
|
348 ;; Uninstalled, builddir == srcdir
|
|
349 (setq alternative source))
|
|
350 (if (or (member alternative Info-default-directory-list)
|
|
351 ;; On DOS/NT, we use movable executables always,
|
|
352 ;; and we must always find the Info dir at run time.
|
|
353 (if (memq system-type '(ms-dos windows-nt))
|
|
354 nil
|
|
355 ;; Use invocation-directory for Info
|
|
356 ;; only if we used it for exec-directory also.
|
|
357 (not (string= exec-directory
|
|
358 (expand-file-name "lib-src/"
|
|
359 installation-directory))))
|
|
360 (not (file-exists-p alternative)))
|
|
361 Info-default-directory-list
|
|
362 ;; `alternative' contains the Info files that came with this
|
|
363 ;; version, so we should look there first. `Info-insert-dir'
|
|
364 ;; currently expects to find `alternative' first on the list.
|
|
365 (cons alternative
|
|
366 (reverse (cdr (reverse Info-default-directory-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
|
367
|
22471
|
368 ;;;###autoload
|
|
369 (defun info-other-window (&optional file)
|
|
370 "Like `info' but show the Info buffer in another window."
|
|
371 (interactive (if current-prefix-arg
|
|
372 (list (read-file-name "Info file name: " nil nil t))))
|
|
373 (let (same-window-buffer-names)
|
|
374 (info file)))
|
28943
|
375
|
10978
|
376 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
|
10957
|
377
|
|
378 ;;;###autoload
|
325
|
379 (defun info (&optional file)
|
|
380 "Enter Info, the documentation browser.
|
|
381 Optional argument FILE specifies the file to examine;
|
|
382 the default is the top-level directory of Info.
|
25311
|
383 Called from a program, FILE may specify an Info node of the form
|
|
384 `(FILENAME)NODENAME'.
|
325
|
385
|
|
386 In interactive use, a prefix argument directs this command
|
14529
|
387 to read a file name from the minibuffer.
|
|
388
|
|
389 The search path for Info files is in the variable `Info-directory-list'.
|
28943
|
390 The top-level Info directory is made by combining all the files named `dir'
|
14529
|
391 in all the directories in that path."
|
325
|
392 (interactive (if current-prefix-arg
|
|
393 (list (read-file-name "Info file name: " nil nil t))))
|
|
394 (if file
|
23175
|
395 (progn
|
|
396 (pop-to-buffer "*info*")
|
|
397 ;; If argument already contains parentheses, don't add another set
|
|
398 ;; since the argument will then be parsed improperly. This also
|
|
399 ;; has the added benefit of allowing node names to be included
|
|
400 ;; following the parenthesized filename.
|
|
401 (if (and (stringp file) (string-match "(.*)" file))
|
|
402 (Info-goto-node file)
|
|
403 (Info-goto-node (concat "(" file ")"))))
|
21704
|
404 (if (get-buffer "*info*")
|
|
405 (pop-to-buffer "*info*")
|
|
406 (Info-directory))))
|
325
|
407
|
4410
|
408 ;;;###autoload
|
46326
|
409 (defun info-emacs-manual ()
|
|
410 (interactive)
|
|
411 (info "emacs"))
|
|
412
|
|
413 ;;;###autoload
|
4410
|
414 (defun info-standalone ()
|
|
415 "Run Emacs as a standalone Info reader.
|
|
416 Usage: emacs -f info-standalone [filename]
|
|
417 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
|
|
418 (setq Info-standalone t)
|
|
419 (if (and command-line-args-left
|
|
420 (not (string-match "^-" (car command-line-args-left))))
|
|
421 (condition-case err
|
|
422 (progn
|
|
423 (info (car command-line-args-left))
|
|
424 (setq command-line-args-left (cdr command-line-args-left)))
|
|
425 (error (send-string-to-terminal
|
|
426 (format "%s\n" (if (eq (car-safe err) 'error)
|
|
427 (nth 1 err) err)))
|
|
428 (save-buffers-kill-emacs)))
|
|
429 (info)))
|
25145
|
430
|
31942
|
431 ;; See if the accessible portion of the buffer begins with a node
|
23923
|
432 ;; delimiter, and the node header line which follows matches REGEXP.
|
|
433 ;; Typically, this test will be followed by a loop that examines the
|
|
434 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
|
|
435 ;; to have the overhead of this special test inside the loop.
|
|
436
|
|
437 ;; This function changes match-data, but supposedly the caller might
|
|
438 ;; want to use the results of re-search-backward.
|
|
439
|
|
440 ;; The return value is the value of point at the beginning of matching
|
31942
|
441 ;; REGEXP, if the function succeeds, nil otherwise.
|
23923
|
442 (defun Info-node-at-bob-matching (regexp)
|
29446
|
443 (and (bobp) ; are we at beginning of buffer?
|
|
444 (looking-at "\^_") ; does it begin with node delimiter?
|
23923
|
445 (let (beg)
|
|
446 (forward-line 1)
|
|
447 (setq beg (point))
|
29446
|
448 (forward-line 1) ; does the line after delimiter match REGEXP?
|
23923
|
449 (re-search-backward regexp beg t))))
|
|
450
|
325
|
451 (defun Info-find-node (filename nodename &optional no-going-back)
|
29621
|
452 "Go to an info node specified as separate FILENAME and NODENAME.
|
|
453 NO-GOING-BACK is non-nil if recovering from an error in this function;
|
|
454 it says do not attempt further (recursive) error recovery."
|
25172
|
455 (info-initialize)
|
325
|
456 ;; Convert filename to lower case if not found as specified.
|
|
457 ;; Expand it.
|
26004
|
458 (if (stringp filename)
|
325
|
459 (let (temp temp-downcase found)
|
22692
|
460 (setq filename (substitute-in-file-name filename))
|
|
461 (if (string= (downcase filename) "dir")
|
|
462 (setq found t)
|
|
463 (let ((dirs (if (string-match "^\\./" filename)
|
|
464 ;; If specified name starts with `./'
|
|
465 ;; then just try current directory.
|
|
466 '("./")
|
|
467 (if (file-name-absolute-p filename)
|
|
468 ;; No point in searching for an
|
|
469 ;; absolute file name
|
|
470 '(nil)
|
|
471 (if Info-additional-directory-list
|
|
472 (append Info-directory-list
|
|
473 Info-additional-directory-list)
|
|
474 Info-directory-list)))))
|
|
475 ;; Search the directory list for file FILENAME.
|
|
476 (while (and dirs (not found))
|
|
477 (setq temp (expand-file-name filename (car dirs)))
|
|
478 (setq temp-downcase
|
|
479 (expand-file-name (downcase filename) (car dirs)))
|
|
480 ;; Try several variants of specified name.
|
36452
|
481 (let ((suffix-list Info-suffix-list)
|
|
482 (lfn (or (not (fboundp 'msdos-long-file-names))
|
|
483 (msdos-long-file-names))))
|
22692
|
484 (while (and suffix-list (not found))
|
|
485 (cond ((info-file-exists-p
|
|
486 (info-insert-file-contents-1
|
36452
|
487 temp (car (car suffix-list)) lfn))
|
22692
|
488 (setq found temp))
|
|
489 ((info-file-exists-p
|
|
490 (info-insert-file-contents-1
|
36452
|
491 temp-downcase (car (car suffix-list)) lfn))
|
|
492 (setq found temp-downcase))
|
|
493 ((and (fboundp 'msdos-long-file-names)
|
|
494 lfn
|
|
495 (info-file-exists-p
|
|
496 (info-insert-file-contents-1
|
|
497 temp (car (car suffix-list)) nil)))
|
|
498 (setq found temp)))
|
22692
|
499 (setq suffix-list (cdr suffix-list))))
|
|
500 (setq dirs (cdr dirs)))))
|
|
501 (if found
|
|
502 (setq filename found)
|
|
503 (error "Info file %s does not exist" filename))))
|
|
504 ;; Record the node we are leaving.
|
|
505 (if (and Info-current-file (not no-going-back))
|
|
506 (setq Info-history
|
|
507 (cons (list Info-current-file Info-current-node (point))
|
|
508 Info-history)))
|
21704
|
509 ;; Go into info buffer.
|
|
510 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
|
26004
|
511 (Info-find-node-2 filename nodename no-going-back))
|
|
512
|
|
513 (defun Info-on-current-buffer (&optional nodename)
|
|
514 "Use the `Info-mode' to browse the current info buffer.
|
|
515 If a prefix arg is provided, it queries for the NODENAME which
|
39459
|
516 else defaults to \"Top\"."
|
26004
|
517 (interactive
|
|
518 (list (if current-prefix-arg
|
|
519 (completing-read "Node name: " (Info-build-node-completions)
|
39459
|
520 nil t "Top"))))
|
|
521 (unless nodename (setq nodename "Top"))
|
29410
|
522 (info-initialize)
|
26004
|
523 (Info-mode)
|
|
524 (set (make-local-variable 'Info-current-file) t)
|
|
525 (Info-find-node-2 nil nodename))
|
|
526
|
29684
|
527 (defun Info-find-in-tag-table-1 (marker regexp case-fold)
|
|
528 "Find a node in a tag table.
|
|
529 MARKER specifies the buffer and position to start searching at.
|
|
530 REGEXP is a regular expression matching nodes or references. Its first
|
|
531 group should match `Node:' or `Ref:'.
|
|
532 CASE-FOLD t means search for a case-insensitive match.
|
|
533 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
|
|
534 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
|
|
535 where the match was found, and MODE is `major-mode' of the buffer in
|
|
536 which the match was found."
|
|
537 (let ((case-fold-search case-fold)
|
|
538 found-mode guesspos found-anchor)
|
|
539 (save-excursion
|
|
540 (set-buffer (marker-buffer marker))
|
|
541 (goto-char marker)
|
|
542
|
|
543 ;; Search tag table
|
|
544 (beginning-of-line)
|
|
545 (when (re-search-forward regexp nil t)
|
|
546 (list (string-equal "Ref:" (match-string 1))
|
45014
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
547 (+ (point-min) (read (current-buffer)))
|
29684
|
548 major-mode)))))
|
|
549
|
|
550 (defun Info-find-in-tag-table (marker regexp)
|
|
551 "Find a node in a tag table.
|
|
552 MARKER specifies the buffer and position to start searching at.
|
|
553 REGEXP is a regular expression matching nodes or references. Its first
|
|
554 group should match `Node:' or `Ref:'.
|
|
555 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
|
|
556 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
|
|
557 where the match was found, and MODE is `major-mode' of the buffer in
|
|
558 which the match was found.
|
|
559 This function tries to find a case-sensitive match first, then a
|
|
560 case-insensitive match is tried."
|
|
561 (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
|
|
562 (when (null (car result))
|
|
563 (setq result (Info-find-in-tag-table-1 marker regexp t)))
|
|
564 result))
|
|
565
|
|
566 (defun Info-find-node-in-buffer-1 (regexp case-fold)
|
|
567 "Find a node or anchor in the current buffer.
|
|
568 REGEXP is a regular expression matching nodes or references. Its first
|
|
569 group should match `Node:' or `Ref:'.
|
|
570 CASE-FOLD t means search for a case-insensitive match.
|
|
571 Value is the position at which a match was found, or nil if not found."
|
|
572 (let ((case-fold-search case-fold)
|
|
573 found)
|
|
574 (save-excursion
|
|
575 (when (Info-node-at-bob-matching regexp)
|
|
576 (setq found (point)))
|
|
577 (while (and (not found)
|
|
578 (search-forward "\n\^_" nil t))
|
|
579 (forward-line 1)
|
|
580 (let ((beg (point)))
|
|
581 (forward-line 1)
|
|
582 (when (re-search-backward regexp beg t)
|
|
583 (beginning-of-line)
|
|
584 (setq found (point)))))
|
|
585 found)))
|
|
586
|
|
587 (defun Info-find-node-in-buffer (regexp)
|
|
588 "Find a node or anchor in the current buffer.
|
|
589 REGEXP is a regular expression matching nodes or references. Its first
|
|
590 group should match `Node:' or `Ref:'.
|
|
591 Value is the position at which a match was found, or nil if not found.
|
|
592 This function looks for a case-sensitive match first. If none is found,
|
|
593 a case-insensitive match is tried."
|
|
594 (or (Info-find-node-in-buffer-1 regexp nil)
|
|
595 (Info-find-node-in-buffer-1 regexp t)))
|
|
596
|
26004
|
597 (defun Info-find-node-2 (filename nodename &optional no-going-back)
|
21704
|
598 (buffer-disable-undo (current-buffer))
|
|
599 (or (eq major-mode 'Info-mode)
|
|
600 (Info-mode))
|
325
|
601 (widen)
|
|
602 (setq Info-current-node nil)
|
|
603 (unwind-protect
|
24632
|
604 (let ((case-fold-search t)
|
|
605 anchorpos)
|
22692
|
606 ;; Switch files if necessary
|
|
607 (or (null filename)
|
|
608 (equal Info-current-file filename)
|
|
609 (let ((buffer-read-only nil))
|
|
610 (setq Info-current-file nil
|
|
611 Info-current-subfile nil
|
|
612 Info-current-file-completions nil
|
|
613 buffer-file-name nil)
|
|
614 (erase-buffer)
|
|
615 (if (eq filename t)
|
|
616 (Info-insert-dir)
|
41713
d53ece895385
(Info-find-node-2): Don't call info-insert-file-contents
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
617 (info-insert-file-contents filename nil)
|
22692
|
618 (setq default-directory (file-name-directory filename)))
|
|
619 (set-buffer-modified-p nil)
|
|
620 ;; See whether file has a tag table. Record the location if yes.
|
|
621 (goto-char (point-max))
|
|
622 (forward-line -8)
|
|
623 ;; Use string-equal, not equal, to ignore text props.
|
|
624 (if (not (or (string-equal nodename "*")
|
|
625 (not
|
|
626 (search-forward "\^_\nEnd tag table\n" nil t))))
|
|
627 (let (pos)
|
|
628 ;; We have a tag table. Find its beginning.
|
|
629 ;; Is this an indirect file?
|
|
630 (search-backward "\nTag table:\n")
|
|
631 (setq pos (point))
|
|
632 (if (save-excursion
|
|
633 (forward-line 2)
|
|
634 (looking-at "(Indirect)\n"))
|
|
635 ;; It is indirect. Copy it to another buffer
|
|
636 ;; and record that the tag table is in that buffer.
|
|
637 (let ((buf (current-buffer))
|
|
638 (tagbuf
|
|
639 (or Info-tag-table-buffer
|
|
640 (generate-new-buffer " *info tag table*"))))
|
|
641 (setq Info-tag-table-buffer tagbuf)
|
|
642 (save-excursion
|
|
643 (set-buffer tagbuf)
|
1484
|
644 (buffer-disable-undo (current-buffer))
|
22692
|
645 (setq case-fold-search t)
|
|
646 (erase-buffer)
|
|
647 (insert-buffer-substring buf))
|
|
648 (set-marker Info-tag-table-marker
|
|
649 (match-end 0) tagbuf))
|
|
650 (set-marker Info-tag-table-marker pos)))
|
|
651 (set-marker Info-tag-table-marker nil))
|
|
652 (setq Info-current-file
|
|
653 (if (eq filename t) "dir" filename))))
|
|
654 ;; Use string-equal, not equal, to ignore text props.
|
|
655 (if (string-equal nodename "*")
|
|
656 (progn (setq Info-current-node nodename)
|
|
657 (Info-set-mode-line))
|
|
658 ;; Possibilities:
|
|
659 ;;
|
|
660 ;; 1. Anchor found in tag table
|
|
661 ;; 2. Anchor *not* in tag table
|
|
662 ;;
|
|
663 ;; 3. Node found in tag table
|
|
664 ;; 4. Node *not* found in tag table, but found in file
|
|
665 ;; 5. Node *not* in tag table, and *not* in file
|
|
666 ;;
|
|
667 ;; *Or* the same, but in an indirect subfile.
|
|
668
|
|
669 ;; Search file for a suitable node.
|
24632
|
670 (let ((guesspos (point-min))
|
29684
|
671 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
672 (if (stringp nodename)
|
30686
|
673 (regexp-quote nodename)
|
|
674 "")
|
29684
|
675 "\\) *[,\t\n\177]"))
|
24632
|
676 (nodepos nil))
|
22692
|
677
|
29164
|
678 (catch 'foo
|
29684
|
679
|
29164
|
680 ;; First, search a tag table, if any
|
29684
|
681 (when (marker-position Info-tag-table-marker)
|
|
682 (let* ((m Info-tag-table-marker)
|
|
683 (found (Info-find-in-tag-table m regexp)))
|
|
684
|
|
685 (when found
|
|
686 ;; FOUND is (ANCHOR POS MODE).
|
|
687 (setq guesspos (nth 1 found))
|
|
688
|
|
689 ;; If this is an indirect file, determine which
|
|
690 ;; file really holds this node and read it in.
|
|
691 (unless (eq (nth 2 found) 'Info-mode)
|
|
692 ;; Note that the current buffer must be the
|
|
693 ;; *info* buffer on entry to
|
|
694 ;; Info-read-subfile. Thus the hackery above.
|
|
695 (setq guesspos (Info-read-subfile guesspos)))
|
29164
|
696
|
|
697 ;; Handle anchor
|
29684
|
698 (when (nth 0 found)
|
|
699 (goto-char (setq anchorpos guesspos))
|
|
700 (throw 'foo t)))))
|
29164
|
701
|
|
702 ;; Else we may have a node, which we search for:
|
|
703 (goto-char (max (point-min)
|
|
704 (- (byte-to-position guesspos) 1000)))
|
29684
|
705
|
|
706 ;; Now search from our advised position (or from beg of
|
|
707 ;; buffer) to find the actual node. First, check
|
|
708 ;; whether the node is right where we are, in case the
|
|
709 ;; buffer begins with a node.
|
|
710 (let ((pos (Info-find-node-in-buffer regexp)))
|
|
711 (when pos
|
|
712 (goto-char pos)
|
|
713 (throw 'foo t))
|
|
714 (error "No such anchor in tag table or node in tag table or file: %s"
|
|
715 nodename)))
|
29164
|
716
|
|
717 (Info-select-node)
|
|
718 (goto-char (or anchorpos (point-min))))))
|
325
|
719 ;; If we did not finish finding the specified node,
|
|
720 ;; go back to the previous one.
|
6716
|
721 (or Info-current-node no-going-back (null Info-history)
|
22692
|
722 (let ((hist (car Info-history)))
|
|
723 (setq Info-history (cdr Info-history))
|
|
724 (Info-find-node (nth 0 hist) (nth 1 hist) t)
|
|
725 (goto-char (nth 2 hist))))))
|
325
|
726
|
1979
|
727 ;; Cache the contents of the (virtual) dir file, once we have merged
|
|
728 ;; it for the first time, so we can save time subsequently.
|
1971
|
729 (defvar Info-dir-contents nil)
|
|
730
|
1979
|
731 ;; Cache for the directory we decided to use for the default-directory
|
|
732 ;; of the merged dir text.
|
|
733 (defvar Info-dir-contents-directory nil)
|
|
734
|
3836
|
735 ;; Record the file attributes of all the files from which we
|
|
736 ;; constructed Info-dir-contents.
|
|
737 (defvar Info-dir-file-attributes nil)
|
|
738
|
23416
|
739 (defvar Info-dir-file-name nil)
|
|
740
|
1971
|
741 ;; Construct the Info directory node by merging the files named `dir'
|
1979
|
742 ;; from various directories. Set the *info* buffer's
|
|
743 ;; default-directory to the first directory we actually get any text
|
|
744 ;; from.
|
1971
|
745 (defun Info-insert-dir ()
|
3836
|
746 (if (and Info-dir-contents Info-dir-file-attributes
|
|
747 ;; Verify that none of the files we used has changed
|
|
748 ;; since we used it.
|
|
749 (eval (cons 'and
|
29583
|
750 (mapcar (lambda (elt)
|
|
751 (let ((curr (file-attributes
|
|
752 ;; Handle symlinks
|
|
753 (file-truename (car elt)))))
|
28943
|
754
|
29583
|
755 ;; Don't compare the access time.
|
|
756 (if curr (setcar (nthcdr 4 curr) 0))
|
|
757 (setcar (nthcdr 4 (cdr elt)) 0)
|
|
758 (equal (cdr elt) curr)))
|
3836
|
759 Info-dir-file-attributes))))
|
23416
|
760 (progn
|
|
761 (insert Info-dir-contents)
|
|
762 (goto-char (point-min)))
|
30686
|
763 (let ((dirs (if Info-additional-directory-list
|
46139
|
764 (append Info-directory-list
|
|
765 Info-additional-directory-list)
|
|
766 Info-directory-list))
|
22951
|
767 ;; Bind this in case the user sets it to nil.
|
|
768 (case-fold-search t)
|
23416
|
769 ;; This is set non-nil if we find a problem in some input files.
|
|
770 problems
|
3212
|
771 buffers buffer others nodes dirs-done)
|
1979
|
772
|
7911
|
773 (setq Info-dir-file-attributes nil)
|
|
774
|
1979
|
775 ;; Search the directory list for the directory file.
|
1971
|
776 (while dirs
|
5271
|
777 (let ((truename (file-truename (expand-file-name (car dirs)))))
|
|
778 (or (member truename dirs-done)
|
|
779 (member (directory-file-name truename) dirs-done)
|
|
780 ;; Try several variants of specified name.
|
|
781 ;; Try upcasing, appending `.info', or both.
|
7911
|
782 (let* (file
|
|
783 (attrs
|
|
784 (or
|
|
785 (progn (setq file (expand-file-name "dir" truename))
|
|
786 (file-attributes file))
|
|
787 (progn (setq file (expand-file-name "DIR" truename))
|
|
788 (file-attributes file))
|
|
789 (progn (setq file (expand-file-name "dir.info" truename))
|
|
790 (file-attributes file))
|
|
791 (progn (setq file (expand-file-name "DIR.INFO" truename))
|
|
792 (file-attributes file)))))
|
5271
|
793 (setq dirs-done
|
|
794 (cons truename
|
|
795 (cons (directory-file-name truename)
|
|
796 dirs-done)))
|
7911
|
797 (if attrs
|
|
798 (save-excursion
|
|
799 (or buffers
|
|
800 (message "Composing main Info directory..."))
|
20421
|
801 (set-buffer (generate-new-buffer " info dir"))
|
22863
|
802 (condition-case nil
|
|
803 (progn
|
|
804 (insert-file-contents file)
|
23416
|
805 (make-local-variable 'Info-dir-file-name)
|
|
806 (setq Info-dir-file-name file)
|
22863
|
807 (setq buffers (cons (current-buffer) buffers)
|
|
808 Info-dir-file-attributes
|
|
809 (cons (cons file attrs)
|
|
810 Info-dir-file-attributes)))
|
|
811 (error (kill-buffer (current-buffer))))))))
|
16462
|
812 (or (cdr dirs) (setq Info-dir-contents-directory
|
|
813 (file-name-as-directory (car dirs))))
|
7911
|
814 (setq dirs (cdr dirs))))
|
28943
|
815
|
6716
|
816 (or buffers
|
14664
|
817 (error "Can't find the Info directory node"))
|
1979
|
818 ;; Distinguish the dir file that comes with Emacs from all the
|
3212
|
819 ;; others. Yes, that is really what this is supposed to do.
|
24513
|
820 ;; The definition of `Info-directory-list' puts it first on that
|
|
821 ;; list and so last in `buffers' at this point.
|
|
822 (setq buffer (car (last buffers))
|
|
823 others (delq buffer buffers))
|
1979
|
824
|
15304
|
825 ;; Insert the entire original dir file as a start; note that we've
|
|
826 ;; already saved its default directory to use as the default
|
|
827 ;; directory for the whole concatenation.
|
1971
|
828 (insert-buffer buffer)
|
1979
|
829
|
1971
|
830 ;; Look at each of the other buffers one by one.
|
|
831 (while others
|
23416
|
832 (let ((other (car others))
|
29446
|
833 ;; Bind this in case the user sets it to nil.
|
|
834 (case-fold-search t)
|
23416
|
835 this-buffer-nodes)
|
1971
|
836 ;; In each, find all the menus.
|
|
837 (save-excursion
|
|
838 (set-buffer other)
|
|
839 (goto-char (point-min))
|
|
840 ;; Find each menu, and add an elt to NODES for it.
|
|
841 (while (re-search-forward "^\\* Menu:" nil t)
|
|
842 (let (beg nodename end)
|
|
843 (forward-line 1)
|
33133
e3d7bf8b5a51
(Info-insert-dir): Don't include blank lines at beginning of additional
Miles Bader <miles@gnu.org>
diff
changeset
|
844 (while (and (eolp) (not (eobp)))
|
e3d7bf8b5a51
(Info-insert-dir): Don't include blank lines at beginning of additional
Miles Bader <miles@gnu.org>
diff
changeset
|
845 (forward-line 1))
|
1971
|
846 (setq beg (point))
|
23904
|
847 (or (search-backward "\n\^_" nil 'move)
|
|
848 (looking-at "\^_")
|
|
849 (signal 'search-failed (list "\n\^_")))
|
1971
|
850 (search-forward "Node: ")
|
|
851 (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
|
852 (search-forward "\n\^_" nil 'move)
|
1971
|
853 (beginning-of-line)
|
|
854 (setq end (point))
|
23416
|
855 (setq this-buffer-nodes
|
|
856 (cons (list nodename other beg end)
|
|
857 this-buffer-nodes))))
|
|
858 (if (assoc-ignore-case "top" this-buffer-nodes)
|
|
859 (setq nodes (nconc this-buffer-nodes nodes))
|
|
860 (setq problems t)
|
|
861 (message "No `top' node in %s" Info-dir-file-name))))
|
1971
|
862 (setq others (cdr others)))
|
29621
|
863 ;; Add to the main menu a menu item for each other node.
|
|
864 (let ((case-fold-search t)
|
29446
|
865 (re-search-forward "^\\* Menu:")))
|
1971
|
866 (forward-line 1)
|
|
867 (let ((menu-items '("top"))
|
|
868 (nodes nodes)
|
|
869 (case-fold-search t)
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
870 (end (save-excursion (search-forward "\^_" nil t) (point))))
|
1971
|
871 (while nodes
|
|
872 (let ((nodename (car (car nodes))))
|
6537
|
873 (save-excursion
|
|
874 (or (member (downcase nodename) menu-items)
|
21641
|
875 (re-search-forward (concat "^\\* +"
|
6537
|
876 (regexp-quote nodename)
|
|
877 "::")
|
|
878 end t)
|
|
879 (progn
|
|
880 (insert "* " nodename "::" "\n")
|
|
881 (setq menu-items (cons nodename menu-items))))))
|
1971
|
882 (setq nodes (cdr nodes))))
|
|
883 ;; Now take each node of each of the other buffers
|
|
884 ;; and merge it into the main buffer.
|
|
885 (while nodes
|
29446
|
886 (let ((case-fold-search t)
|
|
887 (nodename (car (car nodes))))
|
1971
|
888 (goto-char (point-min))
|
|
889 ;; Find the like-named node in the main buffer.
|
23904
|
890 (if (re-search-forward (concat "^\^_.*\n.*Node: "
|
1971
|
891 (regexp-quote nodename)
|
|
892 "[,\n\t]")
|
|
893 nil t)
|
|
894 (progn
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
895 (search-forward "\n\^_" nil 'move)
|
8913
|
896 (beginning-of-line)
|
|
897 (insert "\n"))
|
1971
|
898 ;; If none exists, add one.
|
|
899 (goto-char (point-max))
|
8069
|
900 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
|
1971
|
901 ;; Merge the text from the other buffer's menu
|
|
902 ;; into the menu in the like-named node in the main buffer.
|
8913
|
903 (apply 'insert-buffer-substring (cdr (car nodes))))
|
1971
|
904 (setq nodes (cdr nodes)))
|
|
905 ;; Kill all the buffers we just made.
|
|
906 (while buffers
|
|
907 (kill-buffer (car buffers))
|
7911
|
908 (setq buffers (cdr buffers)))
|
23416
|
909 (goto-char (point-min))
|
|
910 (if problems
|
|
911 (message "Composing main Info directory...problems encountered, see `*Messages*'")
|
|
912 (message "Composing main Info directory...done")))
|
1979
|
913 (setq Info-dir-contents (buffer-string)))
|
|
914 (setq default-directory Info-dir-contents-directory))
|
1971
|
915
|
16981
|
916 ;; Note that on entry to this function the current-buffer must be the
|
|
917 ;; *info* buffer; not the info tags buffer.
|
325
|
918 (defun Info-read-subfile (nodepos)
|
16399
|
919 ;; NODEPOS is either a position (in the Info file as a whole,
|
|
920 ;; not relative to a subfile) or the name of a subfile.
|
325
|
921 (let (lastfilepos
|
|
922 lastfilename)
|
16399
|
923 (if (numberp nodepos)
|
|
924 (save-excursion
|
|
925 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
926 (goto-char (point-min))
|
23904
|
927 (or (looking-at "\^_")
|
|
928 (search-forward "\n\^_"))
|
16399
|
929 (forward-line 2)
|
|
930 (catch 'foo
|
|
931 (while (not (looking-at "\^_"))
|
|
932 (if (not (eolp))
|
|
933 (let ((beg (point))
|
|
934 thisfilepos thisfilename)
|
|
935 (search-forward ": ")
|
|
936 (setq thisfilename (buffer-substring beg (- (point) 2)))
|
45014
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
937 (setq thisfilepos (+ (point-min) (read (current-buffer))))
|
16399
|
938 ;; read in version 19 stops at the end of number.
|
|
939 ;; Advance to the next line.
|
|
940 (forward-line 1)
|
|
941 (if (> thisfilepos nodepos)
|
|
942 (throw 'foo t))
|
|
943 (setq lastfilename thisfilename)
|
|
944 (setq lastfilepos thisfilepos))
|
|
945 (forward-line 1)))))
|
|
946 (setq lastfilename nodepos)
|
|
947 (setq lastfilepos 0))
|
16981
|
948 ;; Assume previous buffer is in Info-mode.
|
|
949 ;; (set-buffer (get-buffer "*info*"))
|
325
|
950 (or (equal Info-current-subfile lastfilename)
|
|
951 (let ((buffer-read-only nil))
|
|
952 (setq buffer-file-name nil)
|
|
953 (widen)
|
|
954 (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
|
955 (info-insert-file-contents lastfilename)
|
325
|
956 (set-buffer-modified-p nil)
|
|
957 (setq Info-current-subfile lastfilename)))
|
37837
|
958 ;; Widen in case we are in the same subfile as before.
|
|
959 (widen)
|
325
|
960 (goto-char (point-min))
|
23904
|
961 (if (looking-at "\^_")
|
|
962 (forward-char 1)
|
|
963 (search-forward "\n\^_"))
|
16399
|
964 (if (numberp nodepos)
|
|
965 (+ (- nodepos lastfilepos) (point)))))
|
325
|
966
|
31660
|
967 (defvar Info-header-line nil
|
|
968 "If the info node header is hidden, the text of the header.")
|
44902
|
969 (put 'Info-header-line 'risky-local-variable t)
|
31660
|
970
|
325
|
971 (defun Info-select-node ()
|
29621
|
972 "Select the info node that point is in.
|
|
973 Bind this in case the user sets it to nil."
|
22951
|
974 (let ((case-fold-search t))
|
|
975 (save-excursion
|
29446
|
976 ;; Find beginning of node.
|
|
977 (if (search-backward "\n\^_" nil 'move)
|
|
978 (forward-line 2)
|
|
979 (if (looking-at "\^_")
|
|
980 (forward-line 1)
|
|
981 (signal 'search-failed (list "\n\^_"))))
|
|
982 ;; Get nodename spelled as it is in the node.
|
|
983 (re-search-forward "Node:[ \t]*")
|
|
984 (setq Info-current-node
|
|
985 (buffer-substring-no-properties (point)
|
|
986 (progn
|
|
987 (skip-chars-forward "^,\t\n")
|
|
988 (point))))
|
|
989 (Info-set-mode-line)
|
|
990 ;; Find the end of it, and narrow.
|
|
991 (beginning-of-line)
|
|
992 (let (active-expression)
|
31660
|
993 ;; Narrow to the node contents
|
29446
|
994 (narrow-to-region (point)
|
|
995 (if (re-search-forward "\n[\^_\f]" nil t)
|
|
996 (prog1
|
|
997 (1- (point))
|
|
998 (if (looking-at "[\n\^_\f]*execute: ")
|
|
999 (progn
|
|
1000 (goto-char (match-end 0))
|
|
1001 (setq active-expression
|
|
1002 (read (current-buffer))))))
|
|
1003 (point-max)))
|
|
1004 (if Info-enable-active-nodes (eval active-expression))
|
45458
|
1005 (Info-fontify-node)
|
31660
|
1006 (if Info-use-header-line
|
45775
|
1007 (progn
|
|
1008 (setq Info-header-line
|
|
1009 (get-text-property (point-min) 'header-line))
|
|
1010 (setq header-line-format 'Info-header-line)
|
|
1011 ;;; It is useful to be able to copy the links line out of the buffer
|
|
1012 ;;; with M-w.
|
|
1013 ;;; (narrow-to-region (1+ header-end) (point-max))
|
|
1014 )
|
42241
|
1015 (setq Info-header-line nil)
|
|
1016 (setq header-line-format nil)) ; so the header line isn't displayed
|
29446
|
1017 (run-hooks 'Info-selection-hook)))))
|
325
|
1018
|
|
1019 (defun Info-set-mode-line ()
|
|
1020 (setq mode-line-buffer-identification
|
32538
|
1021 (nconc (propertized-buffer-identification "%b")
|
32533
|
1022 (list
|
|
1023 (concat " ("
|
|
1024 (file-name-nondirectory
|
|
1025 (if (stringp Info-current-file)
|
|
1026 Info-current-file
|
|
1027 (or buffer-file-name "")))
|
|
1028 ") "
|
|
1029 (or Info-current-node ""))))))
|
325
|
1030
|
|
1031 ;; Go to an info node specified with a filename-and-nodename string
|
|
1032 ;; of the sort that is found in pointers in nodes.
|
|
1033
|
26004
|
1034 (defun Info-goto-node (nodename &optional fork)
|
39213
|
1035 "Go to info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
|
39382
|
1036 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
|
|
1037 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
|
|
1038 its sub-files).
|
|
1039 Completion is available, but only for node names in the current Info file.
|
32286
|
1040 If FORK is non-nil (interactively with a prefix arg), show the node in
|
|
1041 a new info buffer.
|
26004
|
1042 If FORK is a string, it is the name to use for the new buffer."
|
32500
|
1043 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
|
25172
|
1044 (info-initialize)
|
26004
|
1045 (if fork
|
29446
|
1046 (set-buffer
|
|
1047 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
|
325
|
1048 (let (filename)
|
|
1049 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
|
|
1050 nodename)
|
|
1051 (setq filename (if (= (match-beginning 1) (match-end 1))
|
|
1052 ""
|
|
1053 (substring nodename (match-beginning 2) (match-end 2)))
|
|
1054 nodename (substring nodename (match-beginning 3) (match-end 3)))
|
|
1055 (let ((trim (string-match "\\s *\\'" filename)))
|
|
1056 (if trim (setq filename (substring filename 0 trim))))
|
|
1057 (let ((trim (string-match "\\s *\\'" nodename)))
|
|
1058 (if trim (setq nodename (substring nodename 0 trim))))
|
12433
|
1059 (if transient-mark-mode (deactivate-mark))
|
325
|
1060 (Info-find-node (if (equal filename "") nil filename)
|
|
1061 (if (equal nodename "") "Top" nodename))))
|
4410
|
1062
|
22760
|
1063 (defvar Info-read-node-completion-table)
|
|
1064
|
12779
|
1065 ;; This function is used as the "completion table" while reading a node name.
|
22760
|
1066 ;; It does completion using the alist in Info-read-node-completion-table
|
12779
|
1067 ;; unless STRING starts with an open-paren.
|
|
1068 (defun Info-read-node-name-1 (string predicate code)
|
45014
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1069 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1070 ;; First complete embedded file names.
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1071 ((string-match "\\`([^)]*\\'" string)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1072 (let ((file (substring string 1)))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1073 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1074 ((eq code nil)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1075 (let ((comp (try-completion file 'locate-file-completion
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1076 (cons Info-directory-list
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1077 (mapcar 'car Info-suffix-list)))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1078 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1079 ((eq comp t) (concat string ")"))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1080 (comp (concat "(" comp)))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1081 ((eq code t) (all-completions file 'locate-file-completion
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1082 (cons Info-directory-list
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1083 (mapcar 'car Info-suffix-list))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1084 (t nil))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1085 ;; If a file name was given, then any node is fair game.
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1086 ((string-match "\\`(" string)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1087 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1088 ((eq code nil) string)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1089 ((eq code t) nil)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1090 (t t)))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1091 ;; Otherwise use Info-read-node-completion-table.
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1092 ((eq code nil)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1093 (try-completion string Info-read-node-completion-table predicate))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1094 ((eq code t)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1095 (all-completions string Info-read-node-completion-table predicate))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1096 (t
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1097 (test-completion string Info-read-node-completion-table predicate))))
|
12779
|
1098
|
4410
|
1099 (defun Info-read-node-name (prompt &optional default)
|
|
1100 (let* ((completion-ignore-case t)
|
22760
|
1101 (Info-read-node-completion-table (Info-build-node-completions))
|
17140
|
1102 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
|
4410
|
1103 (if (equal nodename "")
|
|
1104 (or default
|
|
1105 (Info-read-node-name prompt))
|
|
1106 nodename)))
|
|
1107
|
|
1108 (defun Info-build-node-completions ()
|
|
1109 (or Info-current-file-completions
|
22951
|
1110 (let ((compl nil)
|
|
1111 ;; Bind this in case the user sets it to nil.
|
23923
|
1112 (case-fold-search t)
|
|
1113 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
|
4410
|
1114 (save-excursion
|
|
1115 (save-restriction
|
|
1116 (if (marker-buffer Info-tag-table-marker)
|
16981
|
1117 (let ((marker Info-tag-table-marker))
|
|
1118 (set-buffer (marker-buffer marker))
|
6049
|
1119 (widen)
|
16981
|
1120 (goto-char marker)
|
29621
|
1121 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t)
|
4410
|
1122 (setq compl
|
29621
|
1123 (cons (list (match-string-no-properties 2))
|
4410
|
1124 compl))))
|
|
1125 (widen)
|
|
1126 (goto-char (point-min))
|
23923
|
1127 ;; If the buffer begins with a node header, process that first.
|
|
1128 (if (Info-node-at-bob-matching node-regexp)
|
26580
|
1129 (setq compl (list (match-string-no-properties 1))))
|
23923
|
1130 ;; Now for the rest of the nodes.
|
4410
|
1131 (while (search-forward "\n\^_" nil t)
|
|
1132 (forward-line 1)
|
|
1133 (let ((beg (point)))
|
|
1134 (forward-line 1)
|
23923
|
1135 (if (re-search-backward node-regexp beg t)
|
28943
|
1136 (setq compl
|
26580
|
1137 (cons (list (match-string-no-properties 1))
|
4410
|
1138 compl))))))))
|
26172
|
1139 (setq compl (cons '("*") compl))
|
38407
4569042ee316
(Info-build-node-completions): Make Info-current-file-completions buffer local.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1140 (set (make-local-variable 'Info-current-file-completions) compl))))
|
325
|
1141
|
540
|
1142 (defun Info-restore-point (hl)
|
|
1143 "If this node has been visited, restore the point value when we left."
|
6049
|
1144 (while hl
|
|
1145 (if (and (equal (nth 0 (car hl)) Info-current-file)
|
11527
|
1146 ;; Use string-equal, not equal, to ignore text props.
|
|
1147 (string-equal (nth 1 (car hl)) Info-current-node))
|
6049
|
1148 (progn
|
6121
|
1149 (goto-char (nth 2 (car hl)))
|
|
1150 (setq hl nil)) ;terminate the while at next iter
|
6049
|
1151 (setq hl (cdr hl)))))
|
540
|
1152
|
30109
|
1153 (defvar Info-search-history nil
|
|
1154 "The history list for `Info-search'.")
|
325
|
1155
|
|
1156 (defun Info-search (regexp)
|
|
1157 "Search for REGEXP, starting from point, and select node it's found in."
|
35136
|
1158 (interactive (list (read-string
|
|
1159 (if Info-search-history
|
|
1160 (format "Regexp search (default `%s'): "
|
|
1161 (car Info-search-history))
|
|
1162 "Regexp search: ")
|
|
1163 nil 'Info-search-history)))
|
30109
|
1164 (when transient-mark-mode
|
|
1165 (deactivate-mark))
|
|
1166 (when (equal regexp "")
|
|
1167 (setq regexp (car Info-search-history)))
|
24963
|
1168 (when regexp
|
|
1169 (let ((found ()) current
|
|
1170 (onode Info-current-node)
|
|
1171 (ofile Info-current-file)
|
|
1172 (opoint (point))
|
|
1173 (ostart (window-start))
|
|
1174 (osubfile Info-current-subfile))
|
|
1175 (save-excursion
|
|
1176 (save-restriction
|
|
1177 (widen)
|
|
1178 (if (null Info-current-subfile)
|
325
|
1179 (progn (re-search-forward regexp) (setq found (point)))
|
24963
|
1180 (condition-case err
|
|
1181 (progn (re-search-forward regexp) (setq found (point)))
|
|
1182 (search-failed nil)))))
|
29446
|
1183 (if (not found) ;can only happen in subfile case -- else would have erred
|
24963
|
1184 (unwind-protect
|
|
1185 (let ((list ()))
|
|
1186 (save-excursion
|
|
1187 (set-buffer (marker-buffer Info-tag-table-marker))
|
16981
|
1188 (goto-char (point-min))
|
24963
|
1189 (search-forward "\n\^_\nIndirect:")
|
|
1190 (save-restriction
|
|
1191 (narrow-to-region (point)
|
|
1192 (progn (search-forward "\n\^_")
|
|
1193 (1- (point))))
|
|
1194 (goto-char (point-min))
|
47327
|
1195 ;; Find the subfile we just searched.
|
24963
|
1196 (search-forward (concat "\n" osubfile ": "))
|
47327
|
1197 ;; Skip that one.
|
|
1198 (forward-line 1)
|
|
1199 ;; Make a list of all following subfiles.
|
|
1200 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
|
24963
|
1201 (while (not (eobp))
|
|
1202 (re-search-forward "\\(^.*\\): [0-9]+$")
|
|
1203 (goto-char (+ (match-end 1) 2))
|
47327
|
1204 (setq list (cons (cons (+ (point-min)
|
|
1205 (read (current-buffer)))
|
26580
|
1206 (match-string-no-properties 1))
|
24963
|
1207 list))
|
|
1208 (goto-char (1+ (match-end 0))))
|
47327
|
1209 ;; Put in forward order
|
|
1210 (setq list (nreverse list))))
|
24963
|
1211 (while list
|
|
1212 (message "Searching subfile %s..." (cdr (car list)))
|
|
1213 (Info-read-subfile (car (car list)))
|
|
1214 (setq list (cdr list))
|
|
1215 (if (re-search-forward regexp nil t)
|
|
1216 (setq found (point) list ())))
|
|
1217 (if found
|
|
1218 (message "")
|
|
1219 (signal 'search-failed (list regexp))))
|
|
1220 (if (not found)
|
|
1221 (progn (Info-read-subfile osubfile)
|
|
1222 (goto-char opoint)
|
|
1223 (Info-select-node)
|
|
1224 (set-window-start (selected-window) ostart)))))
|
29446
|
1225 (widen)
|
|
1226 (goto-char found)
|
|
1227 (Info-select-node)
|
|
1228 ;; Use string-equal, not equal, to ignore text props.
|
|
1229 (or (and (string-equal onode Info-current-node)
|
|
1230 (equal ofile Info-current-file))
|
|
1231 (setq Info-history (cons (list ofile onode opoint)
|
|
1232 Info-history))))))
|
325
|
1233
|
|
1234 (defun Info-extract-pointer (name &optional errorname)
|
29621
|
1235 "Extract the value of the node-pointer named NAME.
|
|
1236 If there is none, use ERRORNAME in the error message;
|
|
1237 if ERRORNAME is nil, just return nil.
|
|
1238 Bind this in case the user sets it to nil."
|
22951
|
1239 (let ((case-fold-search t))
|
|
1240 (save-excursion
|
31660
|
1241 (save-restriction
|
|
1242 (goto-char (point-min))
|
45633
|
1243 ;;; (when Info-header-line
|
|
1244 ;;; ;; expose the header line in the buffer
|
|
1245 ;;; (widen)
|
|
1246 ;;; (forward-line -1))
|
31660
|
1247 (let ((bound (point)))
|
|
1248 (forward-line 1)
|
31951
|
1249 (cond ((re-search-backward (concat name ":") bound t)
|
32007
|
1250 (goto-char (match-end 0))
|
|
1251 (Info-following-node-name))
|
31660
|
1252 ((not (eq errorname t))
|
|
1253 (error "Node has no %s"
|
|
1254 (capitalize (or errorname name))))))))))
|
325
|
1255
|
|
1256 (defun Info-following-node-name (&optional allowedchars)
|
29621
|
1257 "Return the node name in the buffer following point.
|
|
1258 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
|
|
1259 saying which chars may appear in the node name."
|
325
|
1260 (skip-chars-forward " \t")
|
13287
|
1261 (buffer-substring-no-properties
|
325
|
1262 (point)
|
|
1263 (progn
|
|
1264 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
|
|
1265 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
|
|
1266 (if (looking-at "(")
|
|
1267 (skip-chars-forward "^)")))
|
|
1268 (skip-chars-backward " ")
|
|
1269 (point))))
|
|
1270
|
|
1271 (defun Info-next ()
|
|
1272 "Go to the next node of this node."
|
|
1273 (interactive)
|
|
1274 (Info-goto-node (Info-extract-pointer "next")))
|
|
1275
|
|
1276 (defun Info-prev ()
|
|
1277 "Go to the previous node of this node."
|
|
1278 (interactive)
|
|
1279 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
|
|
1280
|
21910
|
1281 (defun Info-up (&optional same-file)
|
|
1282 "Go to the superior node of this node.
|
|
1283 If SAME-FILE is non-nil, do not move to a different Info file."
|
325
|
1284 (interactive)
|
21910
|
1285 (let ((node (Info-extract-pointer "up")))
|
26004
|
1286 (and (or same-file (not (stringp Info-current-file)))
|
21910
|
1287 (string-match "^(" node)
|
|
1288 (error "Up node is in another Info file"))
|
|
1289 (Info-goto-node node))
|
540
|
1290 (Info-restore-point Info-history))
|
325
|
1291
|
|
1292 (defun Info-last ()
|
|
1293 "Go back to the last node visited."
|
|
1294 (interactive)
|
|
1295 (or Info-history
|
|
1296 (error "This is the first Info node you looked at"))
|
|
1297 (let (filename nodename opoint)
|
|
1298 (setq filename (car (car Info-history)))
|
|
1299 (setq nodename (car (cdr (car Info-history))))
|
|
1300 (setq opoint (car (cdr (cdr (car Info-history)))))
|
|
1301 (setq Info-history (cdr Info-history))
|
|
1302 (Info-find-node filename nodename)
|
|
1303 (setq Info-history (cdr Info-history))
|
|
1304 (goto-char opoint)))
|
|
1305
|
28558
|
1306 ;;;###autoload
|
325
|
1307 (defun Info-directory ()
|
|
1308 "Go to the Info directory node."
|
|
1309 (interactive)
|
|
1310 (Info-find-node "dir" "top"))
|
|
1311
|
|
1312 (defun Info-follow-reference (footnotename)
|
29621
|
1313 "Follow cross reference named FOOTNOTENAME to the node it refers to.
|
|
1314 FOOTNOTENAME may be an abbreviation of the reference name."
|
325
|
1315 (interactive
|
|
1316 (let ((completion-ignore-case t)
|
22951
|
1317 (case-fold-search t)
|
5555
|
1318 completions default alt-default (start-point (point)) str i bol eol)
|
325
|
1319 (save-excursion
|
5555
|
1320 ;; Store end and beginning of line.
|
|
1321 (end-of-line)
|
|
1322 (setq eol (point))
|
|
1323 (beginning-of-line)
|
|
1324 (setq bol (point))
|
|
1325
|
325
|
1326 (goto-char (point-min))
|
|
1327 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
|
26580
|
1328 (setq str (buffer-substring-no-properties
|
325
|
1329 (match-beginning 1)
|
|
1330 (1- (point))))
|
|
1331 ;; See if this one should be the default.
|
|
1332 (and (null default)
|
5146
aa2236a14893
(Info-follow-reference): Correct one-off error in comparing start-point.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1333 (<= (match-beginning 0) start-point)
|
325
|
1334 (<= start-point (point))
|
|
1335 (setq default t))
|
5555
|
1336 ;; See if this one should be the alternate default.
|
|
1337 (and (null alt-default)
|
|
1338 (and (<= bol (match-beginning 0))
|
|
1339 (<= (point) eol))
|
|
1340 (setq alt-default t))
|
325
|
1341 (setq i 0)
|
|
1342 (while (setq i (string-match "[ \n\t]+" str i))
|
|
1343 (setq str (concat (substring str 0 i) " "
|
|
1344 (substring str (match-end 0))))
|
|
1345 (setq i (1+ i)))
|
|
1346 ;; Record as a completion and perhaps as default.
|
|
1347 (if (eq default t) (setq default str))
|
5555
|
1348 (if (eq alt-default t) (setq alt-default str))
|
16609
|
1349 ;; Don't add this string if it's a duplicate.
|
|
1350 ;; We use a loop instead of "(assoc str completions)" because
|
|
1351 ;; we want to do a case-insensitive compare.
|
|
1352 (let ((tail completions)
|
|
1353 (tem (downcase str)))
|
|
1354 (while (and tail
|
|
1355 (not (string-equal tem (downcase (car (car tail))))))
|
|
1356 (setq tail (cdr tail)))
|
|
1357 (or tail
|
|
1358 (setq completions
|
|
1359 (cons (cons str nil)
|
|
1360 completions))))))
|
5555
|
1361 ;; If no good default was found, try an alternate.
|
|
1362 (or default
|
|
1363 (setq default alt-default))
|
|
1364 ;; If only one cross-reference found, then make it default.
|
|
1365 (if (eq (length completions) 1)
|
|
1366 (setq default (car (car completions))))
|
325
|
1367 (if completions
|
3565
|
1368 (let ((input (completing-read (if default
|
39757
|
1369 (concat
|
|
1370 "Follow reference named: (default "
|
|
1371 default ") ")
|
3565
|
1372 "Follow reference named: ")
|
|
1373 completions nil t)))
|
|
1374 (list (if (equal input "")
|
|
1375 default input)))
|
325
|
1376 (error "No cross-references in this node"))))
|
23038
|
1377
|
|
1378 (unless footnotename
|
|
1379 (error "No reference was specified"))
|
|
1380
|
22951
|
1381 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))
|
|
1382 (case-fold-search t))
|
325
|
1383 (while (setq i (string-match " " str i))
|
|
1384 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
|
|
1385 (setq i (+ i 6)))
|
|
1386 (save-excursion
|
|
1387 (goto-char (point-min))
|
|
1388 (or (re-search-forward str nil t)
|
|
1389 (error "No cross-reference named %s" footnotename))
|
|
1390 (goto-char (+ (match-beginning 0) 5))
|
|
1391 (setq target
|
|
1392 (Info-extract-menu-node-name "Bad format cross reference" t)))
|
|
1393 (while (setq i (string-match "[ \t\n]+" target i))
|
|
1394 (setq target (concat (substring target 0 i) " "
|
|
1395 (substring target (match-end 0))))
|
|
1396 (setq i (+ i 1)))
|
|
1397 (Info-goto-node target)))
|
|
1398
|
|
1399 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
|
|
1400 (skip-chars-forward " \t\n")
|
|
1401 (let ((beg (point))
|
|
1402 str i)
|
|
1403 (skip-chars-forward "^:")
|
|
1404 (forward-char 1)
|
|
1405 (setq str
|
|
1406 (if (looking-at ":")
|
13287
|
1407 (buffer-substring-no-properties beg (1- (point)))
|
325
|
1408 (skip-chars-forward " \t\n")
|
|
1409 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
|
41713
d53ece895385
(Info-find-node-2): Don't call info-insert-file-contents
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1410 (replace-regexp-in-string "[ \n]+" " " str)))
|
325
|
1411
|
7837
|
1412 ;; No one calls this.
|
1484
|
1413 ;;(defun Info-menu-item-sequence (list)
|
|
1414 ;; (while list
|
7837
|
1415 ;; (Info-menu (car list))
|
1484
|
1416 ;; (setq list (cdr list))))
|
325
|
1417
|
22761
|
1418 (defvar Info-complete-menu-buffer)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1419 (defvar Info-complete-next-re nil)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1420 (defvar Info-complete-cache nil)
|
22761
|
1421
|
7837
|
1422 (defun Info-complete-menu-item (string predicate action)
|
41798
|
1423 ;; This uses two dynamically bound variables:
|
|
1424 ;; - `Info-complete-menu-buffer' which contains the buffer in which
|
|
1425 ;; is the menu of items we're trying to complete.
|
|
1426 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
|
|
1427 ;; also look for menu items in subsequent nodes as long as those
|
|
1428 ;; nodes' names match `Info-complete-next-re'. This feature is currently
|
|
1429 ;; only used for completion in Info-index.
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1430 (save-excursion
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1431 (set-buffer Info-complete-menu-buffer)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1432 (let ((completion-ignore-case t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1433 (case-fold-search t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1434 (orignode Info-current-node)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1435 nextnode)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1436 (goto-char (point-min))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1437 (search-forward "\n* Menu:")
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1438 (if (not (memq action '(nil t)))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1439 (re-search-forward
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1440 (concat "\n\\* +" (regexp-quote string) ":") nil t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1441 (let ((pattern (concat "\n\\* +\\("
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1442 (regexp-quote string)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1443 "[^:\t\n]*\\):"))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1444 completions)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1445 ;; Check the cache.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1446 (if (and (equal (nth 0 Info-complete-cache) Info-current-file)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1447 (equal (nth 1 Info-complete-cache) Info-current-node)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1448 (equal (nth 2 Info-complete-cache) Info-complete-next-re)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1449 (let ((prev (nth 3 Info-complete-cache)))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1450 (eq t (compare-strings string 0 (length prev)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1451 prev 0 nil t))))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1452 ;; We can reuse the previous list.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1453 (setq completions (nth 4 Info-complete-cache))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1454 ;; The cache can't be used.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1455 (while
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1456 (progn
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1457 (while (re-search-forward pattern nil t)
|
45014
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1458 (push (match-string-no-properties 1)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1459 completions))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1460 ;; Check subsequent nodes if applicable.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1461 (and Info-complete-next-re
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1462 (setq nextnode (Info-extract-pointer "next" t))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1463 (string-match Info-complete-next-re nextnode)))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1464 (Info-goto-node nextnode))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1465 ;; Go back to the start node (for the next completion).
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1466 (unless (equal Info-current-node orignode)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1467 (Info-goto-node orignode))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1468 ;; Update the cache.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1469 (setq Info-complete-cache
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1470 (list Info-current-file Info-current-node
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1471 Info-complete-next-re string completions)))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1472 (if action
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1473 (all-completions string completions predicate)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1474 (try-completion string completions predicate)))))))
|
7837
|
1475
|
|
1476
|
26004
|
1477 (defun Info-menu (menu-item &optional fork)
|
39382
|
1478 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
|
|
1479 The menu item should one of those listed in the current node's menu.
|
|
1480 Completion is allowed, and the default menu item is the one point is on.
|
32286
|
1481 If FORK is non-nil (interactively with a prefix arg), show the node in
|
|
1482 a new info buffer. If FORK is a string, it is the name to use for the
|
|
1483 new buffer."
|
325
|
1484 (interactive
|
|
1485 (let ((completions '())
|
|
1486 ;; If point is within a menu item, use that item as the default
|
|
1487 (default nil)
|
|
1488 (p (point))
|
10957
|
1489 beg
|
29446
|
1490 (last nil)
|
|
1491 (case-fold-search t))
|
325
|
1492 (save-excursion
|
|
1493 (goto-char (point-min))
|
|
1494 (if (not (search-forward "\n* menu:" nil t))
|
|
1495 (error "No menu in this node"))
|
7837
|
1496 (setq beg (point))
|
|
1497 (and (< (point) p)
|
|
1498 (save-excursion
|
|
1499 (goto-char p)
|
|
1500 (end-of-line)
|
23819
2e335a66e659
(Info-menu): Don't return error if point is between menu header and
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
1501 (if (re-search-backward "\n\\* +\\([^:\t\n]*\\):" beg t)
|
26580
|
1502 (setq default (match-string-no-properties 1))))))
|
325
|
1503 (let ((item nil))
|
|
1504 (while (null item)
|
7837
|
1505 (setq item (let ((completion-ignore-case t)
|
|
1506 (Info-complete-menu-buffer (current-buffer)))
|
325
|
1507 (completing-read (if default
|
|
1508 (format "Menu item (default %s): "
|
|
1509 default)
|
29446
|
1510 "Menu item: ")
|
7837
|
1511 'Info-complete-menu-item nil t)))
|
540
|
1512 ;; we rely on the fact that completing-read accepts an input
|
|
1513 ;; of "" even when the require-match argument is true and ""
|
|
1514 ;; is not a valid possibility
|
325
|
1515 (if (string= item "")
|
|
1516 (if default
|
|
1517 (setq item default)
|
29446
|
1518 ;; ask again
|
|
1519 (setq item nil))))
|
26004
|
1520 (list item current-prefix-arg))))
|
325
|
1521 ;; there is a problem here in that if several menu items have the same
|
|
1522 ;; name you can only go to the node of the first with this command.
|
26004
|
1523 (Info-goto-node (Info-extract-menu-item menu-item) (if fork menu-item)))
|
28943
|
1524
|
325
|
1525 (defun Info-extract-menu-item (menu-item)
|
|
1526 (setq menu-item (regexp-quote menu-item))
|
22951
|
1527 (let ((case-fold-search t))
|
|
1528 (save-excursion
|
29446
|
1529 (let ((case-fold-search t))
|
|
1530 (goto-char (point-min))
|
|
1531 (or (search-forward "\n* menu:" nil t)
|
|
1532 (error "No menu in this node"))
|
|
1533 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
|
|
1534 (re-search-forward (concat "\n\\* +" menu-item) nil t)
|
|
1535 (error "No such item in menu"))
|
|
1536 (beginning-of-line)
|
|
1537 (forward-char 2)
|
|
1538 (Info-extract-menu-node-name)))))
|
325
|
1539
|
|
1540 ;; If COUNT is nil, use the last item in the menu.
|
|
1541 (defun Info-extract-menu-counting (count)
|
22951
|
1542 (let ((case-fold-search t))
|
|
1543 (save-excursion
|
29446
|
1544 (let ((case-fold-search t))
|
|
1545 (goto-char (point-min))
|
|
1546 (or (search-forward "\n* menu:" nil t)
|
|
1547 (error "No menu in this node"))
|
|
1548 (if count
|
|
1549 (or (search-forward "\n* " nil t count)
|
|
1550 (error "Too few items in menu"))
|
|
1551 (while (search-forward "\n* " nil t)
|
|
1552 nil))
|
|
1553 (Info-extract-menu-node-name)))))
|
325
|
1554
|
1666
|
1555 (defun Info-nth-menu-item ()
|
|
1556 "Go to the node of the Nth menu item.
|
|
1557 N is the digit argument used to invoke this command."
|
325
|
1558 (interactive)
|
1666
|
1559 (Info-goto-node
|
|
1560 (Info-extract-menu-counting
|
|
1561 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
|
325
|
1562
|
|
1563 (defun Info-top-node ()
|
|
1564 "Go to the Top node of this file."
|
|
1565 (interactive)
|
|
1566 (Info-goto-node "Top"))
|
|
1567
|
|
1568 (defun Info-final-node ()
|
|
1569 "Go to the final node in this file."
|
|
1570 (interactive)
|
|
1571 (Info-goto-node "Top")
|
29446
|
1572 (let ((Info-history nil)
|
|
1573 (case-fold-search t))
|
325
|
1574 ;; Go to the last node in the menu of Top.
|
|
1575 (Info-goto-node (Info-extract-menu-counting nil))
|
|
1576 ;; If the last node in the menu is not last in pointer structure,
|
28943
|
1577 ;; move forward until we can't go any farther.
|
325
|
1578 (while (Info-forward-node t t) nil)
|
|
1579 ;; Then keep moving down to last subnode, unless we reach an index.
|
|
1580 (while (and (not (string-match "\\<index\\>" Info-current-node))
|
|
1581 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
1582 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
1583
|
|
1584 (defun Info-forward-node (&optional not-down no-error)
|
|
1585 "Go forward one node, considering all nodes as forming one sequence."
|
|
1586 (interactive)
|
|
1587 (goto-char (point-min))
|
|
1588 (forward-line 1)
|
29446
|
1589 (let ((case-fold-search t))
|
|
1590 ;; three possibilities, in order of priority:
|
|
1591 ;; 1. next node is in a menu in this node (but not in an index)
|
|
1592 ;; 2. next node is next at same level
|
|
1593 ;; 3. next node is up and next
|
|
1594 (cond ((and (not not-down)
|
|
1595 (save-excursion (search-forward "\n* menu:" nil t))
|
|
1596 (not (string-match "\\<index\\>" Info-current-node)))
|
|
1597 (Info-goto-node (Info-extract-menu-counting 1))
|
|
1598 t)
|
34624
|
1599 ((save-excursion
|
|
1600 (save-restriction
|
|
1601 (let (limit)
|
|
1602 (when Info-header-line
|
|
1603 (goto-char (point-min))
|
|
1604 (widen)
|
|
1605 (forward-line -1)
|
|
1606 (setq limit (point))
|
|
1607 (forward-line 1))
|
|
1608 (search-backward "next:" limit t))))
|
29446
|
1609 (Info-next)
|
|
1610 t)
|
34624
|
1611 ((and (save-excursion
|
|
1612 (save-restriction
|
|
1613 (let (limit)
|
|
1614 (when Info-header-line
|
|
1615 (goto-char (point-min))
|
|
1616 (widen)
|
|
1617 (forward-line -1)
|
|
1618 (setq limit (point))
|
|
1619 (forward-line 1))
|
|
1620 (search-backward "up:" limit t))))
|
29446
|
1621 ;; Use string-equal, not equal, to ignore text props.
|
|
1622 (not (string-equal (downcase (Info-extract-pointer "up"))
|
|
1623 "top")))
|
|
1624 (let ((old-node Info-current-node))
|
|
1625 (Info-up)
|
|
1626 (let (Info-history success)
|
|
1627 (unwind-protect
|
|
1628 (setq success (Info-forward-node t no-error))
|
|
1629 (or success (Info-goto-node old-node))))))
|
|
1630 (no-error nil)
|
|
1631 (t (error "No pointer forward from this node")))))
|
325
|
1632
|
|
1633 (defun Info-backward-node ()
|
|
1634 "Go backward one node, considering all nodes as forming one sequence."
|
|
1635 (interactive)
|
|
1636 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
|
29446
|
1637 (upnode (Info-extract-pointer "up" t))
|
|
1638 (case-fold-search t))
|
325
|
1639 (cond ((and upnode (string-match "(" upnode))
|
|
1640 (error "First node in file"))
|
|
1641 ((and upnode (or (null prevnode)
|
11527
|
1642 ;; Use string-equal, not equal,
|
|
1643 ;; to ignore text properties.
|
|
1644 (string-equal (downcase prevnode)
|
|
1645 (downcase upnode))))
|
325
|
1646 (Info-up))
|
|
1647 (prevnode
|
|
1648 ;; If we move back at the same level,
|
|
1649 ;; go down to find the last subnode*.
|
|
1650 (Info-prev)
|
|
1651 (let (Info-history)
|
|
1652 (while (and (not (string-match "\\<index\\>" Info-current-node))
|
|
1653 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
1654 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
1655 (t
|
|
1656 (error "No pointer backward from this node")))))
|
|
1657
|
|
1658 (defun Info-exit ()
|
|
1659 "Exit Info by selecting some other buffer."
|
|
1660 (interactive)
|
4410
|
1661 (if Info-standalone
|
|
1662 (save-buffers-kill-emacs)
|
22331
|
1663 (quit-window)))
|
325
|
1664
|
929
|
1665 (defun Info-next-menu-item ()
|
|
1666 (interactive)
|
29621
|
1667 ;; Bind this in case the user sets it to nil.
|
29446
|
1668 (let* ((case-fold-search t)
|
|
1669 (node
|
|
1670 (save-excursion
|
|
1671 (forward-line -1)
|
|
1672 (search-forward "\n* menu:" nil t)
|
|
1673 (and (search-forward "\n* " nil t)
|
|
1674 (Info-extract-menu-node-name)))))
|
23533
|
1675 (if node (Info-goto-node node)
|
|
1676 (error "No more items in menu"))))
|
929
|
1677
|
|
1678 (defun Info-last-menu-item ()
|
|
1679 (interactive)
|
|
1680 (save-excursion
|
|
1681 (forward-line 1)
|
29621
|
1682 ;; Bind this in case the user sets it to nil.
|
29446
|
1683 (let* ((case-fold-search t)
|
|
1684 (beg (save-excursion
|
|
1685 (and (search-backward "\n* menu:" nil t)
|
|
1686 (point)))))
|
8489
|
1687 (or (and beg (search-backward "\n* " beg t))
|
|
1688 (error "No previous items in menu")))
|
|
1689 (Info-goto-node (save-excursion
|
|
1690 (goto-char (match-end 0))
|
|
1691 (Info-extract-menu-node-name)))))
|
929
|
1692
|
4410
|
1693 (defmacro Info-no-error (&rest body)
|
929
|
1694 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
|
|
1695
|
|
1696 (defun Info-next-preorder ()
|
8018
|
1697 "Go to the next subnode or the next node, or go up a level."
|
|
1698 (interactive)
|
|
1699 (cond ((Info-no-error (Info-next-menu-item)))
|
|
1700 ((Info-no-error (Info-next)))
|
21910
|
1701 ((Info-no-error (Info-up t))
|
12156
|
1702 ;; Since we have already gone thru all the items in this menu,
|
|
1703 ;; go up to the end of this node.
|
15575
|
1704 (goto-char (point-max))
|
|
1705 ;; Since logically we are done with the node with that menu,
|
|
1706 ;; move on from it.
|
|
1707 (Info-next-preorder))
|
8018
|
1708 (t
|
|
1709 (error "No more nodes"))))
|
929
|
1710
|
|
1711 (defun Info-last-preorder ()
|
|
1712 "Go to the last node, popping up a level if there is none."
|
|
1713 (interactive)
|
8489
|
1714 (cond ((Info-no-error
|
|
1715 (Info-last-menu-item)
|
|
1716 ;; If we go down a menu item, go to the end of the node
|
|
1717 ;; so we can scroll back through it.
|
12156
|
1718 (goto-char (point-max)))
|
15575
|
1719 ;; Keep going down, as long as there are nested menu nodes.
|
|
1720 (while (Info-no-error
|
|
1721 (Info-last-menu-item)
|
|
1722 ;; If we go down a menu item, go to the end of the node
|
|
1723 ;; so we can scroll back through it.
|
|
1724 (goto-char (point-max))))
|
12156
|
1725 (recenter -1))
|
34468
|
1726 ((and (Info-no-error (Info-extract-pointer "prev"))
|
|
1727 (not (equal (Info-extract-pointer "up")
|
21910
|
1728 (Info-extract-pointer "prev"))))
|
|
1729 (Info-no-error (Info-prev))
|
12156
|
1730 (goto-char (point-max))
|
15575
|
1731 (while (Info-no-error
|
|
1732 (Info-last-menu-item)
|
|
1733 ;; If we go down a menu item, go to the end of the node
|
|
1734 ;; so we can scroll back through it.
|
|
1735 (goto-char (point-max))))
|
12156
|
1736 (recenter -1))
|
21910
|
1737 ((Info-no-error (Info-up t))
|
12156
|
1738 (goto-char (point-min))
|
29446
|
1739 (let ((case-fold-search t))
|
|
1740 (or (search-forward "\n* Menu:" nil t)
|
|
1741 (goto-char (point-max)))))
|
12156
|
1742 (t (error "No previous nodes"))))
|
929
|
1743
|
|
1744 (defun Info-scroll-up ()
|
9222
|
1745 "Scroll one screenful forward in Info, considering all nodes as one sequence.
|
16498
|
1746 Once you scroll far enough in a node that its menu appears on the screen
|
34182
|
1747 but after point, the next scroll moves into its first subnode, unless
|
|
1748 `Info-scroll-prefer-subnodes' is nil.
|
16498
|
1749
|
34182
|
1750 When you scroll past the end of a node, that goes to the next node if
|
|
1751 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
|
|
1752 if this node has no successor, it moves to the parent node's successor,
|
|
1753 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
|
|
1754 the menu of a node, it moves to subnode indicated by the following menu
|
|
1755 item. (That case won't normally result from this command, but can happen
|
|
1756 in other ways.)"
|
16498
|
1757
|
929
|
1758 (interactive)
|
8489
|
1759 (if (or (< (window-start) (point-min))
|
|
1760 (> (window-start) (point-max)))
|
|
1761 (set-window-start (selected-window) (point)))
|
29446
|
1762 (let* ((case-fold-search t)
|
|
1763 (virtual-end (save-excursion
|
|
1764 (goto-char (point-min))
|
34182
|
1765 (if (and Info-scroll-prefer-subnodes
|
|
1766 (search-forward "\n* Menu:" nil t))
|
29446
|
1767 (point)
|
|
1768 (point-max)))))
|
8489
|
1769 (if (or (< virtual-end (window-start))
|
|
1770 (pos-visible-in-window-p virtual-end))
|
34182
|
1771 (cond
|
|
1772 (Info-scroll-prefer-subnodes (Info-next-preorder))
|
|
1773 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
|
|
1774 (t (Info-next-preorder)))
|
8489
|
1775 (scroll-up))))
|
929
|
1776
|
|
1777 (defun Info-scroll-down ()
|
9222
|
1778 "Scroll one screenful back in Info, considering all nodes as one sequence.
|
34468
|
1779 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
|
|
1780 is non-nil, this goes to its last subnode. When you scroll past the
|
|
1781 beginning of a node, that goes to the previous node or back up to the
|
|
1782 parent node."
|
929
|
1783 (interactive)
|
8489
|
1784 (if (or (< (window-start) (point-min))
|
|
1785 (> (window-start) (point-max)))
|
|
1786 (set-window-start (selected-window) (point)))
|
29446
|
1787 (let* ((case-fold-search t)
|
|
1788 (current-point (point))
|
34468
|
1789 (virtual-end
|
|
1790 (and Info-scroll-prefer-subnodes
|
|
1791 (save-excursion
|
|
1792 (beginning-of-line)
|
|
1793 (setq current-point (point))
|
|
1794 (goto-char (point-min))
|
|
1795 (search-forward "\n* Menu:"
|
|
1796 current-point
|
|
1797 t)))))
|
36634
|
1798 (if (or virtual-end
|
36894
|
1799 (pos-visible-in-window-p (point-min) nil t))
|
8489
|
1800 (Info-last-preorder)
|
|
1801 (scroll-down))))
|
929
|
1802
|
15055
|
1803 (defun Info-next-reference (&optional recur)
|
4410
|
1804 "Move cursor to the next cross-reference or menu item in the node."
|
|
1805 (interactive)
|
|
1806 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
|
22951
|
1807 (old-pt (point))
|
|
1808 (case-fold-search t))
|
4410
|
1809 (or (eobp) (forward-char 1))
|
|
1810 (or (re-search-forward pat nil t)
|
|
1811 (progn
|
|
1812 (goto-char (point-min))
|
|
1813 (or (re-search-forward pat nil t)
|
|
1814 (progn
|
|
1815 (goto-char old-pt)
|
|
1816 (error "No cross references in this node")))))
|
|
1817 (goto-char (match-beginning 0))
|
|
1818 (if (looking-at "\\* Menu:")
|
15055
|
1819 (if recur
|
|
1820 (error "No cross references in this node")
|
|
1821 (Info-next-reference t)))))
|
4410
|
1822
|
15055
|
1823 (defun Info-prev-reference (&optional recur)
|
4410
|
1824 "Move cursor to the previous cross-reference or menu item in the node."
|
|
1825 (interactive)
|
|
1826 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
|
22951
|
1827 (old-pt (point))
|
|
1828 (case-fold-search t))
|
4410
|
1829 (or (re-search-backward pat nil t)
|
|
1830 (progn
|
|
1831 (goto-char (point-max))
|
|
1832 (or (re-search-backward pat nil t)
|
|
1833 (progn
|
|
1834 (goto-char old-pt)
|
|
1835 (error "No cross references in this node")))))
|
|
1836 (goto-char (match-beginning 0))
|
|
1837 (if (looking-at "\\* Menu:")
|
15055
|
1838 (if recur
|
|
1839 (error "No cross references in this node")
|
|
1840 (Info-prev-reference t)))))
|
4410
|
1841
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1842 (defun Info-goto-index ()
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1843 (Info-goto-node "Top")
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1844 (or (search-forward "\n* menu:" nil t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1845 (error "No index"))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1846 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1847 (error "No index"))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1848 (goto-char (match-beginning 1))
|
41691
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1849 ;; Protect Info-history so that the current node (Top) is not added to it.
|
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1850 (let ((Info-history nil))
|
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1851 (Info-goto-node (Info-extract-menu-node-name))))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1852
|
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
|
1853 (defun Info-index (topic)
|
29621
|
1854 "Look up a string TOPIC in the index for this file.
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1855 The index is defined as the first node in the top level menu whose
|
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
|
1856 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
|
1857 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
|
1858 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
|
1859 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
|
1860 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
|
1861 Give a blank topic name to go to the Index node itself."
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1862 (interactive
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1863 (list
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1864 (let ((Info-complete-menu-buffer (clone-buffer))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1865 (Info-complete-next-re "\\<Index\\>"))
|
46104
|
1866 (if (equal Info-current-file "dir")
|
|
1867 (error "The Info directory node has no index; use m to select a manual"))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1868 (unwind-protect
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1869 (with-current-buffer Info-complete-menu-buffer
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1870 (Info-goto-index)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1871 (completing-read "Index topic: " 'Info-complete-menu-item))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1872 (kill-buffer Info-complete-menu-buffer)))))
|
46104
|
1873 (if (equal Info-current-file "dir")
|
|
1874 (error "The Info directory node has no index; use m to select a manual"))
|
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
|
1875 (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
|
1876 (rnode nil)
|
21641
|
1877 (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
|
1878 (regexp-quote topic)))
|
22951
|
1879 node
|
|
1880 (case-fold-search t))
|
41691
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1881 (Info-goto-index)
|
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
|
1882 (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
|
1883 (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
|
1884 (exact nil)
|
41691
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1885 ;; We bind Info-history to nil for internal node-switches so
|
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1886 ;; that we don't put junk in the history. In the first
|
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1887 ;; Info-goto-index call, above, we do update the history
|
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1888 ;; because that is what the user's previous node choice into it.
|
10758
|
1889 (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
|
1890 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
|
1891 (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
|
1892 (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
|
1893 (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
|
1894 (while (re-search-forward pattern nil t)
|
31942
|
1895 (push (list (match-string-no-properties 1)
|
|
1896 (match-string-no-properties 2)
|
|
1897 Info-current-node
|
|
1898 (string-to-int (concat "0"
|
|
1899 (match-string 3))))
|
|
1900 matches))
|
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
|
1901 (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
|
1902 (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
|
1903 (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
|
1904 (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
|
1905 (progn
|
14664
|
1906 (Info-goto-node orignode)
|
14560
|
1907 (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
|
1908 ;; 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
|
1909 (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
|
1910 (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
|
1911 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
|
1912 (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
|
1913 (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
|
1914
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
1915 (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
|
1916 "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
|
1917 (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
|
1918 (or Info-index-alternatives
|
16790
|
1919 (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
|
1920 (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
|
1921 (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
|
1922 (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
|
1923 (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
|
1924 (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
|
1925 (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
|
1926 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
|
1927 (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
|
1928 (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
|
1929 (forward-line (nth 3 (car Info-index-alternatives)))
|
29446
|
1930 (forward-line 3) ; don't search in headers
|
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
|
1931 (let ((name (car (car Info-index-alternatives))))
|
14560
|
1932 (Info-find-index-name name)))
|
|
1933 (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
|
1934 (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
|
1935 (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
|
1936 (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
|
1937 "(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
|
1938 "(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
|
1939
|
14560
|
1940 (defun Info-find-index-name (name)
|
|
1941 "Move point to the place within the current node where NAME is defined."
|
22951
|
1942 (let ((case-fold-search t))
|
|
1943 (if (or (re-search-forward (format
|
|
1944 "[a-zA-Z]+: %s\\( \\|$\\)"
|
|
1945 (regexp-quote name)) nil t)
|
46691
ac544e207278
(Info-find-index-name): Search for a function definition with a return type.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1946 ;; Find a function definition with a return type.
|
ac544e207278
(Info-find-index-name): Search for a function definition with a return type.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1947 (re-search-forward (format
|
46714
|
1948 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
|
46691
ac544e207278
(Info-find-index-name): Search for a function definition with a return type.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1949 (regexp-quote name)) nil t)
|
22951
|
1950 (search-forward (format "`%s'" name) nil t)
|
|
1951 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
|
|
1952 (search-forward
|
|
1953 (format "`%s'" (substring name 0 (match-beginning 1)))
|
|
1954 nil t))
|
|
1955 (search-forward name nil t))
|
|
1956 (beginning-of-line)
|
|
1957 (goto-char (point-min)))))
|
14560
|
1958
|
325
|
1959 (defun Info-undefined ()
|
|
1960 "Make command be undefined in Info."
|
|
1961 (interactive)
|
|
1962 (ding))
|
|
1963
|
|
1964 (defun Info-help ()
|
|
1965 "Enter the Info tutorial."
|
|
1966 (interactive)
|
|
1967 (delete-other-windows)
|
|
1968 (Info-find-node "info"
|
|
1969 (if (< (window-height) 23)
|
|
1970 "Help-Small-Screen"
|
|
1971 "Help")))
|
|
1972
|
|
1973 (defun Info-summary ()
|
|
1974 "Display a brief summary of all Info commands."
|
|
1975 (interactive)
|
|
1976 (save-window-excursion
|
|
1977 (switch-to-buffer "*Help*")
|
20910
|
1978 (setq buffer-read-only nil)
|
325
|
1979 (erase-buffer)
|
|
1980 (insert (documentation 'Info-mode))
|
9852
|
1981 (help-mode)
|
325
|
1982 (goto-char (point-min))
|
|
1983 (let (ch flag)
|
|
1984 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
|
|
1985 (message (if flag "Type Space to see more"
|
|
1986 "Type Space to return to Info"))
|
2032
|
1987 (if (not (eq ?\ (setq ch (read-event))))
|
1821
|
1988 (progn (setq unread-command-events (list ch)) nil)
|
325
|
1989 flag))
|
4410
|
1990 (scroll-up)))
|
|
1991 (bury-buffer "*Help*")))
|
325
|
1992
|
|
1993 (defun Info-get-token (pos start all &optional errorstring)
|
29621
|
1994 "Return the token around POS.
|
325
|
1995 POS must be somewhere inside the token
|
|
1996 START is a regular expression which will match the
|
|
1997 beginning of the tokens delimited string
|
|
1998 ALL is a regular expression with a single
|
13990
|
1999 parenthesized subpattern which is the token to be
|
29621
|
2000 returned. E.g. '{\(.*\)}' would return any string
|
325
|
2001 enclosed in braces around POS.
|
29621
|
2002 ERRORSTRING optional fourth argument, controls action on no match
|
325
|
2003 nil: return nil
|
|
2004 t: beep
|
|
2005 a string: signal an error, using that string."
|
22951
|
2006 (let ((case-fold-search t))
|
|
2007 (save-excursion
|
|
2008 (goto-char pos)
|
|
2009 ;; First look for a match for START that goes across POS.
|
|
2010 (while (and (not (bobp)) (> (point) (- pos (length start)))
|
|
2011 (not (looking-at start)))
|
|
2012 (forward-char -1))
|
|
2013 ;; If we did not find one, search back for START
|
|
2014 ;; (this finds only matches that end at or before POS).
|
|
2015 (or (looking-at start)
|
|
2016 (progn
|
|
2017 (goto-char pos)
|
|
2018 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
|
|
2019 (let (found)
|
|
2020 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
|
|
2021 (not (setq found (and (<= (match-beginning 0) pos)
|
|
2022 (> (match-end 0) pos))))))
|
|
2023 (if (and found (<= (match-beginning 0) pos)
|
|
2024 (> (match-end 0) pos))
|
26580
|
2025 (match-string-no-properties 1)
|
22951
|
2026 (cond ((null errorstring)
|
|
2027 nil)
|
|
2028 ((eq errorstring t)
|
|
2029 (beep)
|
|
2030 nil)
|
|
2031 (t
|
|
2032 (error "No %s around position %d" errorstring pos))))))))
|
325
|
2033
|
7007
|
2034 (defun Info-mouse-follow-nearest-node (click)
|
1309
|
2035 "\\<Info-mode-map>Follow a node reference near point.
|
|
2036 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
|
7007
|
2037 At end of the node's text, moves to the next node, or up if none."
|
1309
|
2038 (interactive "e")
|
32500
|
2039 (mouse-set-point click)
|
7007
|
2040 (and (not (Info-try-follow-nearest-node))
|
|
2041 (save-excursion (forward-line 1) (eobp))
|
12156
|
2042 (Info-next-preorder)))
|
7007
|
2043
|
|
2044 (defun Info-follow-nearest-node ()
|
|
2045 "\\<Info-mode-map>Follow a node reference near point.
|
|
2046 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
|
|
2047 If no reference to follow, moves to the next node, or up if none."
|
|
2048 (interactive)
|
|
2049 (or (Info-try-follow-nearest-node)
|
12156
|
2050 (Info-next-preorder)))
|
7007
|
2051
|
|
2052 ;; Common subroutine.
|
|
2053 (defun Info-try-follow-nearest-node ()
|
|
2054 "Follow a node reference near point. Return non-nil if successful."
|
325
|
2055 (let (node)
|
|
2056 (cond
|
7007
|
2057 ((setq node (Info-get-token (point) "\\*note[ \n]"
|
|
2058 "\\*note[ \n]\\([^:]*\\):"))
|
325
|
2059 (Info-follow-reference node))
|
21641
|
2060 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
|
325
|
2061 (Info-goto-node node))
|
23019
|
2062 ((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):")
|
|
2063 (beginning-of-line)
|
|
2064 (forward-char 2)
|
|
2065 (setq node (Info-extract-menu-node-name))
|
|
2066 (Info-goto-node node))
|
3127
|
2067 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
|
325
|
2068 (Info-goto-node node))
|
3127
|
2069 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
|
325
|
2070 (Info-goto-node node))
|
3127
|
2071 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
|
325
|
2072 (Info-goto-node "Top"))
|
3127
|
2073 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
|
7007
|
2074 (Info-goto-node node)))
|
|
2075 node))
|
325
|
2076
|
|
2077 (defvar Info-mode-map nil
|
|
2078 "Keymap containing Info commands.")
|
|
2079 (if Info-mode-map
|
|
2080 nil
|
|
2081 (setq Info-mode-map (make-keymap))
|
|
2082 (suppress-keymap Info-mode-map)
|
|
2083 (define-key Info-mode-map "." 'beginning-of-buffer)
|
929
|
2084 (define-key Info-mode-map " " 'Info-scroll-up)
|
7007
|
2085 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
|
4410
|
2086 (define-key Info-mode-map "\t" 'Info-next-reference)
|
|
2087 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
|
1666
|
2088 (define-key Info-mode-map "1" 'Info-nth-menu-item)
|
|
2089 (define-key Info-mode-map "2" 'Info-nth-menu-item)
|
|
2090 (define-key Info-mode-map "3" 'Info-nth-menu-item)
|
|
2091 (define-key Info-mode-map "4" 'Info-nth-menu-item)
|
|
2092 (define-key Info-mode-map "5" 'Info-nth-menu-item)
|
|
2093 (define-key Info-mode-map "6" 'Info-nth-menu-item)
|
|
2094 (define-key Info-mode-map "7" 'Info-nth-menu-item)
|
|
2095 (define-key Info-mode-map "8" 'Info-nth-menu-item)
|
|
2096 (define-key Info-mode-map "9" 'Info-nth-menu-item)
|
1667
|
2097 (define-key Info-mode-map "0" 'undefined)
|
325
|
2098 (define-key Info-mode-map "?" 'Info-summary)
|
|
2099 (define-key Info-mode-map "]" 'Info-forward-node)
|
|
2100 (define-key Info-mode-map "[" 'Info-backward-node)
|
|
2101 (define-key Info-mode-map "<" 'Info-top-node)
|
|
2102 (define-key Info-mode-map ">" 'Info-final-node)
|
|
2103 (define-key Info-mode-map "b" 'beginning-of-buffer)
|
45182
|
2104 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
|
325
|
2105 (define-key Info-mode-map "d" 'Info-directory)
|
|
2106 (define-key Info-mode-map "e" 'Info-edit)
|
|
2107 (define-key Info-mode-map "f" 'Info-follow-reference)
|
|
2108 (define-key Info-mode-map "g" 'Info-goto-node)
|
|
2109 (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
|
2110 (define-key Info-mode-map "i" 'Info-index)
|
325
|
2111 (define-key Info-mode-map "l" 'Info-last)
|
|
2112 (define-key Info-mode-map "m" 'Info-menu)
|
|
2113 (define-key Info-mode-map "n" 'Info-next)
|
|
2114 (define-key Info-mode-map "p" 'Info-prev)
|
|
2115 (define-key Info-mode-map "q" 'Info-exit)
|
|
2116 (define-key Info-mode-map "s" 'Info-search)
|
8739
|
2117 ;; For consistency with Rmail.
|
|
2118 (define-key Info-mode-map "\M-s" 'Info-search)
|
26004
|
2119 (define-key Info-mode-map "\M-n" 'clone-buffer)
|
3313
|
2120 (define-key Info-mode-map "t" 'Info-top-node)
|
325
|
2121 (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
|
2122 (define-key Info-mode-map "," 'Info-index-next)
|
930
|
2123 (define-key Info-mode-map "\177" 'Info-scroll-down)
|
7007
|
2124 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
|
540
|
2125 )
|
16043
|
2126
|
|
2127 (defun Info-check-pointer (item)
|
29621
|
2128 "Non-nil if ITEM is present in this node."
|
16043
|
2129 (condition-case nil
|
|
2130 (Info-extract-pointer item)
|
|
2131 (error nil)))
|
|
2132
|
30220
|
2133 (easy-menu-define
|
|
2134 Info-mode-menu Info-mode-map
|
|
2135 "Menu for info files."
|
|
2136 '("Info"
|
|
2137 ["Up" Info-up :active (Info-check-pointer "up")
|
|
2138 :help "Go up in the Info tree"]
|
|
2139 ["Next" Info-next :active (Info-check-pointer "next")
|
|
2140 :help "Go to the next node"]
|
|
2141 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
|
|
2142 :help "Go to the previous node"]
|
|
2143 ["Backward" Info-backward-node
|
|
2144 :help "Go backward one node, considering all as a sequence"]
|
|
2145 ["Forward" Info-forward-node
|
|
2146 :help "Go forward one node, considering all as a sequence"]
|
32286
|
2147 ["Beginning" beginning-of-buffer
|
|
2148 :help "Go to beginning of this node"]
|
30220
|
2149 ["Top" Info-top-node
|
|
2150 :help "Go to top node of file"]
|
|
2151 ["Final Node" Info-final-node
|
|
2152 :help "Go to final node in this file"]
|
|
2153 ("Menu Item" ["You should never see this" report-emacs-bug t])
|
|
2154 ("Reference" ["You should never see this" report-emacs-bug t])
|
|
2155 ["Search..." Info-search
|
|
2156 :help "Search for regular expression in this Info file"]
|
32500
|
2157 ["Go to Node..." Info-goto-node
|
30220
|
2158 :help "Go to a named node"]
|
32391
|
2159 ["Last" Info-last :active Info-history
|
30220
|
2160 :help "Go to the last node you were at"]
|
|
2161 ("Index..."
|
|
2162 ["Lookup a String" Info-index
|
|
2163 :help "Look for a string in the index items"]
|
|
2164 ["Next Matching Item" Info-index-next
|
|
2165 :help "Look for another occurrence of previous item"])
|
32286
|
2166 ["Edit" Info-edit :help "Edit contents of this node"
|
|
2167 :active Info-enable-edit]
|
36092
|
2168 ["Copy Node Name" Info-copy-current-node-name
|
|
2169 :help "Copy the name of the current node into the kill ring"]
|
32391
|
2170 ["Exit" Info-exit :help "Stop reading Info"]))
|
16043
|
2171
|
32286
|
2172
|
|
2173 (defvar info-tool-bar-map
|
|
2174 (if (display-graphic-p)
|
44306
|
2175 (let ((map (make-sparse-keymap)))
|
|
2176 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
|
|
2177 (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map)
|
|
2178 (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map)
|
|
2179 (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map)
|
|
2180 (tool-bar-local-item-from-menu 'Info-last "undo" map Info-mode-map)
|
|
2181 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
|
|
2182 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
|
|
2183 (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map)
|
|
2184 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
|
|
2185 map)))
|
32286
|
2186
|
16043
|
2187 (defvar Info-menu-last-node nil)
|
|
2188 ;; Last node the menu was created for.
|
21197
|
2189 ;; Value is a list, (FILE-NAME NODE-NAME).
|
16043
|
2190
|
|
2191 (defun Info-menu-update ()
|
29621
|
2192 "Update the Info menu for the current node."
|
16043
|
2193 (condition-case nil
|
|
2194 (if (or (not (eq major-mode 'Info-mode))
|
21197
|
2195 (equal (list Info-current-file Info-current-node)
|
|
2196 Info-menu-last-node))
|
16043
|
2197 ()
|
|
2198 ;; Update menu menu.
|
|
2199 (let* ((Info-complete-menu-buffer (current-buffer))
|
|
2200 (items (nreverse (condition-case nil
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2201 (Info-complete-menu-item "" nil t)
|
16043
|
2202 (error nil))))
|
28943
|
2203 entries current
|
16043
|
2204 (number 0))
|
|
2205 (while (and items (< number 9))
|
|
2206 (setq current (car items)
|
|
2207 items (cdr items)
|
|
2208 number (1+ number))
|
28943
|
2209 (setq entries (cons `[,current
|
16043
|
2210 (Info-menu ,current)
|
|
2211 :keys ,(format "%d" number)]
|
|
2212 entries)))
|
|
2213 (if items
|
|
2214 (setq entries (cons ["Other..." Info-menu t] entries)))
|
|
2215 (or entries
|
37370
|
2216 (setq entries (list ["No menu" nil nil] nil :active)))
|
30220
|
2217 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
|
16043
|
2218 ;; Update reference menu. Code stolen from `Info-follow-reference'.
|
|
2219 (let ((items nil)
|
28943
|
2220 str i entries current
|
22951
|
2221 (number 0)
|
|
2222 (case-fold-search t))
|
16043
|
2223 (save-excursion
|
|
2224 (goto-char (point-min))
|
|
2225 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
|
|
2226 (setq str (buffer-substring
|
|
2227 (match-beginning 1)
|
|
2228 (1- (point))))
|
|
2229 (setq i 0)
|
|
2230 (while (setq i (string-match "[ \n\t]+" str i))
|
|
2231 (setq str (concat (substring str 0 i) " "
|
|
2232 (substring str (match-end 0))))
|
|
2233 (setq i (1+ i)))
|
|
2234 (setq items
|
|
2235 (cons str items))))
|
|
2236 (while (and items (< number 9))
|
|
2237 (setq current (car items)
|
|
2238 items (cdr items)
|
|
2239 number (1+ number))
|
28943
|
2240 (setq entries (cons `[,current
|
16043
|
2241 (Info-follow-reference ,current)
|
|
2242 t]
|
|
2243 entries)))
|
|
2244 (if items
|
|
2245 (setq entries (cons ["Other..." Info-follow-reference t]
|
|
2246 entries)))
|
|
2247 (or entries
|
37370
|
2248 (setq entries (list ["No references" nil nil] nil :active)))
|
16043
|
2249 (easy-menu-change '("Info") "Reference" (nreverse entries)))
|
|
2250 ;; Update last seen node.
|
21197
|
2251 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
|
16043
|
2252 ;; Try to avoid entering infinite beep mode in case of errors.
|
|
2253 (error (ding))))
|
|
2254
|
325
|
2255
|
36092
|
2256 (defun Info-copy-current-node-name ()
|
|
2257 "Put the name of the current info node into the kill ring.
|
|
2258 The name of the info file is prepended to the node name in parentheses."
|
|
2259 (interactive)
|
|
2260 (unless Info-current-node
|
|
2261 (error "No current info node"))
|
|
2262 (kill-new
|
|
2263 (concat "("
|
|
2264 (file-name-nondirectory
|
|
2265 (if (stringp Info-current-file)
|
|
2266 Info-current-file
|
|
2267 (or buffer-file-name "")))
|
|
2268 ")"
|
|
2269 Info-current-node)))
|
|
2270
|
|
2271
|
325
|
2272 ;; Info mode is suitable only for specially formatted data.
|
31798
460c3cd7b368
Use the correct capitalization when making Info-mode and Info-edit-mode
Miles Bader <miles@gnu.org>
diff
changeset
|
2273 (put 'Info-mode 'mode-class 'special)
|
40967
|
2274 (put 'Info-mode 'no-clone-indirect t)
|
325
|
2275
|
|
2276 (defun Info-mode ()
|
29621
|
2277 "Info mode provides commands for browsing through the Info documentation tree.
|
325
|
2278 Documentation in Info is divided into \"nodes\", each of which discusses
|
|
2279 one topic and contains references to other nodes which discuss related
|
|
2280 topics. Info has commands to follow the references and show you other nodes.
|
|
2281
|
29621
|
2282 \\<Info-mode-map>\
|
325
|
2283 \\[Info-help] Invoke the Info tutorial.
|
21806
|
2284 \\[Info-exit] Quit Info: reselect previously selected buffer.
|
325
|
2285
|
|
2286 Selecting other nodes:
|
8564
|
2287 \\[Info-mouse-follow-nearest-node]
|
|
2288 Follow a node reference you click on.
|
|
2289 This works with menu items, cross references, and
|
|
2290 the \"next\", \"previous\" and \"up\", depending on where you click.
|
21806
|
2291 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
|
325
|
2292 \\[Info-next] Move to the \"next\" node of this node.
|
3127
|
2293 \\[Info-prev] Move to the \"previous\" node of this node.
|
325
|
2294 \\[Info-up] Move \"up\" from this node.
|
|
2295 \\[Info-menu] Pick menu item specified by name (or abbreviation).
|
42406
|
2296 Picking a menu item causes another node to be selected.
|
540
|
2297 \\[Info-directory] Go to the Info directory node.
|
325
|
2298 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
|
|
2299 \\[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
|
2300 \\[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
|
2301 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
|
21806
|
2302 \\[Info-top-node] Go to the Top node of this file.
|
|
2303 \\[Info-final-node] Go to the final node in this file.
|
|
2304 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
|
|
2305 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
|
325
|
2306
|
|
2307 Moving within a node:
|
20514
|
2308 \\[Info-scroll-up] Normally, scroll forward a full screen.
|
42406
|
2309 Once you scroll far enough in a node that its menu appears on the
|
|
2310 screen but after point, the next scroll moves into its first
|
|
2311 subnode. When after all menu items (or if there is no menu),
|
|
2312 move up to the parent node.
|
20514
|
2313 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
|
42406
|
2314 already visible, try to go to the previous menu entry, or up
|
|
2315 if there is none.
|
28943
|
2316 \\[beginning-of-buffer] Go to beginning of node.
|
325
|
2317
|
|
2318 Advanced commands:
|
|
2319 \\[Info-exit] Quit Info: reselect previously selected buffer.
|
|
2320 \\[Info-edit] Edit contents of selected node.
|
|
2321 1 Pick first item in node's menu.
|
|
2322 2, 3, 4, 5 Pick second ... fifth item in node's menu.
|
|
2323 \\[Info-goto-node] Move to node specified by name.
|
42406
|
2324 You may include a filename as well, as (FILENAME)NODENAME.
|
4410
|
2325 \\[universal-argument] \\[info] Move to new Info file with completion.
|
325
|
2326 \\[Info-search] Search through this Info file for specified regexp,
|
42406
|
2327 and select the node in which the next occurrence is found.
|
4410
|
2328 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
|
|
2329 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
|
325
|
2330 (kill-all-local-variables)
|
|
2331 (setq major-mode 'Info-mode)
|
|
2332 (setq mode-name "Info")
|
16672
|
2333 (setq tab-width 8)
|
325
|
2334 (use-local-map Info-mode-map)
|
16043
|
2335 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
|
325
|
2336 (set-syntax-table text-mode-syntax-table)
|
|
2337 (setq local-abbrev-table text-mode-abbrev-table)
|
|
2338 (setq case-fold-search t)
|
|
2339 (setq buffer-read-only t)
|
|
2340 (make-local-variable 'Info-current-file)
|
|
2341 (make-local-variable 'Info-current-subfile)
|
|
2342 (make-local-variable 'Info-current-node)
|
|
2343 (make-local-variable 'Info-tag-table-marker)
|
16981
|
2344 (setq Info-tag-table-marker (make-marker))
|
|
2345 (make-local-variable 'Info-tag-table-buffer)
|
|
2346 (setq Info-tag-table-buffer nil)
|
325
|
2347 (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
|
2348 (make-local-variable 'Info-index-alternatives)
|
45775
|
2349 (make-local-variable 'Info-header-line)
|
32286
|
2350 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
|
19043
|
2351 ;; This is for the sake of the invisible text we use handling titles.
|
|
2352 (make-local-variable 'line-move-ignore-invisible)
|
|
2353 (setq line-move-ignore-invisible t)
|
33189
|
2354 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
|
47376
05b10b9cd8bb
(Info-mode): Add font-lock-defontify to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2355 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
|
325
|
2356 (Info-set-mode-line)
|
|
2357 (run-hooks 'Info-mode-hook))
|
|
2358
|
26004
|
2359 (defun Info-clone-buffer-hook ()
|
|
2360 (when (bufferp Info-tag-table-buffer)
|
|
2361 (setq Info-tag-table-buffer
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2362 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
|
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2363 (let ((m Info-tag-table-marker))
|
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2364 (when (markerp m)
|
38225
|
2365 (setq Info-tag-table-marker
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2366 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
|
38225
|
2367 (with-current-buffer Info-tag-table-buffer
|
|
2368 (copy-marker (marker-position m)))
|
|
2369 (make-marker))))))
|
26004
|
2370
|
32286
|
2371 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
|
|
2372 (set-keymap-parent map text-mode-map)
|
|
2373 (define-key map "\C-c\C-c" 'Info-cease-edit)
|
|
2374 map)
|
325
|
2375 "Local keymap used within `e' command of Info.")
|
|
2376
|
|
2377 ;; Info-edit mode is suitable only for specially formatted data.
|
31798
460c3cd7b368
Use the correct capitalization when making Info-mode and Info-edit-mode
Miles Bader <miles@gnu.org>
diff
changeset
|
2378 (put 'Info-edit-mode 'mode-class 'special)
|
325
|
2379
|
|
2380 (defun Info-edit-mode ()
|
|
2381 "Major mode for editing the contents of an Info node.
|
1477
|
2382 Like text mode with the addition of `Info-cease-edit'
|
325
|
2383 which returns to Info mode for browsing.
|
|
2384 \\{Info-edit-map}"
|
8805
|
2385 (use-local-map Info-edit-map)
|
|
2386 (setq major-mode 'Info-edit-mode)
|
|
2387 (setq mode-name "Info Edit")
|
|
2388 (kill-local-variable 'mode-line-buffer-identification)
|
|
2389 (setq buffer-read-only nil)
|
11580
|
2390 (force-mode-line-update)
|
8805
|
2391 (buffer-enable-undo (current-buffer))
|
|
2392 (run-hooks 'Info-edit-mode-hook))
|
325
|
2393
|
|
2394 (defun Info-edit ()
|
|
2395 "Edit the contents of this Info node.
|
|
2396 Allowed only if variable `Info-enable-edit' is non-nil."
|
|
2397 (interactive)
|
|
2398 (or Info-enable-edit
|
|
2399 (error "Editing info nodes is not enabled"))
|
8805
|
2400 (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
|
2401 (message "%s" (substitute-command-keys
|
29446
|
2402 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
|
325
|
2403
|
|
2404 (defun Info-cease-edit ()
|
|
2405 "Finish editing Info node; switch back to Info proper."
|
|
2406 (interactive)
|
|
2407 ;; Do this first, so nothing has changed if user C-g's at query.
|
|
2408 (and (buffer-modified-p)
|
|
2409 (y-or-n-p "Save the file? ")
|
|
2410 (save-buffer))
|
|
2411 (use-local-map Info-mode-map)
|
|
2412 (setq major-mode 'Info-mode)
|
|
2413 (setq mode-name "Info")
|
|
2414 (Info-set-mode-line)
|
|
2415 (setq buffer-read-only t)
|
11580
|
2416 (force-mode-line-update)
|
325
|
2417 (and (marker-position Info-tag-table-marker)
|
|
2418 (buffer-modified-p)
|
|
2419 (message "Tags may have changed. Use Info-tagify if necessary")))
|
359
|
2420
|
12889
|
2421 (defvar Info-file-list-for-emacs
|
39364
|
2422 '("ediff" "eudc" "forms" "gnus" "info" ("mh" . "mh-e")
|
|
2423 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
|
|
2424 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
|
|
2425 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
|
30738
|
2426 ("skeleton" . "autotype") ("auto-insert" . "autotype")
|
|
2427 ("copyright" . "autotype") ("executable" . "autotype")
|
|
2428 ("time-stamp" . "autotype") ("quickurl" . "autotype")
|
|
2429 ("tempo" . "autotype") ("hippie-expand" . "autotype")
|
40845
|
2430 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
|
|
2431 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
|
39364
|
2432 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
|
|
2433 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
|
|
2434 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
|
|
2435 ("rfc2045" . "emacs-mime")
|
|
2436 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
|
|
2437 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
|
|
2438 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
|
|
2439 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
|
|
2440 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
|
|
2441 ("mml" . "emacs-mime"))
|
12889
|
2442 "List of Info files that describe Emacs commands.
|
|
2443 An element can be a file name, or a list of the form (PREFIX . FILE)
|
|
2444 where PREFIX is a name prefix and FILE is the file to look in.
|
|
2445 If the element is just a file name, the file name also serves as the prefix.")
|
|
2446
|
359
|
2447 (defun Info-find-emacs-command-nodes (command)
|
12889
|
2448 "Return a list of locations documenting COMMAND.
|
12892
|
2449 The `info-file' property of COMMAND says which Info manual to search.
|
|
2450 If COMMAND has no property, the variable `Info-file-list-for-emacs'
|
|
2451 defines heuristics for which Info manual to try.
|
29621
|
2452 The locations are of the format used in `Info-history', i.e.
|
359
|
2453 \(FILENAME NODENAME BUFFERPOS\)."
|
|
2454 (let ((where '())
|
21641
|
2455 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
|
30763
|
2456 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\.$"))
|
12889
|
2457 (info-file "emacs")) ;default
|
|
2458 ;; Determine which info file this command is documented in.
|
|
2459 (if (get command 'info-file)
|
|
2460 (setq info-file (get command 'info-file))
|
|
2461 ;; If it doesn't say explicitly, test its name against
|
|
2462 ;; various prefixes that we know.
|
|
2463 (let ((file-list Info-file-list-for-emacs))
|
|
2464 (while file-list
|
|
2465 (let* ((elt (car file-list))
|
|
2466 (name (if (consp elt)
|
|
2467 (car elt)
|
|
2468 elt))
|
|
2469 (file (if (consp elt) (cdr elt) elt))
|
12892
|
2470 (regexp (concat "\\`" (regexp-quote name)
|
12889
|
2471 "\\(\\'\\|-\\)")))
|
|
2472 (if (string-match regexp (symbol-name command))
|
|
2473 (setq info-file file file-list nil))
|
|
2474 (setq file-list (cdr file-list))))))
|
30763
|
2475 (Info-find-node info-file "Top")
|
|
2476 (or (and (search-forward "\n* menu:" nil t)
|
|
2477 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
|
|
2478 (error "Info file `%s' appears to lack an index" info-file))
|
|
2479 (goto-char (match-beginning 1))
|
|
2480 ;; Bind Info-history to nil, to prevent the index nodes from
|
|
2481 ;; getting into the node history.
|
|
2482 (let ((Info-history nil)
|
|
2483 (exact nil)
|
|
2484 node found)
|
|
2485 (Info-goto-node (Info-extract-menu-node-name))
|
|
2486 (while
|
|
2487 (progn
|
|
2488 (goto-char (point-min))
|
|
2489 (while (re-search-forward cmd-desc nil t)
|
|
2490 (setq where
|
|
2491 (cons (list Info-current-file
|
|
2492 (match-string-no-properties 2)
|
29446
|
2493 0)
|
|
2494 where)))
|
30763
|
2495 (and (setq node (Info-extract-pointer "next" t))
|
|
2496 (string-match "\\<Index\\>" node)))
|
|
2497 (Info-goto-node node)))
|
|
2498 where))
|
359
|
2499
|
|
2500 ;;;###autoload
|
|
2501 (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
|
2502 "Go to the Info node in the Emacs manual for command COMMAND.
|
35112
|
2503 The command is found by looking up in Emacs manual's indices
|
12892
|
2504 or in another manual found via COMMAND's `info-file' property or
|
|
2505 the variable `Info-file-list-for-emacs'."
|
359
|
2506 (interactive "CFind documentation for command: ")
|
|
2507 (or (commandp command)
|
|
2508 (signal 'wrong-type-argument (list 'commandp command)))
|
|
2509 (let ((where (Info-find-emacs-command-nodes command)))
|
|
2510 (if where
|
|
2511 (let ((num-matches (length where)))
|
|
2512 ;; Get Info running, and pop to it in another window.
|
|
2513 (save-window-excursion
|
|
2514 (info))
|
16981
|
2515 ;; FIXME It would be cool if this could use a buffer other
|
|
2516 ;; than *info*.
|
359
|
2517 (pop-to-buffer "*info*")
|
30763
|
2518 ;; Bind Info-history to nil, to prevent the last Index node
|
|
2519 ;; visited by Info-find-emacs-command-nodes from being
|
|
2520 ;; pushed onto the history.
|
|
2521 (let ((Info-history nil))
|
|
2522 (Info-find-node (car (car where))
|
|
2523 (car (cdr (car where)))))
|
359
|
2524 (if (> num-matches 1)
|
|
2525 (progn
|
30763
|
2526 ;; (car where) will be pushed onto Info-history
|
|
2527 ;; when/if they go to another node. Put the other
|
|
2528 ;; nodes that were found on the history.
|
359
|
2529 (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
|
2530 (message "Found %d other entr%s. Use %s to see %s."
|
6049
|
2531 (1- num-matches)
|
|
2532 (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
|
2533 (substitute-command-keys "\\[Info-last]")
|
6049
|
2534 (if (> num-matches 2) "them" "it")))))
|
14355
|
2535 (error "Couldn't find documentation for %s" command))))
|
359
|
2536
|
|
2537 ;;;###autoload
|
|
2538 (defun Info-goto-emacs-key-command-node (key)
|
35112
|
2539 "Go to the node in the Emacs manual which describes the command bound to KEY.
|
|
2540 KEY is a string.
|
29621
|
2541 Interactively, if the binding is `execute-extended-command', a command is read.
|
35112
|
2542 The command is found by looking up in Emacs manual's indices
|
12892
|
2543 or in another manual found via COMMAND's `info-file' property or
|
|
2544 the variable `Info-file-list-for-emacs'."
|
30423
|
2545 (interactive "kFind documentation for key: ")
|
359
|
2546 (let ((command (key-binding key)))
|
|
2547 (cond ((null command)
|
1484
|
2548 (message "%s is undefined" (key-description key)))
|
359
|
2549 ((and (interactive-p)
|
|
2550 (eq command 'execute-extended-command))
|
|
2551 (Info-goto-emacs-command-node
|
|
2552 (read-command "Find documentation for command: ")))
|
|
2553 (t
|
|
2554 (Info-goto-emacs-command-node command)))))
|
4410
|
2555
|
27536
|
2556 (defface Info-title-1-face
|
32645
541dabe224ec
(Info-title-{1,2,3}-face): Change tty colors as suggested by Miles Bader.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2557 '((((type tty pc) (class color)) (:foreground "yellow" :weight bold))
|
32563
|
2558 (t (:height 1.2 :inherit Info-title-2-face)))
|
27536
|
2559 "Face for Info titles at level 1."
|
|
2560 :group 'info)
|
|
2561
|
|
2562 (defface Info-title-2-face
|
32645
541dabe224ec
(Info-title-{1,2,3}-face): Change tty colors as suggested by Miles Bader.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2563 '((((type tty pc) (class color)) (:foreground "lightblue" :weight bold))
|
32563
|
2564 (t (:height 1.2 :inherit Info-title-3-face)))
|
27536
|
2565 "Face for Info titles at level 2."
|
|
2566 :group 'info)
|
|
2567
|
|
2568 (defface Info-title-3-face
|
32645
541dabe224ec
(Info-title-{1,2,3}-face): Change tty colors as suggested by Miles Bader.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2569 '((((type tty pc) (class color)) (:weight bold))
|
32678
|
2570 (t (:height 1.2 :inherit Info-title-4-face)))
|
27536
|
2571 "Face for Info titles at level 3."
|
|
2572 :group 'info)
|
|
2573
|
32678
|
2574 (defface Info-title-4-face
|
|
2575 '((((type tty pc) (class color)) (:weight bold))
|
|
2576 (t (:weight bold :inherit variable-pitch)))
|
|
2577 "Face for Info titles at level 4."
|
|
2578 :group 'info)
|
|
2579
|
33136
|
2580 (defface info-menu-header
|
|
2581 '((((type tty pc))
|
33208
|
2582 :underline t
|
|
2583 :weight bold)
|
33136
|
2584 (t
|
33208
|
2585 :inherit variable-pitch
|
|
2586 :weight bold))
|
33136
|
2587 "Face for headers in Info menus."
|
|
2588 :group 'info)
|
|
2589
|
|
2590 (defun Info-fontify-menu-headers ()
|
|
2591 "Add the face `info-menu-header' to any header before a menu entry."
|
|
2592 (save-excursion
|
|
2593 (goto-char (point-min))
|
|
2594 (when (re-search-forward "\\* Menu:" nil t)
|
|
2595 (put-text-property (match-beginning 0) (match-end 0)
|
45688
|
2596 'font-lock-face 'info-menu-header)
|
33136
|
2597 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
|
|
2598 (put-text-property (match-beginning 1) (match-end 1)
|
45688
|
2599 'font-lock-face 'info-menu-header)))))
|
33136
|
2600
|
45784
|
2601 (defvar Info-next-link-keymap
|
|
2602 (let ((keymap (make-sparse-keymap)))
|
|
2603 (define-key keymap [header-line mouse-1] 'Info-next)
|
|
2604 (define-key keymap [header-line mouse-2] 'Info-next)
|
|
2605 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
2606 (define-key keymap [mouse-2] 'Info-next)
|
|
2607 keymap)
|
|
2608 "Keymap to put on the Next link in the text or the header line.")
|
|
2609
|
|
2610 (defvar Info-prev-link-keymap
|
|
2611 (let ((keymap (make-sparse-keymap)))
|
|
2612 (define-key keymap [header-line mouse-1] 'Info-prev)
|
|
2613 (define-key keymap [header-line mouse-2] 'Info-prev)
|
|
2614 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
2615 (define-key keymap [mouse-2] 'Info-prev)
|
|
2616 keymap)
|
|
2617 "Keymap to put on the Prev link in the text or the header line.")
|
|
2618
|
|
2619
|
|
2620 (defvar Info-up-link-keymap
|
|
2621 (let ((keymap (make-sparse-keymap)))
|
|
2622 (define-key keymap [header-line mouse-1] 'Info-up)
|
|
2623 (define-key keymap [header-line mouse-2] 'Info-up)
|
|
2624 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
2625 (define-key keymap [mouse-2] 'Info-up)
|
|
2626 keymap)
|
|
2627 "Keymap to put on the Up link in the text or the header line.")
|
|
2628
|
4410
|
2629 (defun Info-fontify-node ()
|
39746
|
2630 ;; Only fontify the node if it hasn't already been done. [We pass in
|
|
2631 ;; LIMIT arg to `next-property-change' because it seems to search past
|
|
2632 ;; (point-max).]
|
45775
|
2633 (unless (< (next-property-change (point-min) nil (point-max))
|
|
2634 (point-max))
|
39746
|
2635 (save-excursion
|
|
2636 (let ((buffer-read-only nil)
|
|
2637 (case-fold-search t))
|
|
2638 (goto-char (point-min))
|
|
2639 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
|
21704
|
2640 (goto-char (match-end 0))
|
39746
|
2641 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
|
|
2642 (goto-char (match-end 0))
|
|
2643 (let* ((nbeg (match-beginning 2))
|
|
2644 (nend (match-end 2))
|
|
2645 (tbeg (match-beginning 1))
|
|
2646 (tag (buffer-substring tbeg (match-end 1))))
|
|
2647 (if (string-equal tag "Node")
|
45688
|
2648 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
|
|
2649 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
|
43776
|
2650 (put-text-property tbeg nend 'mouse-face 'highlight)
|
39746
|
2651 (put-text-property tbeg nend
|
|
2652 'help-echo
|
|
2653 (concat "Go to node "
|
|
2654 (buffer-substring nbeg nend)))
|
45775
|
2655 ;; Always set up the text property keymap.
|
45784
|
2656 ;; It will either be used in the buffer
|
45775
|
2657 ;; or copied in the header line.
|
45784
|
2658 (cond ((equal tag "Prev")
|
|
2659 (put-text-property tbeg nend 'keymap
|
|
2660 Info-prev-link-keymap))
|
|
2661 ((equal tag "Next")
|
|
2662 (put-text-property tbeg nend 'keymap
|
|
2663 Info-next-link-keymap))
|
|
2664 ((equal tag "Up")
|
|
2665 (put-text-property tbeg nend 'keymap
|
|
2666 Info-up-link-keymap))))))
|
45775
|
2667 (goto-char (point-min))
|
45784
|
2668 (let ((header-end (save-excursion (end-of-line) (point)))
|
|
2669 header)
|
|
2670 ;; If we find neither Next: nor Prev: link, show the entire
|
|
2671 ;; node header. Otherwise, don't show the File: and Node:
|
|
2672 ;; parts, to avoid wasting precious space on information that
|
|
2673 ;; is available in the mode line.
|
|
2674 (if (re-search-forward
|
|
2675 "\\(next\\|up\\|prev[ious]*\\): "
|
|
2676 header-end t)
|
|
2677 (progn
|
|
2678 (goto-char (match-beginning 1))
|
|
2679 (setq header (buffer-substring (point) header-end)))
|
|
2680 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*" nil t)
|
|
2681 (setq header
|
|
2682 (concat "No next, prev or up links -- "
|
|
2683 (buffer-substring (point) header-end)))
|
|
2684 (setq header (buffer-substring (point) header-end))))
|
|
2685
|
45775
|
2686 (put-text-property (point-min) (1+ (point-min))
|
45784
|
2687 'header-line header)
|
|
2688 ;; Hide the part of the first line
|
|
2689 ;; that is in the header, if it is just part.
|
|
2690 (unless (bobp)
|
|
2691 ;; Hide the punctuation at the end, too.
|
|
2692 (skip-chars-backward " \t,")
|
|
2693 (put-text-property (point) header-end 'invisible t))))
|
39746
|
2694 (goto-char (point-min))
|
|
2695 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
|
|
2696 nil t)
|
45458
|
2697 (let* ((c (preceding-char))
|
45688
|
2698 (face
|
45458
|
2699 (cond ((= c ?*) 'Info-title-1-face)
|
|
2700 ((= c ?=) 'Info-title-2-face)
|
|
2701 ((= c ?-) 'Info-title-3-face)
|
|
2702 (t 'Info-title-4-face))))
|
39746
|
2703 (put-text-property (match-beginning 1) (match-end 1)
|
45688
|
2704 'font-lock-face face))
|
39746
|
2705 ;; This is a serious problem for trying to handle multiple
|
|
2706 ;; frame types at once. We want this text to be invisible
|
|
2707 ;; on frames that can display the font above.
|
|
2708 (when (memq (framep (selected-frame)) '(x pc w32 mac))
|
42432
|
2709 (add-text-properties (match-beginning 2) (1+ (match-end 2))
|
|
2710 '(invisible t intangible t))))
|
39746
|
2711 (goto-char (point-min))
|
|
2712 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
|
|
2713 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
|
|
2714 nil
|
|
2715 (add-text-properties (match-beginning 1) (match-end 1)
|
45688
|
2716 '(font-lock-face info-xref
|
39746
|
2717 mouse-face highlight
|
|
2718 help-echo "mouse-2: go to this node"))))
|
|
2719 (goto-char (point-min))
|
|
2720 (if (and (search-forward "\n* Menu:" nil t)
|
|
2721 (not (string-match "\\<Index\\>" Info-current-node))
|
|
2722 ;; Don't take time to annotate huge menus
|
|
2723 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
|
|
2724 (let ((n 0))
|
|
2725 (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t)
|
|
2726 (setq n (1+ n))
|
40793
|
2727 (if (zerop (% n 3)) ; visual aids to help with 1-9 keys
|
39746
|
2728 (put-text-property (match-beginning 0)
|
|
2729 (1+ (match-beginning 0))
|
45688
|
2730 'font-lock-face 'info-menu-5))
|
39746
|
2731 (add-text-properties (match-beginning 1) (match-end 1)
|
45688
|
2732 '(font-lock-face info-xref
|
39746
|
2733 mouse-face highlight
|
|
2734 help-echo "mouse-2: go to this node")))))
|
|
2735 (Info-fontify-menu-headers)
|
|
2736 (set-buffer-modified-p nil)))))
|
16981
|
2737
|
|
2738
|
|
2739 ;; When an Info buffer is killed, make sure the associated tags buffer
|
|
2740 ;; is killed too.
|
|
2741 (defun Info-kill-buffer ()
|
|
2742 (and (eq major-mode 'Info-mode)
|
|
2743 Info-tag-table-buffer
|
|
2744 (kill-buffer Info-tag-table-buffer)))
|
|
2745
|
|
2746 (add-hook 'kill-buffer-hook 'Info-kill-buffer)
|
20755
|
2747
|
|
2748 ;;; Speedbar support:
|
|
2749 ;; These functions permit speedbar to display the "tags" in the
|
|
2750 ;; current info node.
|
22733
|
2751 (eval-when-compile (require 'speedbar))
|
20755
|
2752
|
22733
|
2753 (defvar Info-speedbar-key-map nil
|
|
2754 "Keymap used when in the info display mode.")
|
|
2755
|
|
2756 (defun Info-install-speedbar-variables ()
|
|
2757 "Install those variables used by speedbar to enhance Info."
|
|
2758 (if Info-speedbar-key-map
|
|
2759 nil
|
|
2760 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
|
20755
|
2761
|
22733
|
2762 ;; Basic tree features
|
|
2763 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
|
|
2764 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
|
|
2765 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
|
|
2766 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
|
|
2767 )
|
|
2768
|
|
2769 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
|
|
2770 Info-speedbar-key-map
|
|
2771 Info-speedbar-hierarchy-buttons)))
|
20755
|
2772
|
|
2773 (defvar Info-speedbar-menu-items
|
22733
|
2774 '(["Browse Node" speedbar-edit-line t]
|
|
2775 ["Expand Node" speedbar-expand-line
|
|
2776 (save-excursion (beginning-of-line)
|
|
2777 (looking-at "[0-9]+: *.\\+. "))]
|
|
2778 ["Contract Node" speedbar-contract-line
|
|
2779 (save-excursion (beginning-of-line)
|
|
2780 (looking-at "[0-9]+: *.-. "))]
|
|
2781 )
|
20755
|
2782 "Additional menu-items to add to speedbar frame.")
|
|
2783
|
22733
|
2784 ;; Make sure our special speedbar major mode is loaded
|
|
2785 (if (featurep 'speedbar)
|
|
2786 (Info-install-speedbar-variables)
|
|
2787 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
|
|
2788
|
|
2789 ;;; Info hierarchy display method
|
|
2790 ;;;###autoload
|
|
2791 (defun Info-speedbar-browser ()
|
|
2792 "Initialize speedbar to display an info node browser.
|
|
2793 This will add a speedbar major display mode."
|
|
2794 (interactive)
|
|
2795 (require 'speedbar)
|
|
2796 ;; Make sure that speedbar is active
|
|
2797 (speedbar-frame-mode 1)
|
|
2798 ;; Now, throw us into Info mode on speedbar.
|
|
2799 (speedbar-change-initial-expansion-list "Info")
|
|
2800 )
|
|
2801
|
32286
|
2802 (eval-when-compile (defvar speedbar-attached-frame))
|
|
2803
|
22733
|
2804 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
|
|
2805 "Display an Info directory hierarchy in speedbar.
|
|
2806 DIRECTORY is the current directory in the attached frame.
|
|
2807 DEPTH is the current indentation depth.
|
|
2808 NODE is an optional argument that is used to represent the
|
|
2809 specific node to expand."
|
|
2810 (if (and (not node)
|
|
2811 (save-excursion (goto-char (point-min))
|
22951
|
2812 (let ((case-fold-search t))
|
|
2813 (looking-at "Info Nodes:"))))
|
22733
|
2814 ;; Update our "current node" maybe?
|
|
2815 nil
|
|
2816 ;; We cannot use the generic list code, that depends on all leaves
|
|
2817 ;; being known at creation time.
|
|
2818 (if (not node)
|
|
2819 (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
|
2820 (let ((completions nil)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2821 (cf (selected-frame)))
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2822 (select-frame speedbar-attached-frame)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2823 (save-window-excursion
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2824 (setq completions
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
2825 (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
|
2826 (select-frame cf)
|
22733
|
2827 (if completions
|
|
2828 (speedbar-with-writable
|
|
2829 (while completions
|
|
2830 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
|
|
2831 (cdr (car completions))
|
|
2832 (car (car completions))
|
|
2833 'Info-speedbar-goto-node
|
|
2834 (cdr (car completions))
|
|
2835 'info-xref depth)
|
|
2836 (setq completions (cdr completions)))
|
|
2837 t)
|
|
2838 nil))))
|
28943
|
2839
|
22733
|
2840 (defun Info-speedbar-goto-node (text node indent)
|
32500
|
2841 "When user clicks on TEXT, go to an info NODE.
|
22733
|
2842 The INDENT level is ignored."
|
29446
|
2843 (select-frame speedbar-attached-frame)
|
|
2844 (let* ((buff (or (get-buffer "*info*")
|
|
2845 (progn (info) (get-buffer "*info*"))))
|
|
2846 (bwin (get-buffer-window buff 0)))
|
|
2847 (if bwin
|
|
2848 (progn
|
|
2849 (select-window bwin)
|
|
2850 (raise-frame (window-frame bwin)))
|
|
2851 (if speedbar-power-click
|
|
2852 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
|
|
2853 (select-frame speedbar-attached-frame)
|
|
2854 (switch-to-buffer buff)))
|
|
2855 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
|
|
2856 (file (match-string 1 node))
|
|
2857 (node (match-string 2 node)))
|
|
2858 (Info-find-node file node)
|
|
2859 ;; If we do a find-node, and we were in info mode, restore
|
|
2860 ;; the old default method. Once we are in info mode, it makes
|
|
2861 ;; sense to return to whatever method the user was using before.
|
|
2862 (if (string= speedbar-initial-expansion-list-name "Info")
|
|
2863 (speedbar-change-initial-expansion-list
|
|
2864 speedbar-previously-used-expansion-list-name)))))
|
22733
|
2865
|
|
2866 (defun Info-speedbar-expand-node (text token indent)
|
|
2867 "Expand the node the user clicked on.
|
|
2868 TEXT is the text of the button we clicked on, a + or - item.
|
|
2869 TOKEN is data related to this node (NAME . FILE).
|
|
2870 INDENT is the current indentation depth."
|
|
2871 (cond ((string-match "+" text) ;we have to expand this file
|
|
2872 (speedbar-change-expand-button-char ?-)
|
|
2873 (if (speedbar-with-writable
|
29446
|
2874 (save-excursion
|
|
2875 (end-of-line) (forward-char 1)
|
|
2876 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
|
22733
|
2877 (speedbar-change-expand-button-char ?-)
|
|
2878 (speedbar-change-expand-button-char ??)))
|
|
2879 ((string-match "-" text) ;we have to contract this node
|
|
2880 (speedbar-change-expand-button-char ?+)
|
|
2881 (speedbar-delete-subblock indent))
|
|
2882 (t (error "Ooops... not sure what to do")))
|
|
2883 (speedbar-center-buffer-smartly))
|
|
2884
|
|
2885 (defun Info-speedbar-fetch-file-nodes (nodespec)
|
|
2886 "Fetch the subnodes from the info NODESPEC.
|
|
2887 NODESPEC is a string of the form: (file)node.
|
|
2888 Optional THISFILE represends the filename of"
|
|
2889 (save-excursion
|
|
2890 ;; Set up a buffer we can use to fake-out Info.
|
|
2891 (set-buffer (get-buffer-create "*info-browse-tmp*"))
|
|
2892 (if (not (equal major-mode 'Info-mode))
|
|
2893 (Info-mode))
|
|
2894 ;; Get the node into this buffer
|
|
2895 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
|
|
2896 (file (match-string 1 nodespec))
|
|
2897 (node (match-string 2 nodespec)))
|
|
2898 (Info-find-node file node))
|
|
2899 ;; Scan the created buffer
|
|
2900 (goto-char (point-min))
|
|
2901 (let ((completions nil)
|
22951
|
2902 (case-fold-search t)
|
22733
|
2903 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
|
|
2904 (match-string 1 nodespec))))
|
|
2905 ;; Always skip the first one...
|
|
2906 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
2907 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
2908 (let ((name (match-string 1)))
|
|
2909 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
|
|
2910 (setq name (cons name (match-string 1)))
|
|
2911 (if (looking-at " *\\(([^)]+)\\)\\.")
|
|
2912 (setq name (cons name (concat (match-string 1) "Top")))
|
|
2913 (if (looking-at " \\([^.]+\\).")
|
|
2914 (setq name
|
|
2915 (cons name (concat "(" thisfile ")" (match-string 1))))
|
|
2916 (setq name (cons name (concat "(" thisfile ")" name))))))
|
|
2917 (setq completions (cons name completions))))
|
|
2918 (nreverse completions))))
|
|
2919
|
|
2920 ;;; Info mode node listing
|
20755
|
2921 (defun Info-speedbar-buttons (buffer)
|
|
2922 "Create a speedbar display to help navigation in an Info file.
|
|
2923 BUFFER is the buffer speedbar is requesting buttons for."
|
22733
|
2924 (if (save-excursion (goto-char (point-min))
|
22951
|
2925 (let ((case-fold-search t))
|
|
2926 (not (looking-at "Info Nodes:"))))
|
22733
|
2927 (erase-buffer))
|
|
2928 (Info-speedbar-hierarchy-buttons nil 0)
|
|
2929 )
|
584
|
2930
|
28558
|
2931 (dolist (mess '("^Node has no Previous$"
|
|
2932 "^No menu in this node$"
|
|
2933 "^Node has no Next$"
|
28943
|
2934 "^No cross-references in this node^"
|
|
2935 search-failed
|
28558
|
2936 "^No \".*\" in index$"))
|
|
2937 (add-to-list 'debug-ignored-errors mess))
|
|
2938
|
584
|
2939 (provide 'info)
|
|
2940
|
660
|
2941 ;;; info.el ends here
|