38412
|
1 ;;; info.el --- info package for Emacs
|
807
|
2
|
54506
|
3 ;; Copyright (C) 1985,86,92,93,94,95,96,97,98,99,2000,01,02,03,2004
|
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.
|
49424
|
29 ;; In particular we make these assumptions:
|
|
30 ;; - a menu item MAY contain colons but not colon-space ": "
|
|
31 ;; - a menu item ending with ": " (but not ":: ") is an index entry
|
|
32 ;; - a node name MAY NOT contain a colon
|
49426
|
33 ;; This distinction is to support indexing of computer programming
|
|
34 ;; language terms that may contain ":" but not ": ".
|
807
|
35
|
|
36 ;;; Code:
|
|
37
|
25869
|
38 (eval-when-compile (require 'jka-compr))
|
|
39
|
17430
|
40 (defgroup info nil
|
|
41 "Info subsystem"
|
|
42 :group 'help
|
|
43 :group 'docs)
|
|
44
|
|
45
|
325
|
46 (defvar Info-history nil
|
54754
|
47 "Stack of info nodes user has visited.
|
325
|
48 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
|
|
49
|
54754
|
50 (defvar Info-history-list nil
|
|
51 "List of all info nodes user has visited.
|
|
52 Each element of list is a list (FILENAME NODENAME).")
|
|
53
|
17430
|
54 (defcustom Info-enable-edit nil
|
3084
|
55 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
|
680
|
56 This is convenient if you want to write info files by hand.
|
|
57 However, we recommend that you not do this.
|
|
58 It is better to write a Texinfo file and generate the Info file from that,
|
17430
|
59 because that gives you a printed manual as well."
|
|
60 :type 'boolean
|
|
61 :group 'info)
|
325
|
62
|
15177
|
63 (defvar Info-enable-active-nodes nil
|
325
|
64 "Non-nil allows Info to execute Lisp code associated with nodes.
|
|
65 The Lisp code is executed when the node is selected.")
|
15177
|
66 (put 'Info-enable-active-nodes 'risky-local-variable t)
|
325
|
67
|
19043
|
68 (defface info-node
|
55061
|
69 '((((class color) (background light)) :foreground "brown" :weight bold :slant italic)
|
|
70 (((class color) (background dark)) :foreground "white" :weight bold :slant italic)
|
|
71 (t :weight bold :slant italic))
|
19043
|
72 "Face for Info node names."
|
|
73 :group 'info)
|
|
74
|
|
75 (defface info-menu-5
|
55061
|
76 '((((class color)) :foreground "red1")
|
|
77 (t :underline t))
|
46029
|
78 "Face for every third `*' in an Info menu."
|
19043
|
79 :group 'info)
|
|
80
|
|
81 (defface info-xref
|
57468
|
82 '((((class color) (background light)) :foreground "blue" :underline t)
|
|
83 (((class color) (background dark)) :foreground "cyan" :underline t)
|
55061
|
84 (t :underline t))
|
19043
|
85 "Face for Info cross-references."
|
|
86 :group 'info)
|
|
87
|
54754
|
88 (defface info-xref-visited
|
55061
|
89 '((t :inherit info-xref)
|
|
90 (((class color) (background light)) :foreground "magenta4")
|
55174
|
91 (((class color) (background dark)) :foreground "magenta3")) ;"violet"?
|
54754
|
92 "Face for visited Info cross-references."
|
|
93 :group 'info)
|
|
94
|
|
95 (defcustom Info-fontify-visited-nodes t
|
|
96 "*Non-nil means to fontify visited nodes in a different face."
|
|
97 :version "21.4"
|
|
98 :type 'boolean
|
|
99 :group 'info)
|
|
100
|
28168
|
101 (defcustom Info-fontify-maximum-menu-size 100000
|
46029
|
102 "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
|
17430
|
103 :type 'integer
|
|
104 :group 'info)
|
8480
|
105
|
31660
|
106 (defcustom Info-use-header-line t
|
46326
|
107 "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
|
31660
|
108 A header-line does not scroll with the rest of the buffer."
|
|
109 :type 'boolean
|
|
110 :group 'info)
|
|
111
|
|
112 (defface info-header-xref
|
55061
|
113 '((t :inherit info-xref))
|
31660
|
114 "Face for Info cross-references in a node header."
|
|
115 :group 'info)
|
|
116
|
|
117 (defface info-header-node
|
55061
|
118 '((t :inherit info-node))
|
31660
|
119 "Face for Info nodes in a node header."
|
|
120 :group 'info)
|
|
121
|
25145
|
122 (defvar Info-directory-list nil
|
325
|
123 "List of directories to search for Info documentation files.
|
46252
|
124 If nil, meaning not yet initialized, Info uses the environment
|
1979
|
125 variable INFOPATH to initialize it, or `Info-default-directory-list'
|
51434
|
126 if there is no INFOPATH variable in the environment, or the
|
|
127 concatenation of the two if INFOPATH ends with a colon.
|
31324
|
128
|
|
129 When `Info-directory-list' is initialized from the value of
|
34574
|
130 `Info-default-directory-list', and Emacs is installed in one of the
|
|
131 standard directories, the directory of Info files that come with Emacs
|
|
132 is put last (so that local Info files override standard ones).
|
|
133
|
|
134 When `Info-directory-list' is initialized from the value of
|
|
135 `Info-default-directory-list', and Emacs is not installed in one
|
|
136 of the standard directories, the first element of the resulting
|
31324
|
137 list is the directory where Emacs installs the Info files that
|
|
138 come with it. This is so that Emacs's own manual, which suits the
|
34574
|
139 version of Emacs you are using, will always be found first. This
|
|
140 is useful when you install an experimental version of Emacs without
|
|
141 removing the standard installation.
|
|
142
|
|
143 If you want to override the order of directories in
|
|
144 `Info-default-directory-list', set INFOPATH in the environment.
|
8461
|
145
|
|
146 If you run the Emacs executable from the `src' directory in the Emacs
|
31324
|
147 source tree, and INFOPATH is not defined, the `info' directory in the
|
|
148 source tree is used as the first element of `Info-directory-list', in
|
|
149 place of the installation Info directory. This is useful when you run
|
|
150 a version of Emacs without installing it.")
|
325
|
151
|
17430
|
152 (defcustom Info-additional-directory-list nil
|
8480
|
153 "List of additional directories to search for Info documentation files.
|
48582
|
154 These directories are searched after those in `Info-directory-list'."
|
17430
|
155 :type '(repeat directory)
|
|
156 :group 'info)
|
8480
|
157
|
51709
02d430615dd4
(Info-fontify-menu-headers): Only fontify `* Menu:' at the beginning
Luc Teirlinck <teirllm@auburn.edu>
diff
changeset
|
158 (defcustom Info-scroll-prefer-subnodes nil
|
34182
|
159 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
|
|
160 If this is non-nil, and you scroll far enough in a node that its menu
|
|
161 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
|
|
162 moves to a subnode indicated by the following menu item. This means
|
|
163 that you visit a subnode before getting to the end of the menu.
|
|
164
|
|
165 Setting this option to nil results in behavior similar to the stand-alone
|
|
166 Info reader program, which visits the first subnode from the menu only
|
|
167 when you hit the end of the current node."
|
52216
9c9f228688f7
(Info-scroll-prefer-subnodes): Add :version keyword to defcustom,
Luc Teirlinck <teirllm@auburn.edu>
diff
changeset
|
168 :version "21.4"
|
34182
|
169 :type 'boolean
|
|
170 :group 'info)
|
|
171
|
48107
|
172 (defcustom Info-hide-note-references t
|
48118
|
173 "*If non-nil, hide the tag and section reference in *note and * menu items.
|
54754
|
174 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\".
|
|
175 If value is non-nil but not t or `hide', the reference section is still shown."
|
48118
|
176 :version "21.4"
|
54754
|
177 :type '(choice (const :tag "No hiding" nil)
|
50004
|
178 (const :tag "Replace tag and hide reference" t)
|
54754
|
179 (const :tag "Hide tag and reference" hide)
|
|
180 (other :tag "Only replace tag" tag))
|
48107
|
181 :group 'info)
|
|
182
|
51731
|
183 (defcustom Info-refill-paragraphs nil
|
|
184 "*If non-nil, attempt to refill paragraphs with hidden references.
|
|
185 This refilling may accidentally remove explicit line breaks in the info
|
|
186 file, so be prepared for a few surprises if you enable this feature."
|
|
187 :version "21.4"
|
|
188 :type 'boolean
|
|
189 :group 'info)
|
|
190
|
56866
|
191 (defcustom Info-search-whitespace-regexp "\\(?:\\s-+\\)"
|
54754
|
192 "*If non-nil, regular expression to match a sequence of whitespace chars.
|
|
193 This applies to Info search for regular expressions.
|
|
194 You might want to use something like \"[ \\t\\r\\n]+\" instead.
|
|
195 In the Customization buffer, that is `[' followed by a space,
|
|
196 a tab, a carriage return (control-M), a newline, and `]+'."
|
|
197 :type 'regexp
|
|
198 :group 'info)
|
|
199
|
51434
|
200 (defcustom Info-mode-hook
|
|
201 ;; Try to obey obsolete Info-fontify settings.
|
|
202 (unless (and (boundp 'Info-fontify) (null Info-fontify))
|
|
203 '(turn-on-font-lock))
|
54754
|
204 "Hooks run when `Info-mode' is called."
|
45458
|
205 :type 'hook
|
|
206 :group 'info)
|
|
207
|
54754
|
208 (defcustom Info-selection-hook nil
|
|
209 "Hooks run when `Info-select-node' is called."
|
|
210 :type 'hook
|
|
211 :group 'info)
|
|
212
|
|
213 (defvar Info-edit-mode-hook nil
|
|
214 "Hooks run when `Info-edit-mode' is called.")
|
|
215
|
325
|
216 (defvar Info-current-file nil
|
12646
|
217 "Info file that Info is now looking at, or nil.
|
|
218 This is the name that was specified in Info, not the actual file name.
|
26004
|
219 It doesn't contain directory names or file name extensions added by Info.
|
|
220 Can also be t when using `Info-on-current-buffer'.")
|
325
|
221
|
|
222 (defvar Info-current-subfile nil
|
29621
|
223 "Info subfile that is actually in the *info* buffer now.
|
|
224 nil if current info file is not split into subfiles.")
|
325
|
225
|
|
226 (defvar Info-current-node nil
|
|
227 "Name of node that Info is now looking at, or nil.")
|
|
228
|
16981
|
229 (defvar Info-tag-table-marker nil
|
325
|
230 "Marker pointing at beginning of current Info file's tag table.
|
|
231 Marker points nowhere if file has no tag table.")
|
|
232
|
16981
|
233 (defvar Info-tag-table-buffer nil
|
|
234 "Buffer used for indirect tag tables.")
|
|
235
|
4410
|
236 (defvar Info-current-file-completions nil
|
|
237 "Cached completion list for current Info file.")
|
|
238
|
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
|
239 (defvar Info-index-alternatives nil
|
29621
|
240 "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
|
241
|
55174
|
242 (defvar Info-point-loc nil
|
|
243 "Point location within a selected node.
|
|
244 If string, the point is moved to the proper occurrence of the
|
|
245 name of the followed cross reference within a selected node.
|
|
246 If number, the point is moved to the corresponding line.")
|
54754
|
247
|
4410
|
248 (defvar Info-standalone nil
|
|
249 "Non-nil if Emacs was started solely as an Info browser.")
|
25145
|
250
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
251 (defvar Info-suffix-list
|
19937
|
252 ;; The MS-DOS list should work both when long file names are
|
|
253 ;; 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
|
254 (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
|
255 '( (".gz" . "gunzip")
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
256 (".z" . "gunzip")
|
34503
|
257 (".bz2" . ("bzip2" "-dc"))
|
19937
|
258 (".inz" . "gunzip")
|
|
259 (".igz" . "gunzip")
|
|
260 (".info.Z" . "gunzip")
|
|
261 (".info.gz" . "gunzip")
|
|
262 ("-info.Z" . "gunzip")
|
|
263 ("-info.gz" . "gunzip")
|
|
264 ("/index.gz". "gunzip")
|
|
265 ("/index.z" . "gunzip")
|
13004
|
266 (".inf" . nil)
|
19937
|
267 (".info" . nil)
|
|
268 ("-info" . nil)
|
|
269 ("/index" . nil)
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
270 ("" . nil))
|
17941
|
271 '( (".info.Z". "uncompress")
|
|
272 (".info.Y". "unyabba")
|
|
273 (".info.gz". "gunzip")
|
|
274 (".info.z". "gunzip")
|
34503
|
275 (".info.bz2" . ("bzip2" "-dc"))
|
17941
|
276 (".info". nil)
|
|
277 ("-info.Z". "uncompress")
|
|
278 ("-info.Y". "unyabba")
|
|
279 ("-info.gz". "gunzip")
|
34503
|
280 ("-info.bz2" . ("bzip2" "-dc"))
|
17941
|
281 ("-info.z". "gunzip")
|
|
282 ("-info". nil)
|
|
283 ("/index.Z". "uncompress")
|
|
284 ("/index.Y". "unyabba")
|
|
285 ("/index.gz". "gunzip")
|
|
286 ("/index.z". "gunzip")
|
34503
|
287 ("/index.bz2". ("bzip2" "-dc"))
|
17941
|
288 ("/index". nil)
|
|
289 (".Z". "uncompress")
|
|
290 (".Y". "unyabba")
|
|
291 (".gz". "gunzip")
|
|
292 (".z". "gunzip")
|
34503
|
293 (".bz2" . ("bzip2" "-dc"))
|
17941
|
294 ("". 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
|
295 "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
|
296 Each entry should be (SUFFIX . STRING); the file is given to
|
34503
|
297 the command as standard input.
|
|
298
|
|
299 STRING may be a list of strings. In that case, the first element is
|
|
300 the command name, and the rest are arguments to that command.
|
|
301
|
|
302 If STRING is nil, no decoding is done.
|
6566
|
303 Because the SUFFIXes are tried in order, the empty string should
|
|
304 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
|
305
|
13562
|
306 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
|
36452
|
307 ;; First, on MS-DOS with no long file names support, delete some of
|
|
308 ;; the extension in FILENAME to make room.
|
|
309 (defun info-insert-file-contents-1 (filename suffix lfn)
|
|
310 (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
|
311 (concat filename suffix)
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
312 (let* ((sans-exts (file-name-sans-extension filename))
|
13562
|
313 ;; How long is the extension in FILENAME (not counting the dot).
|
|
314 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
|
|
315 ext-left)
|
13004
|
316 ;; SUFFIX starts with a dot. If FILENAME already has one,
|
14577
|
317 ;; get rid of the one in SUFFIX (unless suffix is empty).
|
13562
|
318 (or (and (<= ext-len 0)
|
13004
|
319 (not (eq (aref filename (1- (length filename))) ?.)))
|
14577
|
320 (= (length suffix) 0)
|
13004
|
321 (setq suffix (substring suffix 1)))
|
13562
|
322 ;; How many chars of that extension should we keep?
|
|
323 (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
|
324 ;; 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
|
325 (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
|
326 (- 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
|
327 suffix))))
|
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
328
|
22067
|
329 (defun info-file-exists-p (filename)
|
|
330 (and (file-exists-p filename)
|
|
331 (not (file-directory-p filename))))
|
|
332
|
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
|
333 (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
|
334 "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
|
335 Do the right thing if the file has been compressed or zipped."
|
36452
|
336 (let* ((tail Info-suffix-list)
|
49467
|
337 (lfn (if (fboundp 'msdos-long-file-names)
|
|
338 (msdos-long-file-names)
|
|
339 t))
|
36452
|
340 (check-short (and (fboundp 'msdos-long-file-names)
|
|
341 lfn))
|
|
342 fullname decoder done)
|
38679
|
343 (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
|
344 ;; 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
|
345 ;; If so, set DECODE accordingly.
|
6566
|
346 (progn
|
|
347 (while (and tail
|
|
348 (not (string-match
|
|
349 (concat (regexp-quote (car (car tail))) "$")
|
|
350 filename)))
|
|
351 (setq tail (cdr tail)))
|
|
352 (setq fullname filename
|
|
353 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
|
354 ;; Try adding suffixes to FILENAME and see if we can find something.
|
36452
|
355 (while (and tail (not done))
|
|
356 (setq fullname (info-insert-file-contents-1 filename
|
|
357 (car (car tail)) lfn))
|
|
358 (if (info-file-exists-p fullname)
|
|
359 (setq done t
|
|
360 ;; If we found a file with a suffix, set DECODER
|
|
361 ;; according to the suffix.
|
|
362 decoder (cdr (car tail)))
|
|
363 ;; When the MS-DOS port runs on Windows, we need to check
|
|
364 ;; the short variant of a long file name as well.
|
|
365 (when check-short
|
|
366 (setq fullname (info-insert-file-contents-1 filename
|
|
367 (car (car tail)) nil))
|
|
368 (if (info-file-exists-p fullname)
|
|
369 (setq done t
|
|
370 decoder (cdr (car tail))))))
|
6566
|
371 (setq tail (cdr tail)))
|
|
372 (or tail
|
12927
d3cda9e7c55f
(Info-suffix-list): For MS-DOS, use gunzip as the only uncompressor,
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
373 (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
|
374 ;; 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
|
375 (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
|
376 (jka-compr-installed-p)
|
7d465ccfd45b
(info-insert-file-contents): Always check for conflict with jka-compr.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
377 (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
|
378 (setq decoder nil))
|
6566
|
379 (if decoder
|
19937
|
380 (progn
|
|
381 (insert-file-contents-literally fullname visit)
|
|
382 (let ((buffer-read-only nil)
|
|
383 (coding-system-for-write 'no-conversion)
|
|
384 (default-directory (or (file-name-directory fullname)
|
|
385 default-directory)))
|
34503
|
386 (or (consp decoder)
|
|
387 (setq decoder (list decoder)))
|
|
388 (apply 'call-process-region (point-min) (point-max)
|
|
389 (car decoder) t t nil (cdr decoder))))
|
19937
|
390 (insert-file-contents fullname visit))))
|
25145
|
391
|
50660
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
392 (defun Info-default-dirs ()
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
393 (let ((source (expand-file-name "info/" source-directory))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
394 (sibling (if installation-directory
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
395 (expand-file-name "info/" installation-directory)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
396 (if invocation-directory
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
397 (let ((infodir (expand-file-name
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
398 "../info/"
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
399 invocation-directory)))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
400 (if (file-exists-p infodir)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
401 infodir
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
402 (setq infodir (expand-file-name
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
403 "../../../info/"
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
404 invocation-directory))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
405 (and (file-exists-p infodir)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
406 infodir))))))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
407 alternative)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
408 (setq alternative
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
409 (if (and sibling (file-exists-p sibling))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
410 ;; Uninstalled, Emacs builddir != srcdir.
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
411 sibling
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
412 ;; Uninstalled, builddir == srcdir
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
413 source))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
414 (if (or (member alternative Info-default-directory-list)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
415 ;; On DOS/NT, we use movable executables always,
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
416 ;; and we must always find the Info dir at run time.
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
417 (if (memq system-type '(ms-dos windows-nt))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
418 nil
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
419 ;; Use invocation-directory for Info
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
420 ;; only if we used it for exec-directory also.
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
421 (not (string= exec-directory
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
422 (expand-file-name "lib-src/"
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
423 installation-directory))))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
424 (not (file-exists-p alternative)))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
425 Info-default-directory-list
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
426 ;; `alternative' contains the Info files that came with this
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
427 ;; version, so we should look there first. `Info-insert-dir'
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
428 ;; currently expects to find `alternative' first on the list.
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
429 (cons alternative
|
54435
bcc27a58f6ac
(Info-default-dirs): Don't ignore last part of I-d-d-l.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
430 ;; Don't drop the last part, it might contain non-Emacs stuff.
|
bcc27a58f6ac
(Info-default-dirs): Don't ignore last part of I-d-d-l.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
431 ;; (reverse (cdr (reverse
|
bcc27a58f6ac
(Info-default-dirs): Don't ignore last part of I-d-d-l.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
432 Info-default-directory-list)))) ;; )))
|
50660
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
433
|
25145
|
434 (defun info-initialize ()
|
29621
|
435 "Initialize `Info-directory-list', if that hasn't been done yet."
|
25145
|
436 (unless Info-directory-list
|
50660
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
437 (let ((path (getenv "INFOPATH")))
|
25145
|
438 (setq Info-directory-list
|
30020
|
439 (prune-directory-list
|
|
440 (if path
|
50660
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
441 (if (string-match ":\\'" path)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
442 (append (split-string (substring path 0 -1)
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
443 (regexp-quote path-separator))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
444 (Info-default-dirs))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
445 (split-string path (regexp-quote path-separator)))
|
4d6ac18fff69
(Info-default-dirs): New fun extracted from Info-initialize.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
446 (Info-default-dirs)))))))
|
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
|
447
|
22471
|
448 ;;;###autoload
|
|
449 (defun info-other-window (&optional file)
|
|
450 "Like `info' but show the Info buffer in another window."
|
|
451 (interactive (if current-prefix-arg
|
|
452 (list (read-file-name "Info file name: " nil nil t))))
|
55174
|
453 (let (same-window-buffer-names same-window-regexps)
|
22471
|
454 (info file)))
|
28943
|
455
|
55174
|
456 ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
|
10957
|
457
|
57468
|
458 ;;;###autoload (put 'info 'info-file "emacs")
|
10957
|
459 ;;;###autoload
|
55174
|
460 (defun info (&optional file buffer)
|
325
|
461 "Enter Info, the documentation browser.
|
|
462 Optional argument FILE specifies the file to examine;
|
|
463 the default is the top-level directory of Info.
|
25311
|
464 Called from a program, FILE may specify an Info node of the form
|
|
465 `(FILENAME)NODENAME'.
|
55174
|
466 Optional argument BUFFER specifies the Info buffer name;
|
|
467 the default buffer name is *info*. If BUFFER exists,
|
|
468 just switch to BUFFER. Otherwise, create a new buffer
|
|
469 with the top-level Info directory.
|
325
|
470
|
55174
|
471 In interactive use, a non-numeric prefix argument directs
|
|
472 this command to read a file name from the minibuffer.
|
56044
|
473 A numeric prefix argument selects an Info buffer with the prefix number
|
|
474 appended to the Info buffer name.
|
14529
|
475
|
|
476 The search path for Info files is in the variable `Info-directory-list'.
|
28943
|
477 The top-level Info directory is made by combining all the files named `dir'
|
14529
|
478 in all the directories in that path."
|
55174
|
479 (interactive (list
|
|
480 (if (and current-prefix-arg (not (numberp current-prefix-arg)))
|
|
481 (read-file-name "Info file name: " nil nil t))
|
|
482 (if (numberp current-prefix-arg)
|
|
483 (format "*info*<%s>" current-prefix-arg))))
|
|
484 (pop-to-buffer (or buffer "*info*"))
|
|
485 (if (and buffer (not (eq major-mode 'Info-mode)))
|
|
486 (Info-mode))
|
325
|
487 (if file
|
54878
|
488 ;; If argument already contains parentheses, don't add another set
|
|
489 ;; since the argument will then be parsed improperly. This also
|
|
490 ;; has the added benefit of allowing node names to be included
|
|
491 ;; following the parenthesized filename.
|
|
492 (if (and (stringp file) (string-match "(.*)" file))
|
|
493 (Info-goto-node file)
|
|
494 (Info-goto-node (concat "(" file ")")))
|
|
495 (if (zerop (buffer-size))
|
55074
|
496 (Info-directory))))
|
325
|
497
|
4410
|
498 ;;;###autoload
|
46326
|
499 (defun info-emacs-manual ()
|
47794
|
500 "Display the Emacs manual in Info mode."
|
46326
|
501 (interactive)
|
|
502 (info "emacs"))
|
|
503
|
|
504 ;;;###autoload
|
4410
|
505 (defun info-standalone ()
|
|
506 "Run Emacs as a standalone Info reader.
|
|
507 Usage: emacs -f info-standalone [filename]
|
|
508 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
|
|
509 (setq Info-standalone t)
|
|
510 (if (and command-line-args-left
|
|
511 (not (string-match "^-" (car command-line-args-left))))
|
|
512 (condition-case err
|
|
513 (progn
|
|
514 (info (car command-line-args-left))
|
|
515 (setq command-line-args-left (cdr command-line-args-left)))
|
|
516 (error (send-string-to-terminal
|
|
517 (format "%s\n" (if (eq (car-safe err) 'error)
|
|
518 (nth 1 err) err)))
|
|
519 (save-buffers-kill-emacs)))
|
|
520 (info)))
|
25145
|
521
|
31942
|
522 ;; See if the accessible portion of the buffer begins with a node
|
23923
|
523 ;; delimiter, and the node header line which follows matches REGEXP.
|
|
524 ;; Typically, this test will be followed by a loop that examines the
|
|
525 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
|
|
526 ;; to have the overhead of this special test inside the loop.
|
|
527
|
|
528 ;; This function changes match-data, but supposedly the caller might
|
|
529 ;; want to use the results of re-search-backward.
|
|
530
|
|
531 ;; The return value is the value of point at the beginning of matching
|
31942
|
532 ;; REGEXP, if the function succeeds, nil otherwise.
|
23923
|
533 (defun Info-node-at-bob-matching (regexp)
|
29446
|
534 (and (bobp) ; are we at beginning of buffer?
|
|
535 (looking-at "\^_") ; does it begin with node delimiter?
|
23923
|
536 (let (beg)
|
|
537 (forward-line 1)
|
|
538 (setq beg (point))
|
29446
|
539 (forward-line 1) ; does the line after delimiter match REGEXP?
|
23923
|
540 (re-search-backward regexp beg t))))
|
|
541
|
54754
|
542 (defun Info-find-file (filename &optional noerror)
|
|
543 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
|
|
544 Optional second argument NOERROR, if t, means if file is not found
|
|
545 just return nil (no error)."
|
325
|
546 ;; Convert filename to lower case if not found as specified.
|
|
547 ;; Expand it.
|
26004
|
548 (if (stringp filename)
|
325
|
549 (let (temp temp-downcase found)
|
22692
|
550 (setq filename (substitute-in-file-name filename))
|
55074
|
551 (cond
|
54718
|
552 ((string= (downcase filename) "dir")
|
|
553 (setq found t))
|
|
554 ((string= filename "apropos")
|
|
555 (setq found 'apropos))
|
55074
|
556 ((string= filename "history")
|
|
557 (setq found 'history))
|
|
558 ((string= filename "toc")
|
|
559 (setq found 'toc))
|
54718
|
560 (t
|
|
561 (let ((dirs (if (string-match "^\\./" filename)
|
22692
|
562 ;; If specified name starts with `./'
|
|
563 ;; then just try current directory.
|
|
564 '("./")
|
|
565 (if (file-name-absolute-p filename)
|
|
566 ;; No point in searching for an
|
|
567 ;; absolute file name
|
|
568 '(nil)
|
|
569 (if Info-additional-directory-list
|
|
570 (append Info-directory-list
|
|
571 Info-additional-directory-list)
|
|
572 Info-directory-list)))))
|
|
573 ;; Search the directory list for file FILENAME.
|
|
574 (while (and dirs (not found))
|
|
575 (setq temp (expand-file-name filename (car dirs)))
|
|
576 (setq temp-downcase
|
|
577 (expand-file-name (downcase filename) (car dirs)))
|
|
578 ;; Try several variants of specified name.
|
36452
|
579 (let ((suffix-list Info-suffix-list)
|
49467
|
580 (lfn (if (fboundp 'msdos-long-file-names)
|
|
581 (msdos-long-file-names)
|
|
582 t)))
|
22692
|
583 (while (and suffix-list (not found))
|
|
584 (cond ((info-file-exists-p
|
|
585 (info-insert-file-contents-1
|
36452
|
586 temp (car (car suffix-list)) lfn))
|
22692
|
587 (setq found temp))
|
|
588 ((info-file-exists-p
|
|
589 (info-insert-file-contents-1
|
36452
|
590 temp-downcase (car (car suffix-list)) lfn))
|
|
591 (setq found temp-downcase))
|
|
592 ((and (fboundp 'msdos-long-file-names)
|
|
593 lfn
|
|
594 (info-file-exists-p
|
|
595 (info-insert-file-contents-1
|
|
596 temp (car (car suffix-list)) nil)))
|
|
597 (setq found temp)))
|
22692
|
598 (setq suffix-list (cdr suffix-list))))
|
54718
|
599 (setq dirs (cdr dirs))))))
|
22692
|
600 (if found
|
|
601 (setq filename found)
|
54754
|
602 (if noerror
|
|
603 (setq filename nil)
|
|
604 (error "Info file %s does not exist" filename)))
|
|
605 filename)))
|
|
606
|
|
607 (defun Info-find-node (filename nodename &optional no-going-back)
|
|
608 "Go to an info node specified as separate FILENAME and NODENAME.
|
|
609 NO-GOING-BACK is non-nil if recovering from an error in this function;
|
|
610 it says do not attempt further (recursive) error recovery."
|
|
611 (info-initialize)
|
|
612 (setq filename (Info-find-file filename))
|
22692
|
613 ;; Record the node we are leaving.
|
|
614 (if (and Info-current-file (not no-going-back))
|
|
615 (setq Info-history
|
|
616 (cons (list Info-current-file Info-current-node (point))
|
|
617 Info-history)))
|
21704
|
618 ;; Go into info buffer.
|
|
619 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
|
26004
|
620 (Info-find-node-2 filename nodename no-going-back))
|
|
621
|
|
622 (defun Info-on-current-buffer (&optional nodename)
|
|
623 "Use the `Info-mode' to browse the current info buffer.
|
|
624 If a prefix arg is provided, it queries for the NODENAME which
|
39459
|
625 else defaults to \"Top\"."
|
26004
|
626 (interactive
|
|
627 (list (if current-prefix-arg
|
|
628 (completing-read "Node name: " (Info-build-node-completions)
|
39459
|
629 nil t "Top"))))
|
|
630 (unless nodename (setq nodename "Top"))
|
29410
|
631 (info-initialize)
|
26004
|
632 (Info-mode)
|
|
633 (set (make-local-variable 'Info-current-file) t)
|
|
634 (Info-find-node-2 nil nodename))
|
|
635
|
48933
|
636 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
|
|
637 ;; but at least it keeps this routine (which is only for the benefit of
|
|
638 ;; makeinfo-buffer) out of the way of normal operations.
|
|
639 ;;
|
|
640 (defun Info-revert-find-node (filename nodename)
|
|
641 "Go to an info node FILENAME and NODENAME, re-reading disk contents.
|
|
642 When *info* is already displaying FILENAME and NODENAME, the window position
|
|
643 is preserved, if possible."
|
|
644 (pop-to-buffer "*info*")
|
|
645 (let ((old-filename Info-current-file)
|
|
646 (old-nodename Info-current-node)
|
|
647 (pcolumn (current-column))
|
|
648 (pline (count-lines (point-min) (line-beginning-position)))
|
|
649 (wline (count-lines (point-min) (window-start)))
|
|
650 (old-history Info-history)
|
|
651 (new-history (and Info-current-file
|
|
652 (list Info-current-file Info-current-node (point)))))
|
|
653 (kill-buffer (current-buffer))
|
|
654 (Info-find-node filename nodename)
|
|
655 (setq Info-history old-history)
|
|
656 (if (and (equal old-filename Info-current-file)
|
|
657 (equal old-nodename Info-current-node))
|
|
658 (progn
|
|
659 ;; note goto-line is no good, we want to measure from point-min
|
58040
|
660 (goto-char (point-min))
|
48933
|
661 (forward-line wline)
|
|
662 (set-window-start (selected-window) (point))
|
58040
|
663 (goto-char (point-min))
|
48933
|
664 (forward-line pline)
|
|
665 (move-to-column pcolumn))
|
|
666 ;; only add to the history when coming from a different file+node
|
|
667 (if new-history
|
|
668 (setq Info-history (cons new-history Info-history))))))
|
|
669
|
29684
|
670 (defun Info-find-in-tag-table-1 (marker regexp case-fold)
|
|
671 "Find a node in a tag table.
|
|
672 MARKER specifies the buffer and position to start searching at.
|
|
673 REGEXP is a regular expression matching nodes or references. Its first
|
|
674 group should match `Node:' or `Ref:'.
|
|
675 CASE-FOLD t means search for a case-insensitive match.
|
|
676 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
|
|
677 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
|
|
678 where the match was found, and MODE is `major-mode' of the buffer in
|
|
679 which the match was found."
|
51434
|
680 (let ((case-fold-search case-fold))
|
29684
|
681 (save-excursion
|
|
682 (set-buffer (marker-buffer marker))
|
|
683 (goto-char marker)
|
49424
|
684
|
29684
|
685 ;; Search tag table
|
|
686 (beginning-of-line)
|
|
687 (when (re-search-forward regexp nil t)
|
|
688 (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
|
689 (+ (point-min) (read (current-buffer)))
|
29684
|
690 major-mode)))))
|
|
691
|
|
692 (defun Info-find-in-tag-table (marker regexp)
|
|
693 "Find a node in a tag table.
|
|
694 MARKER specifies the buffer and position to start searching at.
|
|
695 REGEXP is a regular expression matching nodes or references. Its first
|
|
696 group should match `Node:' or `Ref:'.
|
|
697 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
|
|
698 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
|
|
699 where the match was found, and MODE is `major-mode' of the buffer in
|
|
700 which the match was found.
|
|
701 This function tries to find a case-sensitive match first, then a
|
|
702 case-insensitive match is tried."
|
|
703 (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
|
|
704 (when (null (car result))
|
|
705 (setq result (Info-find-in-tag-table-1 marker regexp t)))
|
|
706 result))
|
|
707
|
|
708 (defun Info-find-node-in-buffer-1 (regexp case-fold)
|
|
709 "Find a node or anchor in the current buffer.
|
|
710 REGEXP is a regular expression matching nodes or references. Its first
|
|
711 group should match `Node:' or `Ref:'.
|
|
712 CASE-FOLD t means search for a case-insensitive match.
|
|
713 Value is the position at which a match was found, or nil if not found."
|
|
714 (let ((case-fold-search case-fold)
|
|
715 found)
|
|
716 (save-excursion
|
|
717 (when (Info-node-at-bob-matching regexp)
|
|
718 (setq found (point)))
|
|
719 (while (and (not found)
|
|
720 (search-forward "\n\^_" nil t))
|
|
721 (forward-line 1)
|
|
722 (let ((beg (point)))
|
|
723 (forward-line 1)
|
|
724 (when (re-search-backward regexp beg t)
|
|
725 (beginning-of-line)
|
|
726 (setq found (point)))))
|
|
727 found)))
|
49424
|
728
|
29684
|
729 (defun Info-find-node-in-buffer (regexp)
|
|
730 "Find a node or anchor in the current buffer.
|
|
731 REGEXP is a regular expression matching nodes or references. Its first
|
|
732 group should match `Node:' or `Ref:'.
|
|
733 Value is the position at which a match was found, or nil if not found.
|
|
734 This function looks for a case-sensitive match first. If none is found,
|
|
735 a case-insensitive match is tried."
|
|
736 (or (Info-find-node-in-buffer-1 regexp nil)
|
|
737 (Info-find-node-in-buffer-1 regexp t)))
|
49424
|
738
|
26004
|
739 (defun Info-find-node-2 (filename nodename &optional no-going-back)
|
21704
|
740 (buffer-disable-undo (current-buffer))
|
|
741 (or (eq major-mode 'Info-mode)
|
|
742 (Info-mode))
|
325
|
743 (widen)
|
|
744 (setq Info-current-node nil)
|
|
745 (unwind-protect
|
24632
|
746 (let ((case-fold-search t)
|
|
747 anchorpos)
|
22692
|
748 ;; Switch files if necessary
|
|
749 (or (null filename)
|
|
750 (equal Info-current-file filename)
|
|
751 (let ((buffer-read-only nil))
|
|
752 (setq Info-current-file nil
|
|
753 Info-current-subfile nil
|
|
754 Info-current-file-completions nil
|
|
755 buffer-file-name nil)
|
|
756 (erase-buffer)
|
54718
|
757 (cond
|
|
758 ((eq filename t)
|
|
759 (Info-insert-dir))
|
|
760 ((eq filename 'apropos)
|
|
761 (insert-buffer-substring " *info-apropos*"))
|
55074
|
762 ((eq filename 'history)
|
|
763 (insert-buffer-substring " *info-history*"))
|
|
764 ((eq filename 'toc)
|
|
765 (insert-buffer-substring " *info-toc*"))
|
54718
|
766 (t
|
41713
d53ece895385
(Info-find-node-2): Don't call info-insert-file-contents
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
767 (info-insert-file-contents filename nil)
|
54718
|
768 (setq default-directory (file-name-directory filename))))
|
22692
|
769 (set-buffer-modified-p nil)
|
|
770 ;; See whether file has a tag table. Record the location if yes.
|
|
771 (goto-char (point-max))
|
|
772 (forward-line -8)
|
|
773 ;; Use string-equal, not equal, to ignore text props.
|
|
774 (if (not (or (string-equal nodename "*")
|
|
775 (not
|
|
776 (search-forward "\^_\nEnd tag table\n" nil t))))
|
|
777 (let (pos)
|
|
778 ;; We have a tag table. Find its beginning.
|
|
779 ;; Is this an indirect file?
|
|
780 (search-backward "\nTag table:\n")
|
|
781 (setq pos (point))
|
|
782 (if (save-excursion
|
|
783 (forward-line 2)
|
|
784 (looking-at "(Indirect)\n"))
|
|
785 ;; It is indirect. Copy it to another buffer
|
|
786 ;; and record that the tag table is in that buffer.
|
|
787 (let ((buf (current-buffer))
|
|
788 (tagbuf
|
|
789 (or Info-tag-table-buffer
|
|
790 (generate-new-buffer " *info tag table*"))))
|
|
791 (setq Info-tag-table-buffer tagbuf)
|
|
792 (save-excursion
|
|
793 (set-buffer tagbuf)
|
1484
|
794 (buffer-disable-undo (current-buffer))
|
22692
|
795 (setq case-fold-search t)
|
|
796 (erase-buffer)
|
|
797 (insert-buffer-substring buf))
|
|
798 (set-marker Info-tag-table-marker
|
|
799 (match-end 0) tagbuf))
|
|
800 (set-marker Info-tag-table-marker pos)))
|
|
801 (set-marker Info-tag-table-marker nil))
|
|
802 (setq Info-current-file
|
54718
|
803 (cond
|
|
804 ((eq filename t) "dir")
|
|
805 ((eq filename 'apropos) "apropos")
|
55074
|
806 ((eq filename 'history) "history")
|
|
807 ((eq filename 'toc) "toc")
|
54718
|
808 (t filename)))
|
|
809 ))
|
22692
|
810 ;; Use string-equal, not equal, to ignore text props.
|
|
811 (if (string-equal nodename "*")
|
|
812 (progn (setq Info-current-node nodename)
|
|
813 (Info-set-mode-line))
|
|
814 ;; Possibilities:
|
|
815 ;;
|
|
816 ;; 1. Anchor found in tag table
|
|
817 ;; 2. Anchor *not* in tag table
|
|
818 ;;
|
|
819 ;; 3. Node found in tag table
|
|
820 ;; 4. Node *not* found in tag table, but found in file
|
|
821 ;; 5. Node *not* in tag table, and *not* in file
|
|
822 ;;
|
|
823 ;; *Or* the same, but in an indirect subfile.
|
|
824
|
|
825 ;; Search file for a suitable node.
|
24632
|
826 (let ((guesspos (point-min))
|
29684
|
827 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
828 (if (stringp nodename)
|
30686
|
829 (regexp-quote nodename)
|
|
830 "")
|
51434
|
831 "\\) *[,\t\n\177]")))
|
22692
|
832
|
29164
|
833 (catch 'foo
|
49424
|
834
|
29164
|
835 ;; First, search a tag table, if any
|
29684
|
836 (when (marker-position Info-tag-table-marker)
|
|
837 (let* ((m Info-tag-table-marker)
|
|
838 (found (Info-find-in-tag-table m regexp)))
|
49424
|
839
|
29684
|
840 (when found
|
|
841 ;; FOUND is (ANCHOR POS MODE).
|
|
842 (setq guesspos (nth 1 found))
|
49424
|
843
|
29684
|
844 ;; If this is an indirect file, determine which
|
|
845 ;; file really holds this node and read it in.
|
|
846 (unless (eq (nth 2 found) 'Info-mode)
|
|
847 ;; Note that the current buffer must be the
|
|
848 ;; *info* buffer on entry to
|
|
849 ;; Info-read-subfile. Thus the hackery above.
|
|
850 (setq guesspos (Info-read-subfile guesspos)))
|
29164
|
851
|
|
852 ;; Handle anchor
|
29684
|
853 (when (nth 0 found)
|
|
854 (goto-char (setq anchorpos guesspos))
|
|
855 (throw 'foo t)))))
|
29164
|
856
|
|
857 ;; Else we may have a node, which we search for:
|
|
858 (goto-char (max (point-min)
|
|
859 (- (byte-to-position guesspos) 1000)))
|
49424
|
860
|
29684
|
861 ;; Now search from our advised position (or from beg of
|
|
862 ;; buffer) to find the actual node. First, check
|
|
863 ;; whether the node is right where we are, in case the
|
|
864 ;; buffer begins with a node.
|
|
865 (let ((pos (Info-find-node-in-buffer regexp)))
|
|
866 (when pos
|
|
867 (goto-char pos)
|
55751
|
868 (throw 'foo t)))
|
|
869
|
|
870 (when (string-match "\\([^.]+\\)\\." nodename)
|
|
871 (let (Info-point-loc)
|
|
872 (Info-find-node-2
|
|
873 filename (match-string 1 nodename) no-going-back))
|
|
874 (widen)
|
|
875 (throw 'foo t))
|
|
876
|
|
877 ;; No such anchor in tag table or node in tag table or file
|
|
878 (error "No such node or anchor: %s" nodename))
|
29164
|
879
|
|
880 (Info-select-node)
|
54754
|
881 (goto-char (point-min))
|
|
882 (cond (anchorpos
|
|
883 (let ((new-history (list Info-current-file
|
|
884 (substring-no-properties nodename))))
|
|
885 ;; Add anchors to the history too
|
|
886 (setq Info-history-list
|
|
887 (cons new-history
|
|
888 (delete new-history Info-history-list))))
|
|
889 (goto-char anchorpos))
|
55174
|
890 ((numberp Info-point-loc)
|
|
891 (forward-line (1- Info-point-loc))
|
|
892 (setq Info-point-loc nil))
|
|
893 ((stringp Info-point-loc)
|
|
894 (Info-find-index-name Info-point-loc)
|
|
895 (setq Info-point-loc nil))))))
|
325
|
896 ;; If we did not finish finding the specified node,
|
|
897 ;; go back to the previous one.
|
6716
|
898 (or Info-current-node no-going-back (null Info-history)
|
22692
|
899 (let ((hist (car Info-history)))
|
|
900 (setq Info-history (cdr Info-history))
|
|
901 (Info-find-node (nth 0 hist) (nth 1 hist) t)
|
|
902 (goto-char (nth 2 hist))))))
|
325
|
903
|
1979
|
904 ;; Cache the contents of the (virtual) dir file, once we have merged
|
|
905 ;; it for the first time, so we can save time subsequently.
|
1971
|
906 (defvar Info-dir-contents nil)
|
|
907
|
1979
|
908 ;; Cache for the directory we decided to use for the default-directory
|
|
909 ;; of the merged dir text.
|
|
910 (defvar Info-dir-contents-directory nil)
|
|
911
|
3836
|
912 ;; Record the file attributes of all the files from which we
|
|
913 ;; constructed Info-dir-contents.
|
|
914 (defvar Info-dir-file-attributes nil)
|
|
915
|
23416
|
916 (defvar Info-dir-file-name nil)
|
|
917
|
1971
|
918 ;; Construct the Info directory node by merging the files named `dir'
|
1979
|
919 ;; from various directories. Set the *info* buffer's
|
|
920 ;; default-directory to the first directory we actually get any text
|
|
921 ;; from.
|
1971
|
922 (defun Info-insert-dir ()
|
3836
|
923 (if (and Info-dir-contents Info-dir-file-attributes
|
|
924 ;; Verify that none of the files we used has changed
|
|
925 ;; since we used it.
|
|
926 (eval (cons 'and
|
29583
|
927 (mapcar (lambda (elt)
|
|
928 (let ((curr (file-attributes
|
|
929 ;; Handle symlinks
|
|
930 (file-truename (car elt)))))
|
28943
|
931
|
29583
|
932 ;; Don't compare the access time.
|
|
933 (if curr (setcar (nthcdr 4 curr) 0))
|
|
934 (setcar (nthcdr 4 (cdr elt)) 0)
|
|
935 (equal (cdr elt) curr)))
|
3836
|
936 Info-dir-file-attributes))))
|
23416
|
937 (progn
|
|
938 (insert Info-dir-contents)
|
|
939 (goto-char (point-min)))
|
30686
|
940 (let ((dirs (if Info-additional-directory-list
|
46139
|
941 (append Info-directory-list
|
|
942 Info-additional-directory-list)
|
|
943 Info-directory-list))
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
944 (dir-file-attrs nil)
|
22951
|
945 ;; Bind this in case the user sets it to nil.
|
|
946 (case-fold-search t)
|
23416
|
947 ;; This is set non-nil if we find a problem in some input files.
|
|
948 problems
|
3212
|
949 buffers buffer others nodes dirs-done)
|
1979
|
950
|
|
951 ;; Search the directory list for the directory file.
|
1971
|
952 (while dirs
|
5271
|
953 (let ((truename (file-truename (expand-file-name (car dirs)))))
|
|
954 (or (member truename dirs-done)
|
|
955 (member (directory-file-name truename) dirs-done)
|
|
956 ;; Try several variants of specified name.
|
|
957 ;; Try upcasing, appending `.info', or both.
|
7911
|
958 (let* (file
|
|
959 (attrs
|
|
960 (or
|
|
961 (progn (setq file (expand-file-name "dir" truename))
|
|
962 (file-attributes file))
|
|
963 (progn (setq file (expand-file-name "DIR" truename))
|
|
964 (file-attributes file))
|
|
965 (progn (setq file (expand-file-name "dir.info" truename))
|
|
966 (file-attributes file))
|
|
967 (progn (setq file (expand-file-name "DIR.INFO" truename))
|
|
968 (file-attributes file)))))
|
5271
|
969 (setq dirs-done
|
|
970 (cons truename
|
|
971 (cons (directory-file-name truename)
|
|
972 dirs-done)))
|
7911
|
973 (if attrs
|
|
974 (save-excursion
|
|
975 (or buffers
|
|
976 (message "Composing main Info directory..."))
|
20421
|
977 (set-buffer (generate-new-buffer " info dir"))
|
22863
|
978 (condition-case nil
|
|
979 (progn
|
|
980 (insert-file-contents file)
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
981 (set (make-local-variable 'Info-dir-file-name)
|
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
982 file)
|
48135
|
983 (push (current-buffer) buffers)
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
984 (push (cons file attrs) dir-file-attrs))
|
22863
|
985 (error (kill-buffer (current-buffer))))))))
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
986 (unless (cdr dirs)
|
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
987 (set (make-local-variable 'Info-dir-contents-directory)
|
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
988 (file-name-as-directory (car dirs))))
|
7911
|
989 (setq dirs (cdr dirs))))
|
28943
|
990
|
6716
|
991 (or buffers
|
14664
|
992 (error "Can't find the Info directory node"))
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
993
|
1979
|
994 ;; Distinguish the dir file that comes with Emacs from all the
|
3212
|
995 ;; others. Yes, that is really what this is supposed to do.
|
24513
|
996 ;; The definition of `Info-directory-list' puts it first on that
|
|
997 ;; list and so last in `buffers' at this point.
|
|
998 (setq buffer (car (last buffers))
|
|
999 others (delq buffer buffers))
|
1979
|
1000
|
15304
|
1001 ;; Insert the entire original dir file as a start; note that we've
|
|
1002 ;; already saved its default directory to use as the default
|
|
1003 ;; directory for the whole concatenation.
|
1971
|
1004 (insert-buffer buffer)
|
1979
|
1005
|
1971
|
1006 ;; Look at each of the other buffers one by one.
|
48135
|
1007 (dolist (other others)
|
|
1008 (let (this-buffer-nodes)
|
1971
|
1009 ;; In each, find all the menus.
|
48135
|
1010 (with-current-buffer other
|
1971
|
1011 (goto-char (point-min))
|
|
1012 ;; Find each menu, and add an elt to NODES for it.
|
|
1013 (while (re-search-forward "^\\* Menu:" nil t)
|
48135
|
1014 (while (and (zerop (forward-line 1)) (eolp)))
|
|
1015 (let ((beg (point))
|
|
1016 nodename end)
|
|
1017 (re-search-backward "^\^_")
|
1971
|
1018 (search-forward "Node: ")
|
55074
|
1019 (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
|
1020 (search-forward "\n\^_" nil 'move)
|
1971
|
1021 (beginning-of-line)
|
|
1022 (setq end (point))
|
48135
|
1023 (push (list nodename other beg end) this-buffer-nodes)))
|
53409
|
1024 (if (assoc-string "top" this-buffer-nodes t)
|
23416
|
1025 (setq nodes (nconc this-buffer-nodes nodes))
|
|
1026 (setq problems t)
|
48135
|
1027 (message "No `top' node in %s" Info-dir-file-name)))))
|
29621
|
1028 ;; Add to the main menu a menu item for each other node.
|
48135
|
1029 (re-search-forward "^\\* Menu:")
|
1971
|
1030 (forward-line 1)
|
|
1031 (let ((menu-items '("top"))
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1032 (end (save-excursion (search-forward "\^_" nil t) (point))))
|
48135
|
1033 (dolist (node nodes)
|
|
1034 (let ((nodename (car node)))
|
6537
|
1035 (save-excursion
|
|
1036 (or (member (downcase nodename) menu-items)
|
21641
|
1037 (re-search-forward (concat "^\\* +"
|
6537
|
1038 (regexp-quote nodename)
|
|
1039 "::")
|
|
1040 end t)
|
|
1041 (progn
|
|
1042 (insert "* " nodename "::" "\n")
|
48135
|
1043 (push nodename menu-items)))))))
|
1971
|
1044 ;; Now take each node of each of the other buffers
|
|
1045 ;; and merge it into the main buffer.
|
48135
|
1046 (dolist (node nodes)
|
29446
|
1047 (let ((case-fold-search t)
|
48135
|
1048 (nodename (car node)))
|
1971
|
1049 (goto-char (point-min))
|
|
1050 ;; Find the like-named node in the main buffer.
|
23904
|
1051 (if (re-search-forward (concat "^\^_.*\n.*Node: "
|
1971
|
1052 (regexp-quote nodename)
|
|
1053 "[,\n\t]")
|
|
1054 nil t)
|
|
1055 (progn
|
6339
f0f62abb621b
(Info-insert-dir): Use printable escapes instead of embedding literal control
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1056 (search-forward "\n\^_" nil 'move)
|
8913
|
1057 (beginning-of-line)
|
|
1058 (insert "\n"))
|
1971
|
1059 ;; If none exists, add one.
|
|
1060 (goto-char (point-max))
|
8069
|
1061 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
|
1971
|
1062 ;; Merge the text from the other buffer's menu
|
|
1063 ;; into the menu in the like-named node in the main buffer.
|
48135
|
1064 (apply 'insert-buffer-substring (cdr node))))
|
|
1065 (Info-dir-remove-duplicates)
|
56991
|
1066 ;; Kill all the buffers we just made, including the special one excised.
|
|
1067 (mapc 'kill-buffer (cons buffer buffers))
|
23416
|
1068 (goto-char (point-min))
|
|
1069 (if problems
|
|
1070 (message "Composing main Info directory...problems encountered, see `*Messages*'")
|
48690
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
1071 (message "Composing main Info directory...done"))
|
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
1072 (set (make-local-variable 'Info-dir-contents) (buffer-string))
|
036a8f0597c4
(Info-insert-dir): Make dir-node-cache variables buffer-local, so that
Miles Bader <miles@gnu.org>
diff
changeset
|
1073 (set (make-local-variable 'Info-dir-file-attributes) dir-file-attrs)))
|
1979
|
1074 (setq default-directory Info-dir-contents-directory))
|
1971
|
1075
|
48135
|
1076 (defvar Info-streamline-headings
|
|
1077 '(("Emacs" . "Emacs")
|
|
1078 ("Programming" . "Programming")
|
|
1079 ("Libraries" . "Libraries")
|
|
1080 ("World Wide Web\\|Net Utilities" . "Net Utilities"))
|
|
1081 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
|
|
1082
|
|
1083 (defun Info-dir-remove-duplicates ()
|
|
1084 (let (limit)
|
|
1085 (goto-char (point-min))
|
|
1086 ;; Remove duplicate headings in the same menu.
|
|
1087 (while (search-forward "\n* Menu:" nil t)
|
55751
|
1088 (setq limit (save-excursion (search-forward "\n\^_" nil t)))
|
48135
|
1089 ;; Look for the next heading to unify.
|
|
1090 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
|
|
1091 (let ((name (match-string 1))
|
|
1092 (start (match-beginning 0))
|
|
1093 (entries nil) re)
|
|
1094 ;; Check whether this heading should be streamlined.
|
|
1095 (save-match-data
|
|
1096 (dolist (x Info-streamline-headings)
|
|
1097 (when (string-match (car x) name)
|
|
1098 (setq name (cdr x))
|
|
1099 (setq re (car x)))))
|
|
1100 (if re (replace-match name t t nil 1))
|
|
1101 (goto-char (if (re-search-forward "^[^* \n\t]" limit t)
|
|
1102 (match-beginning 0)
|
|
1103 (or limit (point-max))))
|
|
1104 ;; Look for other headings of the same category and merge them.
|
|
1105 (save-excursion
|
|
1106 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
|
|
1107 (when (if re (save-match-data (string-match re (match-string 1)))
|
|
1108 (equal name (match-string 1)))
|
|
1109 (forward-line 0)
|
|
1110 ;; Delete redundant heading.
|
|
1111 (delete-region (match-beginning 0) (point))
|
|
1112 ;; Push the entries onto `text'.
|
|
1113 (push
|
|
1114 (delete-and-extract-region
|
|
1115 (point)
|
|
1116 (if (re-search-forward "^[^* \n\t]" nil t)
|
|
1117 (match-beginning 0)
|
|
1118 (or limit (point-max)))) entries))))
|
|
1119 ;; Insert the entries just found.
|
|
1120 (while (= (line-beginning-position 0) (1- (point)))
|
|
1121 (backward-char))
|
|
1122 (dolist (entry (nreverse entries))
|
|
1123 (insert entry)
|
|
1124 (while (= (line-beginning-position 0) (1- (point)))
|
|
1125 (delete-region (1- (point)) (point))))
|
49424
|
1126
|
48135
|
1127 ;; Now remove duplicate entries under the same heading.
|
|
1128 (let ((seen nil)
|
|
1129 (limit (point)))
|
|
1130 (goto-char start)
|
|
1131 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
|
|
1132 limit 'move)
|
|
1133 (let ((x (match-string 1)))
|
|
1134 (if (member-ignore-case x seen)
|
|
1135 (delete-region (match-beginning 0)
|
|
1136 (progn (re-search-forward "^[^ \t]" nil t)
|
48887
|
1137 (match-beginning 0)))
|
48135
|
1138 (push x seen))))))))))
|
|
1139
|
16981
|
1140 ;; Note that on entry to this function the current-buffer must be the
|
|
1141 ;; *info* buffer; not the info tags buffer.
|
325
|
1142 (defun Info-read-subfile (nodepos)
|
16399
|
1143 ;; NODEPOS is either a position (in the Info file as a whole,
|
|
1144 ;; not relative to a subfile) or the name of a subfile.
|
325
|
1145 (let (lastfilepos
|
|
1146 lastfilename)
|
16399
|
1147 (if (numberp nodepos)
|
|
1148 (save-excursion
|
|
1149 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
1150 (goto-char (point-min))
|
23904
|
1151 (or (looking-at "\^_")
|
|
1152 (search-forward "\n\^_"))
|
16399
|
1153 (forward-line 2)
|
|
1154 (catch 'foo
|
|
1155 (while (not (looking-at "\^_"))
|
|
1156 (if (not (eolp))
|
|
1157 (let ((beg (point))
|
|
1158 thisfilepos thisfilename)
|
|
1159 (search-forward ": ")
|
|
1160 (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
|
1161 (setq thisfilepos (+ (point-min) (read (current-buffer))))
|
16399
|
1162 ;; read in version 19 stops at the end of number.
|
|
1163 ;; Advance to the next line.
|
|
1164 (forward-line 1)
|
|
1165 (if (> thisfilepos nodepos)
|
|
1166 (throw 'foo t))
|
|
1167 (setq lastfilename thisfilename)
|
|
1168 (setq lastfilepos thisfilepos))
|
|
1169 (forward-line 1)))))
|
|
1170 (setq lastfilename nodepos)
|
|
1171 (setq lastfilepos 0))
|
16981
|
1172 ;; Assume previous buffer is in Info-mode.
|
|
1173 ;; (set-buffer (get-buffer "*info*"))
|
325
|
1174 (or (equal Info-current-subfile lastfilename)
|
|
1175 (let ((buffer-read-only nil))
|
|
1176 (setq buffer-file-name nil)
|
|
1177 (widen)
|
|
1178 (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
|
1179 (info-insert-file-contents lastfilename)
|
325
|
1180 (set-buffer-modified-p nil)
|
|
1181 (setq Info-current-subfile lastfilename)))
|
37837
|
1182 ;; Widen in case we are in the same subfile as before.
|
|
1183 (widen)
|
325
|
1184 (goto-char (point-min))
|
23904
|
1185 (if (looking-at "\^_")
|
|
1186 (forward-char 1)
|
|
1187 (search-forward "\n\^_"))
|
16399
|
1188 (if (numberp nodepos)
|
|
1189 (+ (- nodepos lastfilepos) (point)))))
|
325
|
1190
|
50707
|
1191 (defun Info-unescape-quotes (value)
|
53246
|
1192 "Unescape double quotes and backslashes in VALUE."
|
50707
|
1193 (let ((start 0)
|
|
1194 (unquote value))
|
|
1195 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start)
|
|
1196 (setq unquote (replace-match "" t t unquote 1))
|
|
1197 (setq start (- (match-end 0) 1)))
|
|
1198 unquote))
|
|
1199
|
|
1200 ;; As of Texinfo 4.6, makeinfo writes constructs like
|
|
1201 ;; \0\h[image param=value ...\h\0]
|
|
1202 ;; into the Info file for handling images.
|
|
1203 (defun Info-split-parameter-string (parameter-string)
|
|
1204 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
|
53246
|
1205 whitespace separated list of KEY=VALUE pairs. If VALUE contains
|
|
1206 whitespace or double quotes, it must be quoted in double quotes and
|
|
1207 any double quotes or backslashes must be escaped (\\\",\\\\)."
|
50707
|
1208 (let ((start 0)
|
|
1209 (parameter-alist))
|
|
1210 (while (string-match
|
|
1211 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
|
|
1212 parameter-string start)
|
|
1213 (setq start (match-end 0))
|
|
1214 (push (cons (match-string 1 parameter-string)
|
|
1215 (or (match-string 2 parameter-string)
|
|
1216 (Info-unescape-quotes
|
|
1217 (match-string 3 parameter-string))))
|
|
1218 parameter-alist))
|
|
1219 parameter-alist))
|
|
1220
|
|
1221 (defun Info-display-images-node ()
|
|
1222 "Display images in current node."
|
|
1223 (save-excursion
|
|
1224 (let ((inhibit-read-only t)
|
51434
|
1225 (case-fold-search t))
|
50707
|
1226 (goto-char (point-min))
|
|
1227 (while (re-search-forward
|
|
1228 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
|
|
1229 nil t)
|
|
1230 (let* ((start (match-beginning 1))
|
|
1231 (parameter-alist (Info-split-parameter-string (match-string 2)))
|
|
1232 (src (cdr (assoc-string "src" parameter-alist)))
|
|
1233 (image-file (if src (if (file-name-absolute-p src) src
|
|
1234 (concat default-directory src))
|
|
1235 ""))
|
|
1236 (image (if (file-exists-p image-file)
|
|
1237 (create-image image-file)
|
|
1238 "[broken image]")))
|
|
1239 (if (not (get-text-property start 'display))
|
|
1240 (add-text-properties
|
|
1241 start (point) `(display ,image rear-nonsticky (display)))))))
|
|
1242 (set-buffer-modified-p nil)))
|
|
1243
|
54752
|
1244 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
|
|
1245 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
|
|
1246 ;; including one optional trailing newline.
|
|
1247 (defun Info-hide-cookies-node ()
|
|
1248 "Hide unrecognised cookies in current node."
|
|
1249 (save-excursion
|
|
1250 (let ((inhibit-read-only t)
|
|
1251 (case-fold-search t))
|
|
1252 (goto-char (point-min))
|
|
1253 (while (re-search-forward
|
|
1254 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
|
|
1255 nil t)
|
|
1256 (let* ((start (match-beginning 1)))
|
|
1257 (if (not (get-text-property start 'invisible))
|
|
1258 (put-text-property start (point) 'invisible t)))))
|
|
1259 (set-buffer-modified-p nil)))
|
|
1260
|
325
|
1261 (defun Info-select-node ()
|
51513
|
1262 "Select the info node that point is in."
|
|
1263 ;; Bind this in case the user sets it to nil.
|
22951
|
1264 (let ((case-fold-search t))
|
|
1265 (save-excursion
|
29446
|
1266 ;; Find beginning of node.
|
|
1267 (if (search-backward "\n\^_" nil 'move)
|
|
1268 (forward-line 2)
|
|
1269 (if (looking-at "\^_")
|
|
1270 (forward-line 1)
|
|
1271 (signal 'search-failed (list "\n\^_"))))
|
|
1272 ;; Get nodename spelled as it is in the node.
|
|
1273 (re-search-forward "Node:[ \t]*")
|
|
1274 (setq Info-current-node
|
|
1275 (buffer-substring-no-properties (point)
|
|
1276 (progn
|
|
1277 (skip-chars-forward "^,\t\n")
|
|
1278 (point))))
|
|
1279 (Info-set-mode-line)
|
|
1280 ;; Find the end of it, and narrow.
|
|
1281 (beginning-of-line)
|
|
1282 (let (active-expression)
|
31660
|
1283 ;; Narrow to the node contents
|
29446
|
1284 (narrow-to-region (point)
|
|
1285 (if (re-search-forward "\n[\^_\f]" nil t)
|
|
1286 (prog1
|
|
1287 (1- (point))
|
|
1288 (if (looking-at "[\n\^_\f]*execute: ")
|
|
1289 (progn
|
|
1290 (goto-char (match-end 0))
|
|
1291 (setq active-expression
|
|
1292 (read (current-buffer))))))
|
|
1293 (point-max)))
|
|
1294 (if Info-enable-active-nodes (eval active-expression))
|
54754
|
1295 ;; Add a new unique history item to full history list
|
|
1296 (let ((new-history (list Info-current-file Info-current-node)))
|
|
1297 (setq Info-history-list
|
|
1298 (cons new-history (delete new-history Info-history-list))))
|
55751
|
1299 (if (not (eq Info-fontify-maximum-menu-size nil))
|
|
1300 (Info-fontify-node))
|
50707
|
1301 (Info-display-images-node)
|
54752
|
1302 (Info-hide-cookies-node)
|
29446
|
1303 (run-hooks 'Info-selection-hook)))))
|
325
|
1304
|
|
1305 (defun Info-set-mode-line ()
|
|
1306 (setq mode-line-buffer-identification
|
32538
|
1307 (nconc (propertized-buffer-identification "%b")
|
32533
|
1308 (list
|
|
1309 (concat " ("
|
|
1310 (file-name-nondirectory
|
|
1311 (if (stringp Info-current-file)
|
|
1312 Info-current-file
|
|
1313 (or buffer-file-name "")))
|
|
1314 ") "
|
|
1315 (or Info-current-node ""))))))
|
325
|
1316
|
|
1317 ;; Go to an info node specified with a filename-and-nodename string
|
|
1318 ;; of the sort that is found in pointers in nodes.
|
|
1319
|
56044
|
1320 ;;;###autoload
|
26004
|
1321 (defun Info-goto-node (nodename &optional fork)
|
39213
|
1322 "Go to info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
|
39382
|
1323 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
|
|
1324 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
|
|
1325 its sub-files).
|
|
1326 Completion is available, but only for node names in the current Info file.
|
32286
|
1327 If FORK is non-nil (interactively with a prefix arg), show the node in
|
|
1328 a new info buffer.
|
26004
|
1329 If FORK is a string, it is the name to use for the new buffer."
|
32500
|
1330 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
|
25172
|
1331 (info-initialize)
|
26004
|
1332 (if fork
|
29446
|
1333 (set-buffer
|
|
1334 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
|
325
|
1335 (let (filename)
|
|
1336 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
|
|
1337 nodename)
|
|
1338 (setq filename (if (= (match-beginning 1) (match-end 1))
|
|
1339 ""
|
51735
|
1340 (match-string 2 nodename))
|
|
1341 nodename (match-string 3 nodename))
|
55174
|
1342 (let ((trim (string-match "\\s +\\'" filename)))
|
325
|
1343 (if trim (setq filename (substring filename 0 trim))))
|
55174
|
1344 (let ((trim (string-match "\\s +\\'" nodename)))
|
325
|
1345 (if trim (setq nodename (substring nodename 0 trim))))
|
12433
|
1346 (if transient-mark-mode (deactivate-mark))
|
325
|
1347 (Info-find-node (if (equal filename "") nil filename)
|
|
1348 (if (equal nodename "") "Top" nodename))))
|
4410
|
1349
|
22760
|
1350 (defvar Info-read-node-completion-table)
|
|
1351
|
12779
|
1352 ;; This function is used as the "completion table" while reading a node name.
|
22760
|
1353 ;; It does completion using the alist in Info-read-node-completion-table
|
12779
|
1354 ;; unless STRING starts with an open-paren.
|
|
1355 (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
|
1356 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1357 ;; 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
|
1358 ((string-match "\\`([^)]*\\'" string)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1359 (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
|
1360 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1361 ((eq code nil)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1362 (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
|
1363 (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
|
1364 (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
|
1365 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1366 ((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
|
1367 (comp (concat "(" comp)))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1368 ((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
|
1369 (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
|
1370 (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
|
1371 (t nil))))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1372 ;; 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
|
1373 ((string-match "\\`(" string)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1374 (cond
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1375 ((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
|
1376 ((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
|
1377 (t t)))
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1378 ;; 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
|
1379 ((eq code nil)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1380 (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
|
1381 ((eq code t)
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1382 (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
|
1383 (t
|
a590e8ab89d0
(Info-find-in-tag-table-1, Info-read-subfile): Use point-min.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1384 (test-completion string Info-read-node-completion-table predicate))))
|
12779
|
1385
|
4410
|
1386 (defun Info-read-node-name (prompt &optional default)
|
|
1387 (let* ((completion-ignore-case t)
|
22760
|
1388 (Info-read-node-completion-table (Info-build-node-completions))
|
17140
|
1389 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
|
4410
|
1390 (if (equal nodename "")
|
|
1391 (or default
|
|
1392 (Info-read-node-name prompt))
|
|
1393 nodename)))
|
|
1394
|
|
1395 (defun Info-build-node-completions ()
|
|
1396 (or Info-current-file-completions
|
22951
|
1397 (let ((compl nil)
|
|
1398 ;; Bind this in case the user sets it to nil.
|
23923
|
1399 (case-fold-search t)
|
|
1400 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
|
4410
|
1401 (save-excursion
|
|
1402 (save-restriction
|
|
1403 (if (marker-buffer Info-tag-table-marker)
|
16981
|
1404 (let ((marker Info-tag-table-marker))
|
|
1405 (set-buffer (marker-buffer marker))
|
6049
|
1406 (widen)
|
16981
|
1407 (goto-char marker)
|
29621
|
1408 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t)
|
4410
|
1409 (setq compl
|
29621
|
1410 (cons (list (match-string-no-properties 2))
|
4410
|
1411 compl))))
|
|
1412 (widen)
|
|
1413 (goto-char (point-min))
|
23923
|
1414 ;; If the buffer begins with a node header, process that first.
|
|
1415 (if (Info-node-at-bob-matching node-regexp)
|
26580
|
1416 (setq compl (list (match-string-no-properties 1))))
|
23923
|
1417 ;; Now for the rest of the nodes.
|
4410
|
1418 (while (search-forward "\n\^_" nil t)
|
|
1419 (forward-line 1)
|
|
1420 (let ((beg (point)))
|
|
1421 (forward-line 1)
|
23923
|
1422 (if (re-search-backward node-regexp beg t)
|
28943
|
1423 (setq compl
|
26580
|
1424 (cons (list (match-string-no-properties 1))
|
4410
|
1425 compl))))))))
|
26172
|
1426 (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
|
1427 (set (make-local-variable 'Info-current-file-completions) compl))))
|
325
|
1428
|
540
|
1429 (defun Info-restore-point (hl)
|
|
1430 "If this node has been visited, restore the point value when we left."
|
6049
|
1431 (while hl
|
|
1432 (if (and (equal (nth 0 (car hl)) Info-current-file)
|
11527
|
1433 ;; Use string-equal, not equal, to ignore text props.
|
|
1434 (string-equal (nth 1 (car hl)) Info-current-node))
|
6049
|
1435 (progn
|
6121
|
1436 (goto-char (nth 2 (car hl)))
|
|
1437 (setq hl nil)) ;terminate the while at next iter
|
6049
|
1438 (setq hl (cdr hl)))))
|
540
|
1439
|
30109
|
1440 (defvar Info-search-history nil
|
|
1441 "The history list for `Info-search'.")
|
325
|
1442
|
54754
|
1443 (defvar Info-search-case-fold nil
|
|
1444 "The value of `case-fold-search' from previous `Info-search' command.")
|
|
1445
|
56866
|
1446 (defun Info-search (regexp &optional bound noerror count direction)
|
|
1447 "Search for REGEXP, starting from point, and select node it's found in.
|
|
1448 If DIRECTION is `backward', search in the reverse direction."
|
35136
|
1449 (interactive (list (read-string
|
|
1450 (if Info-search-history
|
54754
|
1451 (format "Regexp search%s (default `%s'): "
|
|
1452 (if case-fold-search "" " case-sensitively")
|
35136
|
1453 (car Info-search-history))
|
54754
|
1454 (format "Regexp search%s: "
|
|
1455 (if case-fold-search "" " case-sensitively")))
|
35136
|
1456 nil 'Info-search-history)))
|
30109
|
1457 (when transient-mark-mode
|
|
1458 (deactivate-mark))
|
|
1459 (when (equal regexp "")
|
|
1460 (setq regexp (car Info-search-history)))
|
24963
|
1461 (when regexp
|
51805
|
1462 (let (found beg-found give-up
|
56866
|
1463 (backward (eq direction 'backward))
|
24963
|
1464 (onode Info-current-node)
|
|
1465 (ofile Info-current-file)
|
|
1466 (opoint (point))
|
56866
|
1467 (opoint-min (point-min))
|
|
1468 (opoint-max (point-max))
|
24963
|
1469 (ostart (window-start))
|
|
1470 (osubfile Info-current-subfile))
|
54754
|
1471 (when Info-search-whitespace-regexp
|
56866
|
1472 (setq regexp
|
|
1473 (mapconcat 'identity (split-string regexp "[ \t\n]+")
|
|
1474 Info-search-whitespace-regexp)))
|
54754
|
1475 (setq Info-search-case-fold case-fold-search)
|
24963
|
1476 (save-excursion
|
|
1477 (save-restriction
|
|
1478 (widen)
|
57958
|
1479 (when backward
|
|
1480 ;; Hide Info file header for backward search
|
|
1481 (narrow-to-region (save-excursion
|
|
1482 (goto-char (point-min))
|
|
1483 (search-forward "\n\^_")
|
|
1484 (1- (point)))
|
|
1485 (point-max)))
|
51805
|
1486 (while (and (not give-up)
|
|
1487 (or (null found)
|
56866
|
1488 (if backward
|
|
1489 (isearch-range-invisible found beg-found)
|
57958
|
1490 (isearch-range-invisible beg-found found))
|
|
1491 ;; Skip node header line
|
|
1492 (save-excursion (forward-line -1)
|
|
1493 (looking-at "\^_"))))
|
56866
|
1494 (if (if backward
|
|
1495 (re-search-backward regexp bound t)
|
|
1496 (re-search-forward regexp bound t))
|
|
1497 (setq found (point) beg-found (if backward (match-end 0)
|
|
1498 (match-beginning 0)))
|
51805
|
1499 (setq give-up t)))))
|
|
1500 ;; If no subfiles, give error now.
|
|
1501 (if give-up
|
24963
|
1502 (if (null Info-current-subfile)
|
56866
|
1503 (if backward
|
|
1504 (re-search-backward regexp)
|
|
1505 (re-search-forward regexp))
|
51805
|
1506 (setq found nil)))
|
|
1507
|
56866
|
1508 (unless (or found bound)
|
51805
|
1509 (unwind-protect
|
|
1510 ;; Try other subfiles.
|
|
1511 (let ((list ()))
|
|
1512 (save-excursion
|
|
1513 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
1514 (goto-char (point-min))
|
|
1515 (search-forward "\n\^_\nIndirect:")
|
|
1516 (save-restriction
|
|
1517 (narrow-to-region (point)
|
|
1518 (progn (search-forward "\n\^_")
|
|
1519 (1- (point))))
|
16981
|
1520 (goto-char (point-min))
|
51805
|
1521 ;; Find the subfile we just searched.
|
|
1522 (search-forward (concat "\n" osubfile ": "))
|
|
1523 ;; Skip that one.
|
56866
|
1524 (forward-line (if backward 0 1))
|
51805
|
1525 ;; Make a list of all following subfiles.
|
|
1526 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
|
56866
|
1527 (while (not (if backward (bobp) (eobp)))
|
|
1528 (if backward
|
|
1529 (re-search-backward "\\(^.*\\): [0-9]+$")
|
|
1530 (re-search-forward "\\(^.*\\): [0-9]+$"))
|
51805
|
1531 (goto-char (+ (match-end 1) 2))
|
|
1532 (setq list (cons (cons (+ (point-min)
|
|
1533 (read (current-buffer)))
|
|
1534 (match-string-no-properties 1))
|
|
1535 list))
|
56866
|
1536 (goto-char (if backward
|
|
1537 (1- (match-beginning 0))
|
|
1538 (1+ (match-end 0)))))
|
51805
|
1539 ;; Put in forward order
|
|
1540 (setq list (nreverse list))))
|
|
1541 (while list
|
|
1542 (message "Searching subfile %s..." (cdr (car list)))
|
|
1543 (Info-read-subfile (car (car list)))
|
57958
|
1544 (when backward
|
|
1545 ;; Hide Info file header for backward search
|
|
1546 (narrow-to-region (save-excursion
|
|
1547 (goto-char (point-min))
|
|
1548 (search-forward "\n\^_")
|
|
1549 (1- (point)))
|
|
1550 (point-max))
|
|
1551 (goto-char (point-max)))
|
51805
|
1552 (setq list (cdr list))
|
|
1553 (setq give-up nil found nil)
|
|
1554 (while (and (not give-up)
|
|
1555 (or (null found)
|
56866
|
1556 (if backward
|
|
1557 (isearch-range-invisible found beg-found)
|
57958
|
1558 (isearch-range-invisible beg-found found))
|
|
1559 ;; Skip node header line
|
|
1560 (save-excursion (forward-line -1)
|
|
1561 (looking-at "\^_"))))
|
56866
|
1562 (if (if backward
|
|
1563 (re-search-backward regexp nil t)
|
|
1564 (re-search-forward regexp nil t))
|
|
1565 (setq found (point) beg-found (if backward (match-end 0)
|
|
1566 (match-beginning 0)))
|
51805
|
1567 (setq give-up t)))
|
|
1568 (if give-up
|
|
1569 (setq found nil))
|
24963
|
1570 (if found
|
51805
|
1571 (setq list nil)))
|
|
1572 (if found
|
|
1573 (message "")
|
|
1574 (signal 'search-failed (list regexp))))
|
|
1575 (if (not found)
|
|
1576 (progn (Info-read-subfile osubfile)
|
|
1577 (goto-char opoint)
|
|
1578 (Info-select-node)
|
|
1579 (set-window-start (selected-window) ostart)))))
|
56866
|
1580
|
|
1581 (if (and (string= osubfile Info-current-subfile)
|
|
1582 (> found opoint-min)
|
|
1583 (< found opoint-max))
|
|
1584 ;; Search landed in the same node
|
|
1585 (goto-char found)
|
|
1586 (widen)
|
|
1587 (goto-char found)
|
|
1588 (save-match-data (Info-select-node)))
|
|
1589
|
29446
|
1590 ;; Use string-equal, not equal, to ignore text props.
|
|
1591 (or (and (string-equal onode Info-current-node)
|
|
1592 (equal ofile Info-current-file))
|
56866
|
1593 (and isearch-mode isearch-wrapped (eq opoint opoint-min))
|
29446
|
1594 (setq Info-history (cons (list ofile onode opoint)
|
|
1595 Info-history))))))
|
54754
|
1596
|
|
1597 (defun Info-search-case-sensitively ()
|
|
1598 "Search for a regexp case-sensitively."
|
|
1599 (interactive)
|
|
1600 (let ((case-fold-search nil))
|
|
1601 (call-interactively 'Info-search)))
|
|
1602
|
|
1603 (defun Info-search-next ()
|
|
1604 "Search for next regexp from a previous `Info-search' command."
|
|
1605 (interactive)
|
|
1606 (let ((case-fold-search Info-search-case-fold))
|
|
1607 (if Info-search-history
|
|
1608 (Info-search (car Info-search-history))
|
|
1609 (call-interactively 'Info-search))))
|
56866
|
1610
|
|
1611 (defun Info-search-backward (regexp &optional bound noerror count)
|
|
1612 "Search for REGEXP in the reverse direction."
|
|
1613 (interactive (list (read-string
|
|
1614 (if Info-search-history
|
|
1615 (format "Regexp search%s backward (default `%s'): "
|
|
1616 (if case-fold-search "" " case-sensitively")
|
|
1617 (car Info-search-history))
|
|
1618 (format "Regexp search%s backward: "
|
|
1619 (if case-fold-search "" " case-sensitively")))
|
|
1620 nil 'Info-search-history)))
|
|
1621 (Info-search regexp bound noerror count 'backward))
|
|
1622
|
|
1623 (defun Info-isearch-search ()
|
|
1624 (cond
|
|
1625 (isearch-word
|
|
1626 (if isearch-forward 'word-search-forward 'word-search-backward))
|
|
1627 (isearch-regexp
|
|
1628 (lambda (regexp bound noerror)
|
|
1629 (condition-case nil
|
|
1630 (progn
|
|
1631 (Info-search regexp bound noerror nil
|
|
1632 (unless isearch-forward 'backward))
|
|
1633 (point))
|
|
1634 (error nil))))
|
|
1635 (t
|
|
1636 (if isearch-forward 'search-forward 'search-backward))))
|
|
1637
|
|
1638 (defun Info-isearch-wrap ()
|
|
1639 (if isearch-regexp
|
|
1640 (if isearch-forward (Info-top-node) (Info-final-node))
|
|
1641 (goto-char (if isearch-forward (point-min) (point-max)))))
|
|
1642
|
|
1643 (defun Info-isearch-push-state ()
|
|
1644 `(lambda (cmd)
|
|
1645 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node)))
|
|
1646
|
|
1647 (defun Info-isearch-pop-state (cmd file node)
|
|
1648 (or (and (string= Info-current-file file)
|
|
1649 (string= Info-current-node node))
|
|
1650 (progn (Info-find-node file node) (sit-for 0))))
|
|
1651
|
325
|
1652
|
|
1653 (defun Info-extract-pointer (name &optional errorname)
|
29621
|
1654 "Extract the value of the node-pointer named NAME.
|
|
1655 If there is none, use ERRORNAME in the error message;
|
51735
|
1656 if ERRORNAME is nil, just return nil."
|
|
1657 ;; Bind this in case the user sets it to nil.
|
22951
|
1658 (let ((case-fold-search t))
|
|
1659 (save-excursion
|
51735
|
1660 (goto-char (point-min))
|
|
1661 (let ((bound (point)))
|
|
1662 (forward-line 1)
|
|
1663 (cond ((re-search-backward
|
|
1664 (concat name ":" (Info-following-node-name-re)) bound t)
|
|
1665 (match-string 1))
|
|
1666 ((not (eq errorname t))
|
|
1667 (error "Node has no %s"
|
|
1668 (capitalize (or errorname name)))))))))
|
325
|
1669
|
51735
|
1670 (defun Info-following-node-name-re (&optional allowedchars)
|
|
1671 "Return a regexp matching a node name.
|
29621
|
1672 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
|
51735
|
1673 saying which chars may appear in the node name.
|
|
1674 Submatch 1 is the complete node name.
|
|
1675 Submatch 2 if non-nil is the parenthesized file name part of the node name.
|
|
1676 Submatch 3 is the local part of the node name.
|
|
1677 End of submatch 0, 1, and 3 are the same, so you can safely concat."
|
|
1678 (concat "[ \t]*" ;Skip leading space.
|
|
1679 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
|
|
1680 "\\([" (or allowedchars "^,\t\n") "]*" ;Any number of allowed chars.
|
|
1681 "[" (or allowedchars "^,\t\n") " ]" ;The last char can't be a space.
|
|
1682 "\\|\\)\\)")) ;Allow empty node names.
|
325
|
1683
|
52756
|
1684 ;;; For compatibility; other files have used this name.
|
|
1685 (defun Info-following-node-name ()
|
|
1686 (and (looking-at (Info-following-node-name-re))
|
|
1687 (match-string 1)))
|
|
1688
|
325
|
1689 (defun Info-next ()
|
|
1690 "Go to the next node of this node."
|
|
1691 (interactive)
|
|
1692 (Info-goto-node (Info-extract-pointer "next")))
|
|
1693
|
|
1694 (defun Info-prev ()
|
|
1695 "Go to the previous node of this node."
|
|
1696 (interactive)
|
|
1697 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
|
|
1698
|
21910
|
1699 (defun Info-up (&optional same-file)
|
|
1700 "Go to the superior node of this node.
|
|
1701 If SAME-FILE is non-nil, do not move to a different Info file."
|
325
|
1702 (interactive)
|
54754
|
1703 (let ((old-node Info-current-node)
|
|
1704 (old-file Info-current-file)
|
|
1705 (node (Info-extract-pointer "up")) p)
|
26004
|
1706 (and (or same-file (not (stringp Info-current-file)))
|
21910
|
1707 (string-match "^(" node)
|
|
1708 (error "Up node is in another Info file"))
|
54754
|
1709 (Info-goto-node node)
|
|
1710 (setq p (point))
|
|
1711 (goto-char (point-min))
|
|
1712 (if (and (search-forward "\n* Menu:" nil t)
|
|
1713 (re-search-forward
|
|
1714 (if (string-equal old-node "Top")
|
|
1715 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")")
|
|
1716 (concat "\n\\* +\\(" (regexp-quote old-node)
|
|
1717 ":\\|[^:]+: +" (regexp-quote old-node) "\\)"))
|
|
1718 nil t))
|
|
1719 (beginning-of-line)
|
|
1720 (goto-char p)
|
|
1721 (Info-restore-point Info-history))))
|
325
|
1722
|
|
1723 (defun Info-last ()
|
|
1724 "Go back to the last node visited."
|
|
1725 (interactive)
|
|
1726 (or Info-history
|
|
1727 (error "This is the first Info node you looked at"))
|
|
1728 (let (filename nodename opoint)
|
|
1729 (setq filename (car (car Info-history)))
|
|
1730 (setq nodename (car (cdr (car Info-history))))
|
|
1731 (setq opoint (car (cdr (cdr (car Info-history)))))
|
|
1732 (setq Info-history (cdr Info-history))
|
|
1733 (Info-find-node filename nodename)
|
|
1734 (setq Info-history (cdr Info-history))
|
|
1735 (goto-char opoint)))
|
|
1736
|
28558
|
1737 ;;;###autoload
|
325
|
1738 (defun Info-directory ()
|
|
1739 "Go to the Info directory node."
|
|
1740 (interactive)
|
|
1741 (Info-find-node "dir" "top"))
|
|
1742
|
54754
|
1743 (defun Info-history ()
|
55074
|
1744 "Go to a node with a menu of visited nodes."
|
54754
|
1745 (interactive)
|
|
1746 (let ((curr-file Info-current-file)
|
|
1747 (curr-node Info-current-node)
|
|
1748 p)
|
55074
|
1749 (with-current-buffer (get-buffer-create " *info-history*")
|
|
1750 (let ((inhibit-read-only t))
|
|
1751 (erase-buffer)
|
|
1752 (goto-char (point-min))
|
57329
|
1753 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
|
55074
|
1754 (insert "Recently Visited Nodes\n**********************\n\n")
|
|
1755 (insert "* Menu:\n\n")
|
|
1756 (let ((hl (delete '("history" "Top") Info-history-list)))
|
|
1757 (while hl
|
|
1758 (let ((file (nth 0 (car hl)))
|
|
1759 (node (nth 1 (car hl))))
|
|
1760 (if (and (string-equal file curr-file)
|
|
1761 (string-equal node curr-node))
|
|
1762 (setq p (point)))
|
|
1763 (insert "* " node ": (" (file-name-nondirectory file)
|
|
1764 ")" node ".\n"))
|
|
1765 (setq hl (cdr hl))))))
|
|
1766 (Info-find-node "history" "Top")
|
54754
|
1767 (goto-char (or p (point-min)))))
|
|
1768
|
|
1769 (defun Info-toc ()
|
56044
|
1770 "Go to a node with table of contents of the current Info file.
|
|
1771 Table of contents is created from the tree structure of menus."
|
54754
|
1772 (interactive)
|
57329
|
1773 (let ((curr-file (substring-no-properties Info-current-file))
|
|
1774 (curr-node (substring-no-properties Info-current-node))
|
54754
|
1775 p)
|
55074
|
1776 (with-current-buffer (get-buffer-create " *info-toc*")
|
|
1777 (let ((inhibit-read-only t)
|
|
1778 (node-list (Info-build-toc curr-file)))
|
|
1779 (erase-buffer)
|
|
1780 (goto-char (point-min))
|
57329
|
1781 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
|
55074
|
1782 (insert "Table of Contents\n*****************\n\n")
|
57329
|
1783 (insert "*Note Top: (" curr-file ")Top.\n")
|
55074
|
1784 (Info-insert-toc
|
|
1785 (nth 2 (assoc "Top" node-list)) ; get Top nodes
|
57329
|
1786 node-list 0 curr-file))
|
55074
|
1787 (if (not (bobp))
|
|
1788 (let ((Info-hide-note-references 'hide)
|
|
1789 (Info-fontify-visited-nodes nil))
|
55774
|
1790 (Info-mode)
|
55751
|
1791 (setq Info-current-file "toc" Info-current-node "Top")
|
57329
|
1792 (goto-char (point-min))
|
|
1793 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t)
|
|
1794 (point-min))
|
|
1795 (point-max))
|
|
1796 (Info-fontify-node)
|
|
1797 (widen)))
|
55074
|
1798 (goto-char (point-min))
|
|
1799 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
|
|
1800 (setq p (- p (length curr-node) 2))))
|
|
1801 (Info-find-node "toc" "Top")
|
54754
|
1802 (goto-char (or p (point-min)))))
|
|
1803
|
55074
|
1804 (defun Info-insert-toc (nodes node-list level curr-file)
|
54754
|
1805 "Insert table of contents with references to nodes."
|
|
1806 (let ((section "Top"))
|
|
1807 (while nodes
|
|
1808 (let ((node (assoc (car nodes) node-list)))
|
|
1809 (unless (member (nth 1 node) (list nil section))
|
|
1810 (insert (setq section (nth 1 node)) "\n"))
|
|
1811 (insert (make-string level ?\t))
|
55074
|
1812 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n")
|
|
1813 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file)
|
54754
|
1814 (setq nodes (cdr nodes))))))
|
|
1815
|
|
1816 (defun Info-build-toc (file)
|
|
1817 "Build table of contents from menus of Info FILE and its subfiles."
|
|
1818 (with-temp-buffer
|
57329
|
1819 (let* ((file (and (stringp file) (Info-find-file file)))
|
|
1820 (default-directory (or (and (stringp file)
|
|
1821 (file-name-directory file))
|
55751
|
1822 default-directory))
|
57329
|
1823 (main-file (and (stringp file) file))
|
55751
|
1824 (sections '(("Top" "Top")))
|
|
1825 nodes subfiles)
|
|
1826 (while (or main-file subfiles)
|
|
1827 (or main-file (message "Searching subfile %s..." (car subfiles)))
|
54754
|
1828 (erase-buffer)
|
55751
|
1829 (info-insert-file-contents (or main-file (car subfiles)))
|
|
1830 (goto-char (point-min))
|
54754
|
1831 (while (and (search-forward "\n\^_\nFile:" nil 'move)
|
|
1832 (search-forward "Node: " nil 'move))
|
|
1833 (let ((nodename (substring-no-properties (Info-following-node-name)))
|
|
1834 (bound (- (or (save-excursion (search-forward "\n\^_" nil t))
|
|
1835 (point-max)) 2))
|
|
1836 (section "Top")
|
|
1837 menu-items)
|
55751
|
1838 (when (and (not (Info-index-node nodename file))
|
54754
|
1839 (re-search-forward "^\\* Menu:" bound t))
|
|
1840 (forward-line 1)
|
|
1841 (beginning-of-line)
|
|
1842 (setq bound (or (and (equal nodename "Top")
|
|
1843 (save-excursion
|
|
1844 (re-search-forward
|
|
1845 "^[ \t-]*The Detailed Node Listing" nil t)))
|
|
1846 bound))
|
|
1847 (while (< (point) bound)
|
|
1848 (cond
|
|
1849 ;; Menu item line
|
|
1850 ((looking-at "^\\* +[^:]+:")
|
|
1851 (beginning-of-line)
|
|
1852 (forward-char 2)
|
|
1853 (let ((menu-node-name (substring-no-properties
|
|
1854 (Info-extract-menu-node-name))))
|
|
1855 (setq menu-items (cons menu-node-name menu-items))
|
|
1856 (if (equal nodename "Top")
|
|
1857 (setq sections
|
|
1858 (cons (list menu-node-name section) sections)))))
|
|
1859 ;; Other non-empty strings in the Top node are section names
|
|
1860 ((and (equal nodename "Top")
|
|
1861 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
|
|
1862 (setq section (match-string-no-properties 1))))
|
|
1863 (forward-line 1)
|
|
1864 (beginning-of-line)))
|
|
1865 (setq nodes (cons (list nodename
|
|
1866 (cadr (assoc nodename sections))
|
|
1867 (nreverse menu-items))
|
|
1868 nodes))
|
|
1869 (goto-char bound)))
|
55751
|
1870 (if main-file
|
54754
|
1871 (save-excursion
|
|
1872 (goto-char (point-min))
|
|
1873 (if (search-forward "\n\^_\nIndirect:" nil t)
|
|
1874 (let ((bound (save-excursion (search-forward "\n\^_" nil t))))
|
|
1875 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t)
|
|
1876 (setq subfiles (cons (match-string-no-properties 1)
|
|
1877 subfiles)))))
|
|
1878 (setq subfiles (nreverse subfiles)
|
55751
|
1879 main-file nil))
|
54754
|
1880 (setq subfiles (cdr subfiles))))
|
|
1881 (message "")
|
|
1882 (nreverse nodes))))
|
|
1883
|
|
1884 (defun Info-follow-reference (footnotename &optional fork)
|
29621
|
1885 "Follow cross reference named FOOTNOTENAME to the node it refers to.
|
54754
|
1886 FOOTNOTENAME may be an abbreviation of the reference name.
|
|
1887 If FORK is non-nil (interactively with a prefix arg), show the node in
|
|
1888 a new info buffer. If FORK is a string, it is the name to use for the
|
|
1889 new buffer."
|
325
|
1890 (interactive
|
|
1891 (let ((completion-ignore-case t)
|
22951
|
1892 (case-fold-search t)
|
5555
|
1893 completions default alt-default (start-point (point)) str i bol eol)
|
325
|
1894 (save-excursion
|
5555
|
1895 ;; Store end and beginning of line.
|
|
1896 (end-of-line)
|
|
1897 (setq eol (point))
|
|
1898 (beginning-of-line)
|
|
1899 (setq bol (point))
|
|
1900
|
325
|
1901 (goto-char (point-min))
|
54754
|
1902 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
|
51735
|
1903 (setq str (match-string-no-properties 1))
|
325
|
1904 ;; See if this one should be the default.
|
|
1905 (and (null default)
|
5146
aa2236a14893
(Info-follow-reference): Correct one-off error in comparing start-point.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1906 (<= (match-beginning 0) start-point)
|
325
|
1907 (<= start-point (point))
|
|
1908 (setq default t))
|
5555
|
1909 ;; See if this one should be the alternate default.
|
|
1910 (and (null alt-default)
|
|
1911 (and (<= bol (match-beginning 0))
|
|
1912 (<= (point) eol))
|
|
1913 (setq alt-default t))
|
325
|
1914 (setq i 0)
|
|
1915 (while (setq i (string-match "[ \n\t]+" str i))
|
|
1916 (setq str (concat (substring str 0 i) " "
|
|
1917 (substring str (match-end 0))))
|
|
1918 (setq i (1+ i)))
|
|
1919 ;; Record as a completion and perhaps as default.
|
|
1920 (if (eq default t) (setq default str))
|
5555
|
1921 (if (eq alt-default t) (setq alt-default str))
|
16609
|
1922 ;; Don't add this string if it's a duplicate.
|
51735
|
1923 (or (assoc-string str completions t)
|
|
1924 (push str completions))))
|
5555
|
1925 ;; If no good default was found, try an alternate.
|
|
1926 (or default
|
|
1927 (setq default alt-default))
|
|
1928 ;; If only one cross-reference found, then make it default.
|
|
1929 (if (eq (length completions) 1)
|
51735
|
1930 (setq default (car completions)))
|
325
|
1931 (if completions
|
3565
|
1932 (let ((input (completing-read (if default
|
39757
|
1933 (concat
|
|
1934 "Follow reference named: (default "
|
|
1935 default ") ")
|
3565
|
1936 "Follow reference named: ")
|
|
1937 completions nil t)))
|
|
1938 (list (if (equal input "")
|
54754
|
1939 default input) current-prefix-arg))
|
325
|
1940 (error "No cross-references in this node"))))
|
23038
|
1941
|
|
1942 (unless footnotename
|
|
1943 (error "No reference was specified"))
|
|
1944
|
51434
|
1945 (let (target i (str (concat "\\*note " (regexp-quote footnotename)))
|
22951
|
1946 (case-fold-search t))
|
325
|
1947 (while (setq i (string-match " " str i))
|
|
1948 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
|
|
1949 (setq i (+ i 6)))
|
|
1950 (save-excursion
|
54754
|
1951 ;; Move point to the beginning of reference if point is on reference
|
|
1952 (or (looking-at "\\*note[ \n\t]+")
|
|
1953 (and (looking-back "\\*note[ \n\t]+")
|
|
1954 (goto-char (match-beginning 0)))
|
|
1955 (if (and (save-excursion
|
|
1956 (goto-char (+ (point) 5)) ; skip a possible *note
|
|
1957 (re-search-backward "\\*note[ \n\t]+" nil t)
|
55174
|
1958 (looking-at str))
|
54754
|
1959 (<= (point) (match-end 0)))
|
|
1960 (goto-char (match-beginning 0))))
|
|
1961 ;; Go to the reference closest to point
|
|
1962 (let ((next-ref (save-excursion (and (re-search-forward str nil t)
|
|
1963 (+ (match-beginning 0) 5))))
|
|
1964 (prev-ref (save-excursion (and (re-search-backward str nil t)
|
|
1965 (+ (match-beginning 0) 5)))))
|
|
1966 (goto-char (cond ((and next-ref prev-ref)
|
|
1967 (if (< (abs (- next-ref (point)))
|
|
1968 (abs (- prev-ref (point))))
|
|
1969 next-ref prev-ref))
|
|
1970 ((or next-ref prev-ref))
|
|
1971 ((error "No cross-reference named %s" footnotename))))
|
|
1972 (setq target (Info-extract-menu-node-name t))))
|
325
|
1973 (while (setq i (string-match "[ \t\n]+" target i))
|
|
1974 (setq target (concat (substring target 0 i) " "
|
|
1975 (substring target (match-end 0))))
|
|
1976 (setq i (+ i 1)))
|
54754
|
1977 (Info-goto-node target fork)))
|
325
|
1978
|
51943
4ab63324776e
(Info-menu-entry-name-re): Allow newlines in menu entry names.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1979 (defconst Info-menu-entry-name-re "\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
|
4ab63324776e
(Info-menu-entry-name-re): Allow newlines in menu entry names.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1980 ;; We allow newline because this is also used in Info-follow-reference,
|
4ab63324776e
(Info-menu-entry-name-re): Allow newlines in menu entry names.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
1981 ;; where the xref name might be wrapped over two lines.
|
51735
|
1982 "Regexp that matches a menu entry name upto but not including the colon.
|
|
1983 Because of ambiguities, this should be concatenated with something like
|
|
1984 `:' and `Info-following-node-name-re'.")
|
|
1985
|
55174
|
1986 (defun Info-extract-menu-node-name (&optional multi-line index-node)
|
325
|
1987 (skip-chars-forward " \t\n")
|
51735
|
1988 (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|"
|
|
1989 (Info-following-node-name-re
|
55174
|
1990 (cond
|
|
1991 (index-node "^,\t\n")
|
|
1992 (multi-line "^.,\t")
|
|
1993 (t "^.,\t\n")))
|
|
1994 "\\)"
|
|
1995 (if index-node
|
|
1996 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
|
|
1997 "")))
|
|
1998 (if index-node
|
|
1999 (setq Info-point-loc
|
|
2000 (if (match-beginning 5)
|
|
2001 (string-to-number (match-string 5))
|
|
2002 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
|
57770
|
2003 ;;; Uncomment next line to use names of cross-references in non-index nodes:
|
55174
|
2004 ;;; (setq Info-point-loc
|
|
2005 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
|
|
2006 )
|
51735
|
2007 (replace-regexp-in-string
|
|
2008 "[ \n]+" " "
|
|
2009 (or (match-string 2)
|
|
2010 ;; If the node name is the menu entry name (using `entry::').
|
|
2011 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))))
|
325
|
2012
|
7837
|
2013 ;; No one calls this.
|
1484
|
2014 ;;(defun Info-menu-item-sequence (list)
|
|
2015 ;; (while list
|
7837
|
2016 ;; (Info-menu (car list))
|
1484
|
2017 ;; (setq list (cdr list))))
|
325
|
2018
|
22761
|
2019 (defvar Info-complete-menu-buffer)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2020 (defvar Info-complete-next-re nil)
|
55751
|
2021 (defvar Info-complete-nodes nil)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2022 (defvar Info-complete-cache nil)
|
22761
|
2023
|
51735
|
2024 (defconst Info-node-spec-re
|
|
2025 (concat (Info-following-node-name-re "^.,:") "[,:.]")
|
51437
63b62b12e01c
(Info-extract-menu-node-name): Remove unused arg `errmessage'.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2026 "Regexp to match the text after a : until the terminating `.'.")
|
63b62b12e01c
(Info-extract-menu-node-name): Remove unused arg `errmessage'.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2027
|
7837
|
2028 (defun Info-complete-menu-item (string predicate action)
|
41798
|
2029 ;; This uses two dynamically bound variables:
|
|
2030 ;; - `Info-complete-menu-buffer' which contains the buffer in which
|
|
2031 ;; is the menu of items we're trying to complete.
|
|
2032 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
|
|
2033 ;; also look for menu items in subsequent nodes as long as those
|
|
2034 ;; nodes' names match `Info-complete-next-re'. This feature is currently
|
55751
|
2035 ;; not used.
|
|
2036 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
|
|
2037 ;; also look for menu items in these nodes. This feature is currently
|
41798
|
2038 ;; only used for completion in Info-index.
|
51517
|
2039
|
|
2040 ;; Note that `Info-complete-menu-buffer' could be current already,
|
|
2041 ;; so we want to save point.
|
|
2042 (save-excursion
|
|
2043 (set-buffer Info-complete-menu-buffer)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2044 (let ((completion-ignore-case t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2045 (case-fold-search t)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2046 (orignode Info-current-node)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2047 nextnode)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2048 (goto-char (point-min))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2049 (search-forward "\n* Menu:")
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2050 (if (not (memq action '(nil t)))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2051 (re-search-forward
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2052 (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
|
2053 (let ((pattern (concat "\n\\* +\\("
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2054 (regexp-quote string)
|
51735
|
2055 Info-menu-entry-name-re "\\):" Info-node-spec-re))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2056 completions)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2057 ;; Check the cache.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2058 (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
|
2059 (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
|
2060 (equal (nth 2 Info-complete-cache) Info-complete-next-re)
|
55751
|
2061 (equal (nth 5 Info-complete-cache) Info-complete-nodes)
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2062 (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
|
2063 (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
|
2064 prev 0 nil t))))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2065 ;; We can reuse the previous list.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2066 (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
|
2067 ;; The cache can't be used.
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2068 (while
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2069 (progn
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2070 (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
|
2071 (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
|
2072 completions))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2073 ;; Check subsequent nodes if applicable.
|
55751
|
2074 (or (and Info-complete-next-re
|
|
2075 (setq nextnode (Info-extract-pointer "next" t))
|
|
2076 (string-match Info-complete-next-re nextnode))
|
|
2077 (and Info-complete-nodes
|
|
2078 (setq Info-complete-nodes (cdr Info-complete-nodes)
|
|
2079 nextnode (car Info-complete-nodes)))))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2080 (Info-goto-node nextnode))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2081 ;; 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
|
2082 (unless (equal Info-current-node orignode)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2083 (Info-goto-node orignode))
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2084 ;; Update the cache.
|
48977
ef739be93187
(Info-complete-menu-item): Make `Info-complete-cache' a buffer-local variable.
Miles Bader <miles@gnu.org>
diff
changeset
|
2085 (set (make-local-variable 'Info-complete-cache)
|
ef739be93187
(Info-complete-menu-item): Make `Info-complete-cache' a buffer-local variable.
Miles Bader <miles@gnu.org>
diff
changeset
|
2086 (list Info-current-file Info-current-node
|
55751
|
2087 Info-complete-next-re string completions
|
|
2088 Info-complete-nodes)))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2089 (if action
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2090 (all-completions string completions predicate)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2091 (try-completion string completions predicate)))))))
|
7837
|
2092
|
|
2093
|
26004
|
2094 (defun Info-menu (menu-item &optional fork)
|
39382
|
2095 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
|
|
2096 The menu item should one of those listed in the current node's menu.
|
|
2097 Completion is allowed, and the default menu item is the one point is on.
|
32286
|
2098 If FORK is non-nil (interactively with a prefix arg), show the node in
|
|
2099 a new info buffer. If FORK is a string, it is the name to use for the
|
|
2100 new buffer."
|
325
|
2101 (interactive
|
|
2102 (let ((completions '())
|
|
2103 ;; If point is within a menu item, use that item as the default
|
|
2104 (default nil)
|
|
2105 (p (point))
|
10957
|
2106 beg
|
29446
|
2107 (last nil)
|
|
2108 (case-fold-search t))
|
325
|
2109 (save-excursion
|
|
2110 (goto-char (point-min))
|
|
2111 (if (not (search-forward "\n* menu:" nil t))
|
|
2112 (error "No menu in this node"))
|
7837
|
2113 (setq beg (point))
|
|
2114 (and (< (point) p)
|
|
2115 (save-excursion
|
|
2116 (goto-char p)
|
|
2117 (end-of-line)
|
51784
|
2118 (if (re-search-backward (concat "\n\\* +\\("
|
|
2119 Info-menu-entry-name-re
|
|
2120 "\\):") beg t)
|
26580
|
2121 (setq default (match-string-no-properties 1))))))
|
325
|
2122 (let ((item nil))
|
|
2123 (while (null item)
|
7837
|
2124 (setq item (let ((completion-ignore-case t)
|
|
2125 (Info-complete-menu-buffer (current-buffer)))
|
325
|
2126 (completing-read (if default
|
|
2127 (format "Menu item (default %s): "
|
|
2128 default)
|
29446
|
2129 "Menu item: ")
|
7837
|
2130 'Info-complete-menu-item nil t)))
|
540
|
2131 ;; we rely on the fact that completing-read accepts an input
|
|
2132 ;; of "" even when the require-match argument is true and ""
|
|
2133 ;; is not a valid possibility
|
325
|
2134 (if (string= item "")
|
|
2135 (if default
|
|
2136 (setq item default)
|
29446
|
2137 ;; ask again
|
|
2138 (setq item nil))))
|
26004
|
2139 (list item current-prefix-arg))))
|
325
|
2140 ;; there is a problem here in that if several menu items have the same
|
|
2141 ;; name you can only go to the node of the first with this command.
|
26004
|
2142 (Info-goto-node (Info-extract-menu-item menu-item) (if fork menu-item)))
|
28943
|
2143
|
325
|
2144 (defun Info-extract-menu-item (menu-item)
|
|
2145 (setq menu-item (regexp-quote menu-item))
|
22951
|
2146 (let ((case-fold-search t))
|
|
2147 (save-excursion
|
29446
|
2148 (let ((case-fold-search t))
|
|
2149 (goto-char (point-min))
|
|
2150 (or (search-forward "\n* menu:" nil t)
|
|
2151 (error "No menu in this node"))
|
|
2152 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
|
|
2153 (re-search-forward (concat "\n\\* +" menu-item) nil t)
|
|
2154 (error "No such item in menu"))
|
|
2155 (beginning-of-line)
|
|
2156 (forward-char 2)
|
55751
|
2157 (Info-extract-menu-node-name nil (Info-index-node))))))
|
325
|
2158
|
|
2159 ;; If COUNT is nil, use the last item in the menu.
|
|
2160 (defun Info-extract-menu-counting (count)
|
22951
|
2161 (let ((case-fold-search t))
|
|
2162 (save-excursion
|
29446
|
2163 (let ((case-fold-search t))
|
|
2164 (goto-char (point-min))
|
|
2165 (or (search-forward "\n* menu:" nil t)
|
|
2166 (error "No menu in this node"))
|
|
2167 (if count
|
|
2168 (or (search-forward "\n* " nil t count)
|
|
2169 (error "Too few items in menu"))
|
|
2170 (while (search-forward "\n* " nil t)
|
|
2171 nil))
|
55751
|
2172 (Info-extract-menu-node-name nil (Info-index-node))))))
|
325
|
2173
|
1666
|
2174 (defun Info-nth-menu-item ()
|
|
2175 "Go to the node of the Nth menu item.
|
|
2176 N is the digit argument used to invoke this command."
|
325
|
2177 (interactive)
|
1666
|
2178 (Info-goto-node
|
|
2179 (Info-extract-menu-counting
|
|
2180 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
|
325
|
2181
|
|
2182 (defun Info-top-node ()
|
|
2183 "Go to the Top node of this file."
|
|
2184 (interactive)
|
|
2185 (Info-goto-node "Top"))
|
|
2186
|
|
2187 (defun Info-final-node ()
|
|
2188 "Go to the final node in this file."
|
|
2189 (interactive)
|
|
2190 (Info-goto-node "Top")
|
29446
|
2191 (let ((Info-history nil)
|
|
2192 (case-fold-search t))
|
325
|
2193 ;; Go to the last node in the menu of Top.
|
|
2194 (Info-goto-node (Info-extract-menu-counting nil))
|
|
2195 ;; If the last node in the menu is not last in pointer structure,
|
28943
|
2196 ;; move forward until we can't go any farther.
|
325
|
2197 (while (Info-forward-node t t) nil)
|
|
2198 ;; Then keep moving down to last subnode, unless we reach an index.
|
55751
|
2199 (while (and (not (Info-index-node))
|
325
|
2200 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
2201 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
2202
|
|
2203 (defun Info-forward-node (&optional not-down no-error)
|
|
2204 "Go forward one node, considering all nodes as forming one sequence."
|
|
2205 (interactive)
|
|
2206 (goto-char (point-min))
|
|
2207 (forward-line 1)
|
29446
|
2208 (let ((case-fold-search t))
|
|
2209 ;; three possibilities, in order of priority:
|
|
2210 ;; 1. next node is in a menu in this node (but not in an index)
|
|
2211 ;; 2. next node is next at same level
|
|
2212 ;; 3. next node is up and next
|
|
2213 (cond ((and (not not-down)
|
|
2214 (save-excursion (search-forward "\n* menu:" nil t))
|
55751
|
2215 (not (Info-index-node)))
|
29446
|
2216 (Info-goto-node (Info-extract-menu-counting 1))
|
|
2217 t)
|
48135
|
2218 ((save-excursion (search-backward "next:" nil t))
|
29446
|
2219 (Info-next)
|
|
2220 t)
|
48135
|
2221 ((and (save-excursion (search-backward "up:" nil t))
|
29446
|
2222 ;; Use string-equal, not equal, to ignore text props.
|
|
2223 (not (string-equal (downcase (Info-extract-pointer "up"))
|
|
2224 "top")))
|
|
2225 (let ((old-node Info-current-node))
|
|
2226 (Info-up)
|
|
2227 (let (Info-history success)
|
|
2228 (unwind-protect
|
|
2229 (setq success (Info-forward-node t no-error))
|
|
2230 (or success (Info-goto-node old-node))))))
|
|
2231 (no-error nil)
|
|
2232 (t (error "No pointer forward from this node")))))
|
325
|
2233
|
|
2234 (defun Info-backward-node ()
|
|
2235 "Go backward one node, considering all nodes as forming one sequence."
|
|
2236 (interactive)
|
|
2237 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
|
29446
|
2238 (upnode (Info-extract-pointer "up" t))
|
|
2239 (case-fold-search t))
|
325
|
2240 (cond ((and upnode (string-match "(" upnode))
|
|
2241 (error "First node in file"))
|
|
2242 ((and upnode (or (null prevnode)
|
11527
|
2243 ;; Use string-equal, not equal,
|
|
2244 ;; to ignore text properties.
|
|
2245 (string-equal (downcase prevnode)
|
|
2246 (downcase upnode))))
|
325
|
2247 (Info-up))
|
|
2248 (prevnode
|
|
2249 ;; If we move back at the same level,
|
|
2250 ;; go down to find the last subnode*.
|
|
2251 (Info-prev)
|
|
2252 (let (Info-history)
|
55751
|
2253 (while (and (not (Info-index-node))
|
325
|
2254 (save-excursion (search-forward "\n* Menu:" nil t)))
|
|
2255 (Info-goto-node (Info-extract-menu-counting nil)))))
|
|
2256 (t
|
|
2257 (error "No pointer backward from this node")))))
|
|
2258
|
|
2259 (defun Info-exit ()
|
|
2260 "Exit Info by selecting some other buffer."
|
|
2261 (interactive)
|
4410
|
2262 (if Info-standalone
|
|
2263 (save-buffers-kill-emacs)
|
22331
|
2264 (quit-window)))
|
325
|
2265
|
929
|
2266 (defun Info-next-menu-item ()
|
47794
|
2267 "Go to the node of the next menu item."
|
929
|
2268 (interactive)
|
29621
|
2269 ;; Bind this in case the user sets it to nil.
|
29446
|
2270 (let* ((case-fold-search t)
|
|
2271 (node
|
|
2272 (save-excursion
|
|
2273 (forward-line -1)
|
|
2274 (search-forward "\n* menu:" nil t)
|
|
2275 (and (search-forward "\n* " nil t)
|
|
2276 (Info-extract-menu-node-name)))))
|
23533
|
2277 (if node (Info-goto-node node)
|
|
2278 (error "No more items in menu"))))
|
929
|
2279
|
|
2280 (defun Info-last-menu-item ()
|
47794
|
2281 "Go to the node of the previous menu item."
|
929
|
2282 (interactive)
|
|
2283 (save-excursion
|
|
2284 (forward-line 1)
|
29621
|
2285 ;; Bind this in case the user sets it to nil.
|
29446
|
2286 (let* ((case-fold-search t)
|
|
2287 (beg (save-excursion
|
|
2288 (and (search-backward "\n* menu:" nil t)
|
|
2289 (point)))))
|
8489
|
2290 (or (and beg (search-backward "\n* " beg t))
|
|
2291 (error "No previous items in menu")))
|
|
2292 (Info-goto-node (save-excursion
|
|
2293 (goto-char (match-end 0))
|
|
2294 (Info-extract-menu-node-name)))))
|
929
|
2295
|
4410
|
2296 (defmacro Info-no-error (&rest body)
|
929
|
2297 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
|
|
2298
|
|
2299 (defun Info-next-preorder ()
|
8018
|
2300 "Go to the next subnode or the next node, or go up a level."
|
|
2301 (interactive)
|
|
2302 (cond ((Info-no-error (Info-next-menu-item)))
|
|
2303 ((Info-no-error (Info-next)))
|
21910
|
2304 ((Info-no-error (Info-up t))
|
12156
|
2305 ;; Since we have already gone thru all the items in this menu,
|
|
2306 ;; go up to the end of this node.
|
15575
|
2307 (goto-char (point-max))
|
|
2308 ;; Since logically we are done with the node with that menu,
|
|
2309 ;; move on from it.
|
|
2310 (Info-next-preorder))
|
8018
|
2311 (t
|
|
2312 (error "No more nodes"))))
|
929
|
2313
|
|
2314 (defun Info-last-preorder ()
|
|
2315 "Go to the last node, popping up a level if there is none."
|
|
2316 (interactive)
|
8489
|
2317 (cond ((Info-no-error
|
|
2318 (Info-last-menu-item)
|
|
2319 ;; If we go down a menu item, go to the end of the node
|
|
2320 ;; so we can scroll back through it.
|
12156
|
2321 (goto-char (point-max)))
|
15575
|
2322 ;; Keep going down, as long as there are nested menu nodes.
|
|
2323 (while (Info-no-error
|
|
2324 (Info-last-menu-item)
|
|
2325 ;; If we go down a menu item, go to the end of the node
|
|
2326 ;; so we can scroll back through it.
|
|
2327 (goto-char (point-max))))
|
12156
|
2328 (recenter -1))
|
34468
|
2329 ((and (Info-no-error (Info-extract-pointer "prev"))
|
|
2330 (not (equal (Info-extract-pointer "up")
|
21910
|
2331 (Info-extract-pointer "prev"))))
|
|
2332 (Info-no-error (Info-prev))
|
12156
|
2333 (goto-char (point-max))
|
15575
|
2334 (while (Info-no-error
|
|
2335 (Info-last-menu-item)
|
|
2336 ;; If we go down a menu item, go to the end of the node
|
|
2337 ;; so we can scroll back through it.
|
|
2338 (goto-char (point-max))))
|
12156
|
2339 (recenter -1))
|
21910
|
2340 ((Info-no-error (Info-up t))
|
12156
|
2341 (goto-char (point-min))
|
29446
|
2342 (let ((case-fold-search t))
|
|
2343 (or (search-forward "\n* Menu:" nil t)
|
|
2344 (goto-char (point-max)))))
|
12156
|
2345 (t (error "No previous nodes"))))
|
929
|
2346
|
|
2347 (defun Info-scroll-up ()
|
9222
|
2348 "Scroll one screenful forward in Info, considering all nodes as one sequence.
|
16498
|
2349 Once you scroll far enough in a node that its menu appears on the screen
|
34182
|
2350 but after point, the next scroll moves into its first subnode, unless
|
|
2351 `Info-scroll-prefer-subnodes' is nil.
|
16498
|
2352
|
34182
|
2353 When you scroll past the end of a node, that goes to the next node if
|
|
2354 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
|
|
2355 if this node has no successor, it moves to the parent node's successor,
|
|
2356 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
|
|
2357 the menu of a node, it moves to subnode indicated by the following menu
|
|
2358 item. (That case won't normally result from this command, but can happen
|
|
2359 in other ways.)"
|
16498
|
2360
|
929
|
2361 (interactive)
|
8489
|
2362 (if (or (< (window-start) (point-min))
|
|
2363 (> (window-start) (point-max)))
|
|
2364 (set-window-start (selected-window) (point)))
|
29446
|
2365 (let* ((case-fold-search t)
|
|
2366 (virtual-end (save-excursion
|
|
2367 (goto-char (point-min))
|
34182
|
2368 (if (and Info-scroll-prefer-subnodes
|
|
2369 (search-forward "\n* Menu:" nil t))
|
29446
|
2370 (point)
|
|
2371 (point-max)))))
|
8489
|
2372 (if (or (< virtual-end (window-start))
|
|
2373 (pos-visible-in-window-p virtual-end))
|
34182
|
2374 (cond
|
|
2375 (Info-scroll-prefer-subnodes (Info-next-preorder))
|
|
2376 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
|
|
2377 (t (Info-next-preorder)))
|
8489
|
2378 (scroll-up))))
|
929
|
2379
|
|
2380 (defun Info-scroll-down ()
|
9222
|
2381 "Scroll one screenful back in Info, considering all nodes as one sequence.
|
34468
|
2382 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
|
|
2383 is non-nil, this goes to its last subnode. When you scroll past the
|
|
2384 beginning of a node, that goes to the previous node or back up to the
|
|
2385 parent node."
|
929
|
2386 (interactive)
|
8489
|
2387 (if (or (< (window-start) (point-min))
|
|
2388 (> (window-start) (point-max)))
|
|
2389 (set-window-start (selected-window) (point)))
|
29446
|
2390 (let* ((case-fold-search t)
|
|
2391 (current-point (point))
|
34468
|
2392 (virtual-end
|
|
2393 (and Info-scroll-prefer-subnodes
|
|
2394 (save-excursion
|
|
2395 (beginning-of-line)
|
|
2396 (setq current-point (point))
|
|
2397 (goto-char (point-min))
|
|
2398 (search-forward "\n* Menu:"
|
|
2399 current-point
|
|
2400 t)))))
|
47794
|
2401 (if (or virtual-end
|
36894
|
2402 (pos-visible-in-window-p (point-min) nil t))
|
8489
|
2403 (Info-last-preorder)
|
|
2404 (scroll-down))))
|
929
|
2405
|
15055
|
2406 (defun Info-next-reference (&optional recur)
|
4410
|
2407 "Move cursor to the next cross-reference or menu item in the node."
|
|
2408 (interactive)
|
54754
|
2409 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
|
22951
|
2410 (old-pt (point))
|
|
2411 (case-fold-search t))
|
4410
|
2412 (or (eobp) (forward-char 1))
|
|
2413 (or (re-search-forward pat nil t)
|
|
2414 (progn
|
|
2415 (goto-char (point-min))
|
|
2416 (or (re-search-forward pat nil t)
|
|
2417 (progn
|
|
2418 (goto-char old-pt)
|
|
2419 (error "No cross references in this node")))))
|
54754
|
2420 (goto-char (or (match-beginning 1) (match-beginning 0)))
|
4410
|
2421 (if (looking-at "\\* Menu:")
|
15055
|
2422 (if recur
|
|
2423 (error "No cross references in this node")
|
|
2424 (Info-next-reference t)))))
|
4410
|
2425
|
15055
|
2426 (defun Info-prev-reference (&optional recur)
|
4410
|
2427 "Move cursor to the previous cross-reference or menu item in the node."
|
|
2428 (interactive)
|
54754
|
2429 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
|
22951
|
2430 (old-pt (point))
|
|
2431 (case-fold-search t))
|
4410
|
2432 (or (re-search-backward pat nil t)
|
|
2433 (progn
|
|
2434 (goto-char (point-max))
|
|
2435 (or (re-search-backward pat nil t)
|
|
2436 (progn
|
|
2437 (goto-char old-pt)
|
|
2438 (error "No cross references in this node")))))
|
54754
|
2439 (goto-char (or (match-beginning 1) (match-beginning 0)))
|
4410
|
2440 (if (looking-at "\\* Menu:")
|
15055
|
2441 (if recur
|
|
2442 (error "No cross references in this node")
|
|
2443 (Info-prev-reference t)))))
|
55751
|
2444
|
|
2445 (defvar Info-index-nodes nil
|
|
2446 "Alist of cached index node names of visited Info files.
|
|
2447 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
|
|
2448
|
|
2449 (defun Info-index-nodes (&optional file)
|
|
2450 "Return a list of names of all index nodes in Info FILE.
|
|
2451 If FILE is omitted, it defaults to the current Info file.
|
55774
|
2452 First look in a list of cached index node names. Then scan Info
|
|
2453 file and its subfiles for nodes with the index cookie. Then try
|
|
2454 to find index nodes starting from the first node in the top level
|
|
2455 menu whose name contains the word \"Index\", plus any immediately
|
|
2456 following nodes whose names also contain the word \"Index\"."
|
55751
|
2457 (or file (setq file Info-current-file))
|
|
2458 (or (assoc file Info-index-nodes)
|
|
2459 ;; Skip virtual Info files
|
55774
|
2460 (and (member file '("dir" "history" "toc" "apropos"))
|
|
2461 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
|
|
2462 (not (stringp file))
|
55751
|
2463 ;; Find nodes with index cookie
|
|
2464 (let* ((default-directory (or (and (stringp file)
|
|
2465 (file-name-directory
|
|
2466 (setq file (Info-find-file file))))
|
|
2467 default-directory))
|
55774
|
2468 Info-history Info-history-list Info-fontify-maximum-menu-size
|
|
2469 (main-file file) subfiles nodes node)
|
|
2470 (condition-case nil
|
|
2471 (with-temp-buffer
|
|
2472 (while (or main-file subfiles)
|
|
2473 (erase-buffer)
|
|
2474 (info-insert-file-contents (or main-file (car subfiles)))
|
|
2475 (goto-char (point-min))
|
|
2476 (while (search-forward "\0\b[index\0\b]" nil 'move)
|
|
2477 (save-excursion
|
|
2478 (re-search-backward "^\^_")
|
|
2479 (search-forward "Node: ")
|
|
2480 (setq nodes (cons (Info-following-node-name) nodes))))
|
|
2481 (if main-file
|
|
2482 (save-excursion
|
|
2483 (goto-char (point-min))
|
|
2484 (if (search-forward "\n\^_\nIndirect:" nil t)
|
|
2485 (let ((bound (save-excursion (search-forward "\n\^_" nil t))))
|
|
2486 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t)
|
|
2487 (setq subfiles (cons (match-string-no-properties 1)
|
|
2488 subfiles)))))
|
|
2489 (setq subfiles (nreverse subfiles)
|
|
2490 main-file nil))
|
|
2491 (setq subfiles (cdr subfiles)))))
|
|
2492 (error nil))
|
55751
|
2493 (if nodes
|
|
2494 (setq nodes (nreverse nodes)
|
|
2495 Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
|
|
2496 nodes)
|
55774
|
2497 ;; Find nodes with the word "Index" in the node name
|
|
2498 (let ((case-fold-search t)
|
|
2499 Info-history Info-history-list Info-fontify-maximum-menu-size
|
|
2500 nodes node)
|
|
2501 (condition-case nil
|
|
2502 (with-temp-buffer
|
|
2503 (Info-mode)
|
|
2504 (Info-find-node file "Top")
|
|
2505 (when (and (search-forward "\n* menu:" nil t)
|
|
2506 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
|
|
2507 (goto-char (match-beginning 1))
|
|
2508 (setq nodes (list (Info-extract-menu-node-name)))
|
|
2509 (Info-goto-node (car nodes))
|
|
2510 (while (and (setq node (Info-extract-pointer "next" t))
|
|
2511 (string-match "\\<Index\\>" node))
|
|
2512 (setq nodes (cons node nodes))
|
|
2513 (Info-goto-node node))))
|
|
2514 (error nil))
|
55751
|
2515 (if nodes
|
|
2516 (setq nodes (nreverse nodes)
|
|
2517 Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
|
|
2518 nodes)
|
55774
|
2519 ;; If file has no index nodes, still add it to the cache
|
|
2520 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
|
55751
|
2521 (cdr (assoc file Info-index-nodes)))
|
|
2522
|
|
2523 (defun Info-index-node (&optional node file)
|
|
2524 "Return non-nil value if NODE is an index node.
|
|
2525 If NODE is nil, check the current Info node.
|
|
2526 If FILE is nil, check the current Info file."
|
55774
|
2527 (if (or (and node (not (equal node Info-current-node)))
|
|
2528 (assoc (or file Info-current-file) Info-index-nodes))
|
|
2529 (member (or node Info-current-node) (Info-index-nodes file))
|
|
2530 ;; Don't search all index nodes if request is only for the current node
|
|
2531 ;; and file is not in the cache of index nodes
|
|
2532 (or
|
|
2533 (save-match-data
|
|
2534 (string-match "\\<Index\\>" (or node Info-current-node "")))
|
|
2535 (save-excursion
|
|
2536 (goto-char (+ (or (save-excursion
|
|
2537 (search-backward "\n\^_" nil t))
|
|
2538 (point-min)) 2))
|
|
2539 (search-forward "\0\b[index\0\b]"
|
|
2540 (or (save-excursion
|
|
2541 (search-forward "\n\^_" nil t))
|
|
2542 (point-max)) t)))))
|
4410
|
2543
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2544 (defun Info-goto-index ()
|
55751
|
2545 "Go to the first index node."
|
|
2546 (let ((node (car (Info-index-nodes))))
|
|
2547 (or node (error "No index"))
|
|
2548 (Info-goto-node node)))
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2549
|
51283
|
2550 ;;;###autoload
|
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
|
2551 (defun Info-index (topic)
|
29621
|
2552 "Look up a string TOPIC in the index for this file.
|
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
|
2553 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
|
2554 the first match which is a case-insensitive substring of a topic.
|
55074
|
2555 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other 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
|
2556 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
|
2557 (interactive
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2558 (list
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2559 (let ((Info-complete-menu-buffer (clone-buffer))
|
55751
|
2560 (Info-complete-nodes (Info-index-nodes))
|
|
2561 (Info-history-list nil))
|
46104
|
2562 (if (equal Info-current-file "dir")
|
|
2563 (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
|
2564 (unwind-protect
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2565 (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
|
2566 (Info-goto-index)
|
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2567 (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
|
2568 (kill-buffer Info-complete-menu-buffer)))))
|
46104
|
2569 (if (equal Info-current-file "dir")
|
|
2570 (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
|
2571 (let ((orignode Info-current-node)
|
55174
|
2572 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([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
|
2573 (regexp-quote topic)))
|
55751
|
2574 node (nodes (Info-index-nodes))
|
|
2575 (ohist-list Info-history-list)
|
22951
|
2576 (case-fold-search t))
|
41691
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2577 (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
|
2578 (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
|
2579 (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
|
2580 (exact nil)
|
41691
3317b62de647
(Info-goto-index): One register one step in the history.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2581 ;; 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
|
2582 ;; 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
|
2583 ;; 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
|
2584 ;; because that is what the user's previous node choice into it.
|
10758
|
2585 (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
|
2586 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
|
2587 (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
|
2588 (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
|
2589 (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
|
2590 (while (re-search-forward pattern nil t)
|
31942
|
2591 (push (list (match-string-no-properties 1)
|
|
2592 (match-string-no-properties 2)
|
|
2593 Info-current-node
|
47794
|
2594 (string-to-number (concat "0"
|
|
2595 (match-string 3))))
|
31942
|
2596 matches))
|
55751
|
2597 (setq nodes (cdr nodes) node (car nodes)))
|
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
|
2598 (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
|
2599 (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
|
2600 (progn
|
14664
|
2601 (Info-goto-node orignode)
|
14560
|
2602 (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
|
2603 ;; 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
|
2604 (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
|
2605 (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
|
2606 matches (delq found matches)))
|
55751
|
2607 (setq Info-history-list ohist-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
|
2608 (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
|
2609 (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
|
2610
|
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
2611 (defun Info-index-next (num)
|
55074
|
2612 "Go to the next matching index item from the last \\<Info-mode-map>\\[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
|
2613 (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
|
2614 (or Info-index-alternatives
|
16790
|
2615 (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
|
2616 (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
|
2617 (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
|
2618 (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
|
2619 (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
|
2620 (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
|
2621 (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
|
2622 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
|
2623 (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
|
2624 (if (> (nth 3 (car Info-index-alternatives)) 0)
|
55174
|
2625 (forward-line (1- (nth 3 (car Info-index-alternatives))))
|
29446
|
2626 (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
|
2627 (let ((name (car (car Info-index-alternatives))))
|
14560
|
2628 (Info-find-index-name name)))
|
|
2629 (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
|
2630 (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
|
2631 (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
|
2632 (if (cdr Info-index-alternatives)
|
49380
|
2633 "(`,' tries to find next)"
|
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
|
2634 "(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
|
2635
|
14560
|
2636 (defun Info-find-index-name (name)
|
|
2637 "Move point to the place within the current node where NAME is defined."
|
22951
|
2638 (let ((case-fold-search t))
|
|
2639 (if (or (re-search-forward (format
|
|
2640 "[a-zA-Z]+: %s\\( \\|$\\)"
|
|
2641 (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
|
2642 ;; 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
|
2643 (re-search-forward (format
|
46714
|
2644 "[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
|
2645 (regexp-quote name)) nil t)
|
22951
|
2646 (search-forward (format "`%s'" name) nil t)
|
|
2647 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
|
|
2648 (search-forward
|
|
2649 (format "`%s'" (substring name 0 (match-beginning 1)))
|
|
2650 nil t))
|
52648
928f0fb38bfa
(Info-find-index-name): Search both with and without the " <1>" etc.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2651 (search-forward name nil t)
|
928f0fb38bfa
(Info-find-index-name): Search both with and without the " <1>" etc.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2652 ;; Try again without the " <1>" makeinfo can append
|
928f0fb38bfa
(Info-find-index-name): Search both with and without the " <1>" etc.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2653 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name)
|
928f0fb38bfa
(Info-find-index-name): Search both with and without the " <1>" etc.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2654 (Info-find-index-name (match-string 1 name))))
|
928f0fb38bfa
(Info-find-index-name): Search both with and without the " <1>" etc.
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
2655 (progn (beginning-of-line) t) ;; non-nil for recursive call
|
22951
|
2656 (goto-char (point-min)))))
|
14560
|
2657
|
54718
|
2658 ;;;###autoload
|
|
2659 (defun info-apropos (string)
|
|
2660 "Grovel indices of all known Info files on your system for STRING.
|
|
2661 Build a menu of the possible matches."
|
|
2662 (interactive "sIndex apropos: ")
|
|
2663 (unless (string= string "")
|
55174
|
2664 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
|
54718
|
2665 (regexp-quote string)))
|
|
2666 (ohist Info-history)
|
54865
|
2667 (ohist-list Info-history-list)
|
54718
|
2668 (current-node Info-current-node)
|
|
2669 (current-file Info-current-file)
|
55751
|
2670 manuals matches node nodes)
|
|
2671 (let ((Info-fontify-maximum-menu-size nil))
|
54718
|
2672 (Info-directory)
|
|
2673 (message "Searching indices...")
|
|
2674 (goto-char (point-min))
|
|
2675 (re-search-forward "\\* Menu: *\n" nil t)
|
54765
|
2676 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t)
|
54718
|
2677 (add-to-list 'manuals (match-string 1)))
|
|
2678 (dolist (manual manuals)
|
|
2679 (message "Searching %s" manual)
|
55751
|
2680 (if (setq nodes (Info-index-nodes (Info-find-file manual)))
|
|
2681 (condition-case nil
|
|
2682 (save-excursion
|
|
2683 (Info-find-node manual (car nodes))
|
|
2684 (while
|
|
2685 (progn
|
|
2686 (goto-char (point-min))
|
|
2687 (while (re-search-forward pattern nil t)
|
|
2688 (add-to-list 'matches
|
|
2689 (list manual
|
|
2690 (match-string-no-properties 1)
|
|
2691 (match-string-no-properties 2)
|
|
2692 (match-string-no-properties 3))))
|
|
2693 (setq nodes (cdr nodes) node (car nodes)))
|
|
2694 (Info-goto-node node)))
|
|
2695 (error nil)))))
|
54718
|
2696 (Info-goto-node (concat "(" current-file ")" current-node))
|
54865
|
2697 (setq Info-history ohist
|
|
2698 Info-history-list ohist-list)
|
54718
|
2699 (message "Searching indices...done")
|
|
2700 (if (null matches)
|
|
2701 (message "No matches found")
|
|
2702 (with-current-buffer (get-buffer-create " *info-apropos*")
|
|
2703 (erase-buffer)
|
55751
|
2704 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
|
54718
|
2705 (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n")
|
|
2706 (dolist (entry matches)
|
55200
|
2707 (insert
|
|
2708 (format "* %-38s (%s)%s.%s\n"
|
|
2709 (concat (nth 1 entry) " [" (nth 0 entry) "]:")
|
|
2710 (nth 0 entry)
|
|
2711 (nth 2 entry)
|
|
2712 (if (nth 3 entry)
|
|
2713 (concat " (line " (nth 3 entry) ")")
|
|
2714 "")))))
|
|
2715 (Info-find-node "apropos" "Index")
|
55134
|
2716 (setq Info-complete-cache nil)))))
|
54718
|
2717
|
325
|
2718 (defun Info-undefined ()
|
|
2719 "Make command be undefined in Info."
|
|
2720 (interactive)
|
|
2721 (ding))
|
|
2722
|
|
2723 (defun Info-help ()
|
|
2724 "Enter the Info tutorial."
|
|
2725 (interactive)
|
|
2726 (delete-other-windows)
|
|
2727 (Info-find-node "info"
|
|
2728 (if (< (window-height) 23)
|
|
2729 "Help-Small-Screen"
|
|
2730 "Help")))
|
|
2731
|
|
2732 (defun Info-summary ()
|
|
2733 "Display a brief summary of all Info commands."
|
|
2734 (interactive)
|
|
2735 (save-window-excursion
|
|
2736 (switch-to-buffer "*Help*")
|
20910
|
2737 (setq buffer-read-only nil)
|
325
|
2738 (erase-buffer)
|
|
2739 (insert (documentation 'Info-mode))
|
9852
|
2740 (help-mode)
|
325
|
2741 (goto-char (point-min))
|
|
2742 (let (ch flag)
|
|
2743 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
|
|
2744 (message (if flag "Type Space to see more"
|
|
2745 "Type Space to return to Info"))
|
2032
|
2746 (if (not (eq ?\ (setq ch (read-event))))
|
1821
|
2747 (progn (setq unread-command-events (list ch)) nil)
|
325
|
2748 flag))
|
4410
|
2749 (scroll-up)))
|
|
2750 (bury-buffer "*Help*")))
|
325
|
2751
|
|
2752 (defun Info-get-token (pos start all &optional errorstring)
|
29621
|
2753 "Return the token around POS.
|
325
|
2754 POS must be somewhere inside the token
|
|
2755 START is a regular expression which will match the
|
|
2756 beginning of the tokens delimited string
|
|
2757 ALL is a regular expression with a single
|
13990
|
2758 parenthesized subpattern which is the token to be
|
29621
|
2759 returned. E.g. '{\(.*\)}' would return any string
|
325
|
2760 enclosed in braces around POS.
|
29621
|
2761 ERRORSTRING optional fourth argument, controls action on no match
|
325
|
2762 nil: return nil
|
|
2763 t: beep
|
|
2764 a string: signal an error, using that string."
|
22951
|
2765 (let ((case-fold-search t))
|
|
2766 (save-excursion
|
|
2767 (goto-char pos)
|
|
2768 ;; First look for a match for START that goes across POS.
|
|
2769 (while (and (not (bobp)) (> (point) (- pos (length start)))
|
|
2770 (not (looking-at start)))
|
|
2771 (forward-char -1))
|
|
2772 ;; If we did not find one, search back for START
|
|
2773 ;; (this finds only matches that end at or before POS).
|
|
2774 (or (looking-at start)
|
|
2775 (progn
|
|
2776 (goto-char pos)
|
|
2777 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
|
|
2778 (let (found)
|
|
2779 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
|
|
2780 (not (setq found (and (<= (match-beginning 0) pos)
|
|
2781 (> (match-end 0) pos))))))
|
|
2782 (if (and found (<= (match-beginning 0) pos)
|
|
2783 (> (match-end 0) pos))
|
26580
|
2784 (match-string-no-properties 1)
|
22951
|
2785 (cond ((null errorstring)
|
|
2786 nil)
|
|
2787 ((eq errorstring t)
|
|
2788 (beep)
|
|
2789 nil)
|
|
2790 (t
|
|
2791 (error "No %s around position %d" errorstring pos))))))))
|
325
|
2792
|
7007
|
2793 (defun Info-mouse-follow-nearest-node (click)
|
1309
|
2794 "\\<Info-mode-map>Follow a node reference near point.
|
|
2795 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
|
7007
|
2796 At end of the node's text, moves to the next node, or up if none."
|
1309
|
2797 (interactive "e")
|
32500
|
2798 (mouse-set-point click)
|
7007
|
2799 (and (not (Info-try-follow-nearest-node))
|
|
2800 (save-excursion (forward-line 1) (eobp))
|
12156
|
2801 (Info-next-preorder)))
|
7007
|
2802
|
54754
|
2803 (defun Info-follow-nearest-node (&optional fork)
|
49678
|
2804 "Follow a node reference near point.
|
|
2805 If point is on a reference, follow that reference. Otherwise,
|
|
2806 if point is in a menu item description, follow that menu item."
|
54754
|
2807 (interactive "P")
|
|
2808 (or (Info-try-follow-nearest-node fork)
|
49678
|
2809 (when (save-excursion
|
|
2810 (search-backward "\n* menu:" nil t))
|
|
2811 (save-excursion
|
|
2812 (beginning-of-line)
|
|
2813 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
|
|
2814 (beginning-of-line 0))
|
|
2815 (when (looking-at "\\* +\\([^\t\n]*\\):")
|
|
2816 (Info-goto-node
|
54754
|
2817 (Info-extract-menu-item (match-string-no-properties 1)) fork)
|
49678
|
2818 t)))
|
|
2819 (error "Point neither on reference nor in menu item description")))
|
7007
|
2820
|
|
2821 ;; Common subroutine.
|
54754
|
2822 (defun Info-try-follow-nearest-node (&optional fork)
|
7007
|
2823 "Follow a node reference near point. Return non-nil if successful."
|
48135
|
2824 (let (node)
|
325
|
2825 (cond
|
54754
|
2826 ((and (Info-get-token (point) "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
|
|
2827 (or (featurep 'browse-url) (require 'browse-url nil t)))
|
|
2828 (setq node t)
|
|
2829 (browse-url (browse-url-url-at-point)))
|
|
2830 ((setq node (Info-get-token (point) "\\*note[ \n\t]+"
|
|
2831 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
|
|
2832 (Info-follow-reference node fork))
|
49426
|
2833 ;; menu item: node name
|
21641
|
2834 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
|
54754
|
2835 (Info-goto-node node fork))
|
55174
|
2836 ;; menu item: node name or index entry
|
49426
|
2837 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
|
23019
|
2838 (beginning-of-line)
|
|
2839 (forward-char 2)
|
55751
|
2840 (setq node (Info-extract-menu-node-name nil (Info-index-node)))
|
54754
|
2841 (Info-goto-node node fork))
|
3127
|
2842 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
|
54754
|
2843 (Info-goto-node node fork))
|
3127
|
2844 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
|
54754
|
2845 (Info-goto-node node fork))
|
3127
|
2846 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
|
54754
|
2847 (Info-goto-node "Top" fork))
|
3127
|
2848 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
|
54754
|
2849 (Info-goto-node node fork)))
|
7007
|
2850 node))
|
325
|
2851
|
|
2852 (defvar Info-mode-map nil
|
|
2853 "Keymap containing Info commands.")
|
|
2854 (if Info-mode-map
|
|
2855 nil
|
|
2856 (setq Info-mode-map (make-keymap))
|
|
2857 (suppress-keymap Info-mode-map)
|
|
2858 (define-key Info-mode-map "." 'beginning-of-buffer)
|
929
|
2859 (define-key Info-mode-map " " 'Info-scroll-up)
|
7007
|
2860 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
|
4410
|
2861 (define-key Info-mode-map "\t" 'Info-next-reference)
|
52368
|
2862 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference)
|
|
2863 (define-key Info-mode-map [backtab] 'Info-prev-reference)
|
1666
|
2864 (define-key Info-mode-map "1" 'Info-nth-menu-item)
|
|
2865 (define-key Info-mode-map "2" 'Info-nth-menu-item)
|
|
2866 (define-key Info-mode-map "3" 'Info-nth-menu-item)
|
|
2867 (define-key Info-mode-map "4" 'Info-nth-menu-item)
|
|
2868 (define-key Info-mode-map "5" 'Info-nth-menu-item)
|
|
2869 (define-key Info-mode-map "6" 'Info-nth-menu-item)
|
|
2870 (define-key Info-mode-map "7" 'Info-nth-menu-item)
|
|
2871 (define-key Info-mode-map "8" 'Info-nth-menu-item)
|
|
2872 (define-key Info-mode-map "9" 'Info-nth-menu-item)
|
1667
|
2873 (define-key Info-mode-map "0" 'undefined)
|
325
|
2874 (define-key Info-mode-map "?" 'Info-summary)
|
|
2875 (define-key Info-mode-map "]" 'Info-forward-node)
|
|
2876 (define-key Info-mode-map "[" 'Info-backward-node)
|
|
2877 (define-key Info-mode-map "<" 'Info-top-node)
|
|
2878 (define-key Info-mode-map ">" 'Info-final-node)
|
|
2879 (define-key Info-mode-map "b" 'beginning-of-buffer)
|
45182
|
2880 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
|
325
|
2881 (define-key Info-mode-map "d" 'Info-directory)
|
|
2882 (define-key Info-mode-map "e" 'Info-edit)
|
|
2883 (define-key Info-mode-map "f" 'Info-follow-reference)
|
|
2884 (define-key Info-mode-map "g" 'Info-goto-node)
|
|
2885 (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
|
2886 (define-key Info-mode-map "i" 'Info-index)
|
325
|
2887 (define-key Info-mode-map "l" 'Info-last)
|
56044
|
2888 (define-key Info-mode-map "L" 'Info-history)
|
325
|
2889 (define-key Info-mode-map "m" 'Info-menu)
|
|
2890 (define-key Info-mode-map "n" 'Info-next)
|
|
2891 (define-key Info-mode-map "p" 'Info-prev)
|
|
2892 (define-key Info-mode-map "q" 'Info-exit)
|
|
2893 (define-key Info-mode-map "s" 'Info-search)
|
55774
|
2894 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
|
8739
|
2895 ;; For consistency with Rmail.
|
|
2896 (define-key Info-mode-map "\M-s" 'Info-search)
|
26004
|
2897 (define-key Info-mode-map "\M-n" 'clone-buffer)
|
3313
|
2898 (define-key Info-mode-map "t" 'Info-top-node)
|
56044
|
2899 (define-key Info-mode-map "T" 'Info-toc)
|
325
|
2900 (define-key Info-mode-map "u" 'Info-up)
|
55774
|
2901 ;; For consistency with dired-copy-filename-as-kill.
|
|
2902 (define-key Info-mode-map "w" 'Info-copy-current-node-name)
|
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
|
2903 (define-key Info-mode-map "," 'Info-index-next)
|
930
|
2904 (define-key Info-mode-map "\177" 'Info-scroll-down)
|
7007
|
2905 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
|
540
|
2906 )
|
16043
|
2907
|
|
2908 (defun Info-check-pointer (item)
|
29621
|
2909 "Non-nil if ITEM is present in this node."
|
16043
|
2910 (condition-case nil
|
|
2911 (Info-extract-pointer item)
|
|
2912 (error nil)))
|
|
2913
|
30220
|
2914 (easy-menu-define
|
|
2915 Info-mode-menu Info-mode-map
|
|
2916 "Menu for info files."
|
|
2917 '("Info"
|
|
2918 ["Up" Info-up :active (Info-check-pointer "up")
|
|
2919 :help "Go up in the Info tree"]
|
|
2920 ["Next" Info-next :active (Info-check-pointer "next")
|
|
2921 :help "Go to the next node"]
|
|
2922 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
|
|
2923 :help "Go to the previous node"]
|
|
2924 ["Backward" Info-backward-node
|
|
2925 :help "Go backward one node, considering all as a sequence"]
|
|
2926 ["Forward" Info-forward-node
|
|
2927 :help "Go forward one node, considering all as a sequence"]
|
32286
|
2928 ["Beginning" beginning-of-buffer
|
|
2929 :help "Go to beginning of this node"]
|
30220
|
2930 ["Top" Info-top-node
|
|
2931 :help "Go to top node of file"]
|
|
2932 ["Final Node" Info-final-node
|
|
2933 :help "Go to final node in this file"]
|
|
2934 ("Menu Item" ["You should never see this" report-emacs-bug t])
|
|
2935 ("Reference" ["You should never see this" report-emacs-bug t])
|
|
2936 ["Search..." Info-search
|
|
2937 :help "Search for regular expression in this Info file"]
|
54754
|
2938 ["Search Case-Sensitively..." Info-search-case-sensitively
|
|
2939 :help "Search for regular expression case sensitively"]
|
|
2940 ["Search Next" Info-search-next
|
|
2941 :help "Search for another occurrence of regular expression"]
|
32500
|
2942 ["Go to Node..." Info-goto-node
|
30220
|
2943 :help "Go to a named node"]
|
32391
|
2944 ["Last" Info-last :active Info-history
|
30220
|
2945 :help "Go to the last node you were at"]
|
54754
|
2946 ["History" Info-history :active Info-history-list
|
56044
|
2947 :help "Go to menu of visited nodes"]
|
54754
|
2948 ["Table of Contents" Info-toc
|
56044
|
2949 :help "Go to table of contents"]
|
30220
|
2950 ("Index..."
|
|
2951 ["Lookup a String" Info-index
|
|
2952 :help "Look for a string in the index items"]
|
|
2953 ["Next Matching Item" Info-index-next
|
54718
|
2954 :help "Look for another occurrence of previous item"]
|
|
2955 ["Lookup a string in all indices" info-apropos
|
|
2956 :help "Look for a string in the indices of all manuals"])
|
32286
|
2957 ["Edit" Info-edit :help "Edit contents of this node"
|
|
2958 :active Info-enable-edit]
|
36092
|
2959 ["Copy Node Name" Info-copy-current-node-name
|
|
2960 :help "Copy the name of the current node into the kill ring"]
|
54754
|
2961 ["Clone Info buffer" clone-buffer
|
|
2962 :help "Create a twin copy of the current Info buffer."]
|
32391
|
2963 ["Exit" Info-exit :help "Stop reading Info"]))
|
16043
|
2964
|
32286
|
2965
|
|
2966 (defvar info-tool-bar-map
|
|
2967 (if (display-graphic-p)
|
44306
|
2968 (let ((map (make-sparse-keymap)))
|
|
2969 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
|
|
2970 (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map)
|
|
2971 (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map)
|
|
2972 (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map)
|
|
2973 (tool-bar-local-item-from-menu 'Info-last "undo" map Info-mode-map)
|
|
2974 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
|
|
2975 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
|
|
2976 (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map)
|
|
2977 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
|
|
2978 map)))
|
32286
|
2979
|
16043
|
2980 (defvar Info-menu-last-node nil)
|
|
2981 ;; Last node the menu was created for.
|
21197
|
2982 ;; Value is a list, (FILE-NAME NODE-NAME).
|
16043
|
2983
|
|
2984 (defun Info-menu-update ()
|
29621
|
2985 "Update the Info menu for the current node."
|
16043
|
2986 (condition-case nil
|
|
2987 (if (or (not (eq major-mode 'Info-mode))
|
21197
|
2988 (equal (list Info-current-file Info-current-node)
|
|
2989 Info-menu-last-node))
|
16043
|
2990 ()
|
|
2991 ;; Update menu menu.
|
|
2992 (let* ((Info-complete-menu-buffer (current-buffer))
|
|
2993 (items (nreverse (condition-case nil
|
41690
c9c839b993b9
(Info-complete-next-re, Info-complete-cache): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
2994 (Info-complete-menu-item "" nil t)
|
16043
|
2995 (error nil))))
|
28943
|
2996 entries current
|
16043
|
2997 (number 0))
|
|
2998 (while (and items (< number 9))
|
|
2999 (setq current (car items)
|
|
3000 items (cdr items)
|
|
3001 number (1+ number))
|
28943
|
3002 (setq entries (cons `[,current
|
16043
|
3003 (Info-menu ,current)
|
|
3004 :keys ,(format "%d" number)]
|
|
3005 entries)))
|
|
3006 (if items
|
|
3007 (setq entries (cons ["Other..." Info-menu t] entries)))
|
|
3008 (or entries
|
37370
|
3009 (setq entries (list ["No menu" nil nil] nil :active)))
|
30220
|
3010 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
|
16043
|
3011 ;; Update reference menu. Code stolen from `Info-follow-reference'.
|
|
3012 (let ((items nil)
|
28943
|
3013 str i entries current
|
22951
|
3014 (number 0)
|
|
3015 (case-fold-search t))
|
16043
|
3016 (save-excursion
|
|
3017 (goto-char (point-min))
|
54754
|
3018 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
|
51735
|
3019 (setq str (match-string 1))
|
16043
|
3020 (setq i 0)
|
|
3021 (while (setq i (string-match "[ \n\t]+" str i))
|
|
3022 (setq str (concat (substring str 0 i) " "
|
|
3023 (substring str (match-end 0))))
|
|
3024 (setq i (1+ i)))
|
|
3025 (setq items
|
|
3026 (cons str items))))
|
|
3027 (while (and items (< number 9))
|
|
3028 (setq current (car items)
|
|
3029 items (cdr items)
|
|
3030 number (1+ number))
|
28943
|
3031 (setq entries (cons `[,current
|
16043
|
3032 (Info-follow-reference ,current)
|
|
3033 t]
|
|
3034 entries)))
|
|
3035 (if items
|
|
3036 (setq entries (cons ["Other..." Info-follow-reference t]
|
|
3037 entries)))
|
|
3038 (or entries
|
37370
|
3039 (setq entries (list ["No references" nil nil] nil :active)))
|
16043
|
3040 (easy-menu-change '("Info") "Reference" (nreverse entries)))
|
|
3041 ;; Update last seen node.
|
21197
|
3042 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
|
16043
|
3043 ;; Try to avoid entering infinite beep mode in case of errors.
|
|
3044 (error (ding))))
|
|
3045
|
325
|
3046
|
55774
|
3047 (defun Info-copy-current-node-name (&optional arg)
|
36092
|
3048 "Put the name of the current info node into the kill ring.
|
55774
|
3049 The name of the info file is prepended to the node name in parentheses.
|
|
3050 With a zero prefix arg, put the name inside a function call to `info'."
|
|
3051 (interactive "P")
|
36092
|
3052 (unless Info-current-node
|
|
3053 (error "No current info node"))
|
55774
|
3054 (let ((node (concat "(" (file-name-nondirectory
|
|
3055 (or (and (stringp Info-current-file)
|
|
3056 Info-current-file)
|
|
3057 buffer-file-name
|
|
3058 ""))
|
|
3059 ")" Info-current-node)))
|
|
3060 (if (zerop (prefix-numeric-value arg))
|
|
3061 (setq node (concat "(info \"" node "\")")))
|
|
3062 (kill-new node)
|
|
3063 (message "%s" node)))
|
36092
|
3064
|
|
3065
|
325
|
3066 ;; 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
|
3067 (put 'Info-mode 'mode-class 'special)
|
40967
|
3068 (put 'Info-mode 'no-clone-indirect t)
|
325
|
3069
|
|
3070 (defun Info-mode ()
|
29621
|
3071 "Info mode provides commands for browsing through the Info documentation tree.
|
325
|
3072 Documentation in Info is divided into \"nodes\", each of which discusses
|
|
3073 one topic and contains references to other nodes which discuss related
|
|
3074 topics. Info has commands to follow the references and show you other nodes.
|
|
3075
|
29621
|
3076 \\<Info-mode-map>\
|
325
|
3077 \\[Info-help] Invoke the Info tutorial.
|
21806
|
3078 \\[Info-exit] Quit Info: reselect previously selected buffer.
|
325
|
3079
|
|
3080 Selecting other nodes:
|
8564
|
3081 \\[Info-mouse-follow-nearest-node]
|
|
3082 Follow a node reference you click on.
|
|
3083 This works with menu items, cross references, and
|
|
3084 the \"next\", \"previous\" and \"up\", depending on where you click.
|
21806
|
3085 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
|
325
|
3086 \\[Info-next] Move to the \"next\" node of this node.
|
3127
|
3087 \\[Info-prev] Move to the \"previous\" node of this node.
|
325
|
3088 \\[Info-up] Move \"up\" from this node.
|
|
3089 \\[Info-menu] Pick menu item specified by name (or abbreviation).
|
42406
|
3090 Picking a menu item causes another node to be selected.
|
540
|
3091 \\[Info-directory] Go to the Info directory node.
|
325
|
3092 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
|
|
3093 \\[Info-last] Move to the last node you were at.
|
56044
|
3094 \\[Info-history] Go to menu of visited nodes.
|
|
3095 \\[Info-toc] Go to table of contents of the current Info file.
|
21806
|
3096 \\[Info-top-node] Go to the Top node of this file.
|
|
3097 \\[Info-final-node] Go to the final node in this file.
|
|
3098 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
|
|
3099 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
|
56044
|
3100 \\[Info-index] Look up a topic in this file's Index and move to that node.
|
|
3101 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
|
|
3102 \\[info-apropos] Look for a string in the indices of all manuals.
|
325
|
3103
|
|
3104 Moving within a node:
|
20514
|
3105 \\[Info-scroll-up] Normally, scroll forward a full screen.
|
42406
|
3106 Once you scroll far enough in a node that its menu appears on the
|
|
3107 screen but after point, the next scroll moves into its first
|
|
3108 subnode. When after all menu items (or if there is no menu),
|
|
3109 move up to the parent node.
|
20514
|
3110 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
|
42406
|
3111 already visible, try to go to the previous menu entry, or up
|
|
3112 if there is none.
|
28943
|
3113 \\[beginning-of-buffer] Go to beginning of node.
|
325
|
3114
|
|
3115 Advanced commands:
|
51491
0f2773d31797
(Info-mode): Mention `c' and remove duplicate mention of `q' in
Luc Teirlinck <teirllm@auburn.edu>
diff
changeset
|
3116 \\[Info-copy-current-node-name] Put name of current info node in the kill ring.
|
54754
|
3117 \\[clone-buffer] Select a new cloned Info buffer in another window.
|
325
|
3118 \\[Info-edit] Edit contents of selected node.
|
56044
|
3119 1 .. 9 Pick first ... ninth item in node's menu.
|
|
3120 Every third `*' is highlighted to help pick the right number.
|
325
|
3121 \\[Info-goto-node] Move to node specified by name.
|
42406
|
3122 You may include a filename as well, as (FILENAME)NODENAME.
|
4410
|
3123 \\[universal-argument] \\[info] Move to new Info file with completion.
|
56044
|
3124 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>.
|
325
|
3125 \\[Info-search] Search through this Info file for specified regexp,
|
42406
|
3126 and select the node in which the next occurrence is found.
|
56044
|
3127 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
|
54754
|
3128 \\[Info-search-next] Search for another occurrence of regexp
|
55074
|
3129 from a previous \\<Info-mode-map>\\[Info-search] command.
|
4410
|
3130 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
|
|
3131 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
|
325
|
3132 (kill-all-local-variables)
|
|
3133 (setq major-mode 'Info-mode)
|
|
3134 (setq mode-name "Info")
|
16672
|
3135 (setq tab-width 8)
|
325
|
3136 (use-local-map Info-mode-map)
|
16043
|
3137 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
|
325
|
3138 (set-syntax-table text-mode-syntax-table)
|
|
3139 (setq local-abbrev-table text-mode-abbrev-table)
|
|
3140 (setq case-fold-search t)
|
|
3141 (setq buffer-read-only t)
|
|
3142 (make-local-variable 'Info-current-file)
|
|
3143 (make-local-variable 'Info-current-subfile)
|
|
3144 (make-local-variable 'Info-current-node)
|
|
3145 (make-local-variable 'Info-tag-table-marker)
|
16981
|
3146 (setq Info-tag-table-marker (make-marker))
|
|
3147 (make-local-variable 'Info-tag-table-buffer)
|
|
3148 (setq Info-tag-table-buffer nil)
|
325
|
3149 (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
|
3150 (make-local-variable 'Info-index-alternatives)
|
51434
|
3151 (setq header-line-format
|
|
3152 (if Info-use-header-line
|
52767
|
3153 '(:eval (get-text-property (point-min) 'header-line))
|
51434
|
3154 nil)) ; so the header line isn't displayed
|
32286
|
3155 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
|
19043
|
3156 ;; This is for the sake of the invisible text we use handling titles.
|
|
3157 (make-local-variable 'line-move-ignore-invisible)
|
|
3158 (setq line-move-ignore-invisible t)
|
55153
|
3159 (make-local-variable 'desktop-save-buffer)
|
|
3160 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
|
33189
|
3161 (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
|
3162 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
|
56866
|
3163 (set (make-local-variable 'isearch-search-fun-function)
|
|
3164 'Info-isearch-search)
|
|
3165 (set (make-local-variable 'isearch-wrap-function)
|
|
3166 'Info-isearch-wrap)
|
|
3167 (set (make-local-variable 'isearch-push-state-function)
|
|
3168 'Info-isearch-push-state)
|
|
3169 (set (make-local-variable 'search-whitespace-regexp)
|
|
3170 Info-search-whitespace-regexp)
|
325
|
3171 (Info-set-mode-line)
|
|
3172 (run-hooks 'Info-mode-hook))
|
|
3173
|
26004
|
3174 (defun Info-clone-buffer-hook ()
|
|
3175 (when (bufferp Info-tag-table-buffer)
|
|
3176 (setq Info-tag-table-buffer
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
3177 (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
|
3178 (let ((m Info-tag-table-marker))
|
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
3179 (when (markerp m)
|
38225
|
3180 (setq Info-tag-table-marker
|
38262
03f0515fe575
(Info-clone-buffer-hook): Really unconditionally copy marker.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
3181 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
|
38225
|
3182 (with-current-buffer Info-tag-table-buffer
|
|
3183 (copy-marker (marker-position m)))
|
|
3184 (make-marker))))))
|
26004
|
3185
|
32286
|
3186 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
|
|
3187 (set-keymap-parent map text-mode-map)
|
|
3188 (define-key map "\C-c\C-c" 'Info-cease-edit)
|
|
3189 map)
|
325
|
3190 "Local keymap used within `e' command of Info.")
|
|
3191
|
|
3192 ;; 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
|
3193 (put 'Info-edit-mode 'mode-class 'special)
|
325
|
3194
|
|
3195 (defun Info-edit-mode ()
|
|
3196 "Major mode for editing the contents of an Info node.
|
1477
|
3197 Like text mode with the addition of `Info-cease-edit'
|
325
|
3198 which returns to Info mode for browsing.
|
|
3199 \\{Info-edit-map}"
|
8805
|
3200 (use-local-map Info-edit-map)
|
|
3201 (setq major-mode 'Info-edit-mode)
|
|
3202 (setq mode-name "Info Edit")
|
|
3203 (kill-local-variable 'mode-line-buffer-identification)
|
|
3204 (setq buffer-read-only nil)
|
11580
|
3205 (force-mode-line-update)
|
8805
|
3206 (buffer-enable-undo (current-buffer))
|
|
3207 (run-hooks 'Info-edit-mode-hook))
|
325
|
3208
|
|
3209 (defun Info-edit ()
|
|
3210 "Edit the contents of this Info node.
|
|
3211 Allowed only if variable `Info-enable-edit' is non-nil."
|
|
3212 (interactive)
|
|
3213 (or Info-enable-edit
|
|
3214 (error "Editing info nodes is not enabled"))
|
8805
|
3215 (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
|
3216 (message "%s" (substitute-command-keys
|
29446
|
3217 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
|
325
|
3218
|
|
3219 (defun Info-cease-edit ()
|
|
3220 "Finish editing Info node; switch back to Info proper."
|
|
3221 (interactive)
|
|
3222 ;; Do this first, so nothing has changed if user C-g's at query.
|
|
3223 (and (buffer-modified-p)
|
|
3224 (y-or-n-p "Save the file? ")
|
|
3225 (save-buffer))
|
|
3226 (use-local-map Info-mode-map)
|
|
3227 (setq major-mode 'Info-mode)
|
|
3228 (setq mode-name "Info")
|
|
3229 (Info-set-mode-line)
|
|
3230 (setq buffer-read-only t)
|
11580
|
3231 (force-mode-line-update)
|
325
|
3232 (and (marker-position Info-tag-table-marker)
|
|
3233 (buffer-modified-p)
|
|
3234 (message "Tags may have changed. Use Info-tagify if necessary")))
|
359
|
3235
|
12889
|
3236 (defvar Info-file-list-for-emacs
|
57770
|
3237 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
|
39364
|
3238 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
|
|
3239 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
|
|
3240 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
|
30738
|
3241 ("skeleton" . "autotype") ("auto-insert" . "autotype")
|
|
3242 ("copyright" . "autotype") ("executable" . "autotype")
|
|
3243 ("time-stamp" . "autotype") ("quickurl" . "autotype")
|
|
3244 ("tempo" . "autotype") ("hippie-expand" . "autotype")
|
40845
|
3245 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
|
|
3246 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
|
39364
|
3247 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
|
|
3248 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
|
|
3249 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
|
|
3250 ("rfc2045" . "emacs-mime")
|
|
3251 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
|
|
3252 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
|
|
3253 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
|
|
3254 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
|
|
3255 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
|
|
3256 ("mml" . "emacs-mime"))
|
12889
|
3257 "List of Info files that describe Emacs commands.
|
|
3258 An element can be a file name, or a list of the form (PREFIX . FILE)
|
|
3259 where PREFIX is a name prefix and FILE is the file to look in.
|
|
3260 If the element is just a file name, the file name also serves as the prefix.")
|
|
3261
|
359
|
3262 (defun Info-find-emacs-command-nodes (command)
|
12889
|
3263 "Return a list of locations documenting COMMAND.
|
12892
|
3264 The `info-file' property of COMMAND says which Info manual to search.
|
|
3265 If COMMAND has no property, the variable `Info-file-list-for-emacs'
|
|
3266 defines heuristics for which Info manual to try.
|
29621
|
3267 The locations are of the format used in `Info-history', i.e.
|
57770
|
3268 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
|
|
3269 in the first element of the returned list (which is treated specially in
|
|
3270 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
|
|
3271 (let ((where '()) line-number
|
21641
|
3272 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
|
57672
d8b07169ce26
(Info-find-emacs-command-nodes): Adapt to Texinfo-4.7 style indexes.
Luc Teirlinck <teirllm@auburn.edu>
diff
changeset
|
3273 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
|
57770
|
3274 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
|
12889
|
3275 (info-file "emacs")) ;default
|
|
3276 ;; Determine which info file this command is documented in.
|
|
3277 (if (get command 'info-file)
|
|
3278 (setq info-file (get command 'info-file))
|
|
3279 ;; If it doesn't say explicitly, test its name against
|
|
3280 ;; various prefixes that we know.
|
|
3281 (let ((file-list Info-file-list-for-emacs))
|
|
3282 (while file-list
|
|
3283 (let* ((elt (car file-list))
|
|
3284 (name (if (consp elt)
|
|
3285 (car elt)
|
|
3286 elt))
|
|
3287 (file (if (consp elt) (cdr elt) elt))
|
57468
|
3288 (case-fold-search nil)
|
12892
|
3289 (regexp (concat "\\`" (regexp-quote name)
|
12889
|
3290 "\\(\\'\\|-\\)")))
|
|
3291 (if (string-match regexp (symbol-name command))
|
|
3292 (setq info-file file file-list nil))
|
|
3293 (setq file-list (cdr file-list))))))
|
30763
|
3294 (Info-find-node info-file "Top")
|
|
3295 (or (and (search-forward "\n* menu:" nil t)
|
|
3296 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
|
|
3297 (error "Info file `%s' appears to lack an index" info-file))
|
|
3298 (goto-char (match-beginning 1))
|
|
3299 ;; Bind Info-history to nil, to prevent the index nodes from
|
|
3300 ;; getting into the node history.
|
|
3301 (let ((Info-history nil)
|
55751
|
3302 (Info-history-list nil)
|
|
3303 node (nodes (Info-index-nodes)))
|
|
3304 (Info-goto-node (car nodes))
|
30763
|
3305 (while
|
|
3306 (progn
|
|
3307 (goto-char (point-min))
|
|
3308 (while (re-search-forward cmd-desc nil t)
|
|
3309 (setq where
|
|
3310 (cons (list Info-current-file
|
|
3311 (match-string-no-properties 2)
|
29446
|
3312 0)
|
57770
|
3313 where))
|
|
3314 (setq line-number (and (match-beginning 3)
|
|
3315 (string-to-number (match-string 3)))))
|
55751
|
3316 (and (setq nodes (cdr nodes) node (car nodes))))
|
30763
|
3317 (Info-goto-node node)))
|
57770
|
3318 (if (and line-number where)
|
|
3319 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
|
|
3320 (cdr where))
|
|
3321 where)))
|
359
|
3322
|
57770
|
3323 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
|
359
|
3324 ;;;###autoload
|
|
3325 (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
|
3326 "Go to the Info node in the Emacs manual for command COMMAND.
|
35112
|
3327 The command is found by looking up in Emacs manual's indices
|
12892
|
3328 or in another manual found via COMMAND's `info-file' property or
|
53246
|
3329 the variable `Info-file-list-for-emacs'.
|
|
3330 COMMAND must be a symbol or string."
|
359
|
3331 (interactive "CFind documentation for command: ")
|
50454
|
3332 ;; If command is given as a string, convert it to a symbol.
|
|
3333 (if (stringp command)
|
53246
|
3334 (setq command (intern command)))
|
359
|
3335 (or (commandp command)
|
|
3336 (signal 'wrong-type-argument (list 'commandp command)))
|
|
3337 (let ((where (Info-find-emacs-command-nodes command)))
|
|
3338 (if where
|
|
3339 (let ((num-matches (length where)))
|
|
3340 ;; Get Info running, and pop to it in another window.
|
|
3341 (save-window-excursion
|
|
3342 (info))
|
55074
|
3343 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
|
30763
|
3344 ;; Bind Info-history to nil, to prevent the last Index node
|
|
3345 ;; visited by Info-find-emacs-command-nodes from being
|
|
3346 ;; pushed onto the history.
|
57770
|
3347 (let ((Info-history nil) (Info-history-list nil)
|
|
3348 (line-number (nth 2 (car where))))
|
|
3349 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
|
|
3350 (if (and (integerp line-number) (> line-number 0))
|
|
3351 (forward-line (1- line-number))))
|
359
|
3352 (if (> num-matches 1)
|
|
3353 (progn
|
30763
|
3354 ;; (car where) will be pushed onto Info-history
|
|
3355 ;; when/if they go to another node. Put the other
|
|
3356 ;; nodes that were found on the history.
|
359
|
3357 (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
|
3358 (message "Found %d other entr%s. Use %s to see %s."
|
6049
|
3359 (1- num-matches)
|
|
3360 (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
|
3361 (substitute-command-keys "\\[Info-last]")
|
6049
|
3362 (if (> num-matches 2) "them" "it")))))
|
14355
|
3363 (error "Couldn't find documentation for %s" command))))
|
359
|
3364
|
57770
|
3365 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
|
359
|
3366 ;;;###autoload
|
|
3367 (defun Info-goto-emacs-key-command-node (key)
|
35112
|
3368 "Go to the node in the Emacs manual which describes the command bound to KEY.
|
|
3369 KEY is a string.
|
29621
|
3370 Interactively, if the binding is `execute-extended-command', a command is read.
|
35112
|
3371 The command is found by looking up in Emacs manual's indices
|
12892
|
3372 or in another manual found via COMMAND's `info-file' property or
|
|
3373 the variable `Info-file-list-for-emacs'."
|
30423
|
3374 (interactive "kFind documentation for key: ")
|
359
|
3375 (let ((command (key-binding key)))
|
|
3376 (cond ((null command)
|
1484
|
3377 (message "%s is undefined" (key-description key)))
|
359
|
3378 ((and (interactive-p)
|
|
3379 (eq command 'execute-extended-command))
|
|
3380 (Info-goto-emacs-command-node
|
|
3381 (read-command "Find documentation for command: ")))
|
|
3382 (t
|
|
3383 (Info-goto-emacs-command-node command)))))
|
4410
|
3384
|
27536
|
3385 (defface Info-title-1-face
|
55061
|
3386 '((((type tty pc) (class color)) :foreground "yellow" :weight bold)
|
|
3387 (t :height 1.2 :inherit Info-title-2-face))
|
27536
|
3388 "Face for Info titles at level 1."
|
|
3389 :group 'info)
|
|
3390
|
|
3391 (defface Info-title-2-face
|
55061
|
3392 '((((type tty pc) (class color)) :foreground "lightblue" :weight bold)
|
|
3393 (t :height 1.2 :inherit Info-title-3-face))
|
27536
|
3394 "Face for Info titles at level 2."
|
|
3395 :group 'info)
|
|
3396
|
|
3397 (defface Info-title-3-face
|
55061
|
3398 '((((type tty pc) (class color)) :weight bold)
|
|
3399 (t :height 1.2 :inherit Info-title-4-face))
|
27536
|
3400 "Face for Info titles at level 3."
|
|
3401 :group 'info)
|
|
3402
|
32678
|
3403 (defface Info-title-4-face
|
55061
|
3404 '((((type tty pc) (class color)) :weight bold)
|
|
3405 (t :weight bold :inherit variable-pitch))
|
32678
|
3406 "Face for Info titles at level 4."
|
|
3407 :group 'info)
|
|
3408
|
33136
|
3409 (defface info-menu-header
|
|
3410 '((((type tty pc))
|
33208
|
3411 :underline t
|
|
3412 :weight bold)
|
33136
|
3413 (t
|
33208
|
3414 :inherit variable-pitch
|
|
3415 :weight bold))
|
33136
|
3416 "Face for headers in Info menus."
|
|
3417 :group 'info)
|
|
3418
|
52767
|
3419 (defun Info-escape-percent (string)
|
|
3420 "Double all occurrences of `%' in STRING.
|
|
3421
|
|
3422 Return a new string with all `%' characters replaced by `%%'.
|
|
3423 Preserve text properties."
|
|
3424 (let ((start 0)
|
|
3425 (end (length string))
|
|
3426 mb me m matches)
|
|
3427 (save-match-data
|
|
3428 (while (and (< start end) (string-match "%" string start))
|
|
3429 (setq mb (match-beginning 0)
|
|
3430 me (1+ mb)
|
|
3431 m (substring string mb me)
|
53246
|
3432 matches (cons m
|
|
3433 (cons m
|
|
3434 (cons (substring string start mb)
|
52767
|
3435 matches)))
|
|
3436 start me))
|
|
3437 (push (substring string start end) matches)
|
|
3438 (apply #'concat (nreverse matches)))))
|
|
3439
|
45784
|
3440 (defvar Info-next-link-keymap
|
|
3441 (let ((keymap (make-sparse-keymap)))
|
|
3442 (define-key keymap [header-line mouse-1] 'Info-next)
|
|
3443 (define-key keymap [header-line mouse-2] 'Info-next)
|
|
3444 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
3445 (define-key keymap [mouse-2] 'Info-next)
|
|
3446 keymap)
|
|
3447 "Keymap to put on the Next link in the text or the header line.")
|
|
3448
|
|
3449 (defvar Info-prev-link-keymap
|
|
3450 (let ((keymap (make-sparse-keymap)))
|
|
3451 (define-key keymap [header-line mouse-1] 'Info-prev)
|
|
3452 (define-key keymap [header-line mouse-2] 'Info-prev)
|
|
3453 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
3454 (define-key keymap [mouse-2] 'Info-prev)
|
|
3455 keymap)
|
|
3456 "Keymap to put on the Prev link in the text or the header line.")
|
|
3457
|
|
3458
|
|
3459 (defvar Info-up-link-keymap
|
|
3460 (let ((keymap (make-sparse-keymap)))
|
|
3461 (define-key keymap [header-line mouse-1] 'Info-up)
|
|
3462 (define-key keymap [header-line mouse-2] 'Info-up)
|
|
3463 (define-key keymap [header-line down-mouse-1] 'ignore)
|
|
3464 (define-key keymap [mouse-2] 'Info-up)
|
|
3465 keymap)
|
|
3466 "Keymap to put on the Up link in the text or the header line.")
|
|
3467
|
4410
|
3468 (defun Info-fontify-node ()
|
54754
|
3469 "Fontify the node."
|
|
3470 (save-excursion
|
|
3471 (let* ((inhibit-read-only t)
|
|
3472 (case-fold-search t)
|
|
3473 paragraph-markers
|
|
3474 (not-fontified-p ; the node hasn't already been fontified
|
|
3475 (not (let ((where (next-property-change (point-min))))
|
|
3476 (and where (not (= where (point-max)))))))
|
|
3477 (fontify-visited-p ; visited nodes need to be re-fontified
|
|
3478 (and Info-fontify-visited-nodes
|
|
3479 ;; Don't take time to refontify visited nodes in huge nodes
|
57567
|
3480 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
|
|
3481 rbeg rend)
|
54754
|
3482
|
|
3483 ;; Fontify header line
|
|
3484 (goto-char (point-min))
|
|
3485 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
|
|
3486 (goto-char (match-end 0))
|
|
3487 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
|
|
3488 (goto-char (match-end 0))
|
|
3489 (let* ((nbeg (match-beginning 2))
|
|
3490 (nend (match-end 2))
|
|
3491 (tbeg (match-beginning 1))
|
|
3492 (tag (match-string 1)))
|
|
3493 (if (string-equal tag "Node")
|
|
3494 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
|
|
3495 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
|
|
3496 (put-text-property tbeg nend 'mouse-face 'highlight)
|
|
3497 (put-text-property tbeg nend
|
|
3498 'help-echo
|
|
3499 (concat "Go to node "
|
|
3500 (buffer-substring nbeg nend)))
|
|
3501 ;; Always set up the text property keymap.
|
|
3502 ;; It will either be used in the buffer
|
|
3503 ;; or copied in the header line.
|
|
3504 (put-text-property tbeg nend 'keymap
|
|
3505 (cond
|
|
3506 ((equal tag "Prev") Info-prev-link-keymap)
|
|
3507 ((equal tag "Next") Info-next-link-keymap)
|
|
3508 ((equal tag "Up") Info-up-link-keymap))))))
|
|
3509 (when Info-use-header-line
|
|
3510 (goto-char (point-min))
|
|
3511 (let ((header-end (line-end-position))
|
|
3512 header)
|
|
3513 ;; If we find neither Next: nor Prev: link, show the entire
|
|
3514 ;; node header. Otherwise, don't show the File: and Node:
|
|
3515 ;; parts, to avoid wasting precious space on information that
|
|
3516 ;; is available in the mode line.
|
|
3517 (if (re-search-forward
|
|
3518 "\\(next\\|up\\|prev[ious]*\\): "
|
|
3519 header-end t)
|
|
3520 (progn
|
|
3521 (goto-char (match-beginning 1))
|
|
3522 (setq header (buffer-substring (point) header-end)))
|
|
3523 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*" header-end t)
|
|
3524 (setq header
|
|
3525 (concat "No next, prev or up links -- "
|
|
3526 (buffer-substring (point) header-end)))
|
|
3527 (setq header (buffer-substring (point) header-end))))
|
|
3528 (put-text-property (point-min) (1+ (point-min))
|
|
3529 'header-line (Info-escape-percent header))
|
|
3530 ;; Hide the part of the first line
|
|
3531 ;; that is in the header, if it is just part.
|
|
3532 (unless (bobp)
|
|
3533 ;; Hide the punctuation at the end, too.
|
|
3534 (skip-chars-backward " \t,")
|
|
3535 (put-text-property (point) header-end 'invisible t)))))
|
|
3536
|
|
3537 ;; Fontify titles
|
|
3538 (goto-char (point-min))
|
|
3539 (when not-fontified-p
|
|
3540 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
|
|
3541 nil t)
|
|
3542 (let* ((c (preceding-char))
|
|
3543 (face
|
|
3544 (cond ((= c ?*) 'Info-title-1-face)
|
|
3545 ((= c ?=) 'Info-title-2-face)
|
|
3546 ((= c ?-) 'Info-title-3-face)
|
|
3547 (t 'Info-title-4-face))))
|
|
3548 (put-text-property (match-beginning 1) (match-end 1)
|
|
3549 'font-lock-face face))
|
|
3550 ;; This is a serious problem for trying to handle multiple
|
|
3551 ;; frame types at once. We want this text to be invisible
|
|
3552 ;; on frames that can display the font above.
|
|
3553 (when (memq (framep (selected-frame)) '(x pc w32 mac))
|
|
3554 (add-text-properties (1- (match-beginning 2)) (match-end 2)
|
|
3555 '(invisible t front-sticky nil rear-nonsticky t)))))
|
49424
|
3556
|
54754
|
3557 ;; Fontify cross references
|
|
3558 (goto-char (point-min))
|
|
3559 (when (or not-fontified-p fontify-visited-p)
|
|
3560 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
|
|
3561 (let ((start (match-beginning 0))
|
|
3562 (next (point))
|
|
3563 other-tag)
|
|
3564 (when not-fontified-p
|
|
3565 (when Info-hide-note-references
|
56882
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3566 (when (not (eq Info-hide-note-references 'hide))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3567 ;; *Note is often used where *note should have been
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3568 (goto-char start)
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3569 (skip-syntax-backward " ")
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3570 (setq other-tag
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3571 (cond ((memq (char-before) '(nil ?\. ?! ??))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3572 "See ")
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3573 ((memq (char-before) '(?\, ?\; ?\: ?-))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3574 "see ")
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3575 ((memq (char-before) '(?\( ?\[ ?\{))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3576 ;; Check whether the paren is preceded by
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3577 ;; an end of sentence
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3578 (skip-syntax-backward " (")
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3579 (if (memq (char-before) '(nil ?\. ?! ??))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3580 "See "
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3581 "see "))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3582 ((save-match-data (looking-at "\n\n"))
|
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3583 "See "))))
|
54754
|
3584 (goto-char next)
|
|
3585 (add-text-properties
|
|
3586 (match-beginning 1)
|
|
3587 (or (save-match-data
|
|
3588 ;; Don't hide \n after *Note
|
|
3589 (let ((start1 (match-beginning 1)))
|
|
3590 (if (string-match "\n" (match-string 1))
|
|
3591 (+ start1 (match-beginning 0)))))
|
|
3592 (match-end 1))
|
56882
dca3dbca04cc
(Info-fontify-node): Don't compute other-tag if Info-hide-note-references=hide.
Juri Linkov <juri@jurta.org>
diff
changeset
|
3593 (if other-tag
|
54754
|
3594 `(display ,other-tag front-sticky nil rear-nonsticky t)
|
|
3595 '(invisible t front-sticky nil rear-nonsticky t))))
|
|
3596 (add-text-properties
|
|
3597 (match-beginning 2) (match-end 2)
|
|
3598 (list
|
|
3599 'help-echo (if (or (match-end 5)
|
|
3600 (not (equal (match-string 4) "")))
|
|
3601 (concat "mouse-2: go to " (or (match-string 5)
|
|
3602 (match-string 4)))
|
|
3603 "mouse-2: go to this node")
|
|
3604 'mouse-face 'highlight)))
|
|
3605 (when (or not-fontified-p fontify-visited-p)
|
57567
|
3606 (setq rbeg (match-beginning 2)
|
|
3607 rend (match-end 2))
|
|
3608 (put-text-property
|
|
3609 rbeg rend
|
|
3610 'font-lock-face
|
|
3611 ;; Display visited nodes in a different face
|
|
3612 (if (and Info-fontify-visited-nodes
|
|
3613 (save-match-data
|
|
3614 (let* ((node (replace-regexp-in-string
|
|
3615 "^[ \t]+" ""
|
|
3616 (replace-regexp-in-string
|
|
3617 "[ \t\n]+" " "
|
|
3618 (or (match-string 5)
|
|
3619 (and (not (equal (match-string 4) ""))
|
|
3620 (match-string 4))
|
|
3621 (match-string 2)))))
|
|
3622 (file (file-name-nondirectory
|
|
3623 Info-current-file))
|
|
3624 (hl Info-history-list)
|
|
3625 res)
|
|
3626 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
|
|
3627 (setq file (file-name-nondirectory
|
|
3628 (match-string 1 node))
|
|
3629 node (if (equal (match-string 2 node) "")
|
|
3630 "Top"
|
|
3631 (match-string 2 node))))
|
|
3632 (while hl
|
|
3633 (if (and (string-equal node (nth 1 (car hl)))
|
|
3634 (string-equal file
|
|
3635 (file-name-nondirectory
|
|
3636 (nth 0 (car hl)))))
|
|
3637 (setq res (car hl) hl nil)
|
|
3638 (setq hl (cdr hl))))
|
|
3639 res))) 'info-xref-visited 'info-xref))
|
|
3640 ;; For multiline ref, unfontify newline and surrounding whitespace
|
|
3641 (save-excursion
|
|
3642 (goto-char rbeg)
|
|
3643 (save-match-data
|
|
3644 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
|
|
3645 (remove-text-properties (match-beginning 0)
|
|
3646 (match-end 0)
|
|
3647 '(font-lock-face t))))))
|
54754
|
3648 (when not-fontified-p
|
|
3649 (when (memq Info-hide-note-references '(t hide))
|
|
3650 (add-text-properties (match-beginning 3) (match-end 3)
|
|
3651 '(invisible t front-sticky nil rear-nonsticky t))
|
|
3652 ;; Unhide the file name of the external reference in parens
|
55074
|
3653 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
|
54754
|
3654 (remove-text-properties (match-beginning 6) (match-end 6)
|
|
3655 '(invisible t front-sticky nil rear-nonsticky t)))
|
|
3656 ;; Unhide newline because hidden newlines cause too long lines
|
|
3657 (save-match-data
|
55074
|
3658 (let ((beg3 (match-beginning 3))
|
|
3659 (end3 (match-end 3)))
|
|
3660 (if (and (string-match "\n[ \t]*" (match-string 3))
|
|
3661 (not (save-match-data
|
|
3662 (save-excursion
|
|
3663 (goto-char (1+ end3))
|
|
3664 (looking-at "[.)]*$")))))
|
|
3665 (remove-text-properties (+ beg3 (match-beginning 0))
|
|
3666 (+ beg3 (match-end 0))
|
54754
|
3667 '(invisible t front-sticky nil rear-nonsticky t))))))
|
|
3668 (when (and Info-refill-paragraphs Info-hide-note-references)
|
|
3669 (push (set-marker (make-marker) start)
|
|
3670 paragraph-markers))))))
|
48287
|
3671
|
54754
|
3672 ;; Refill paragraphs (experimental feature)
|
|
3673 (when (and not-fontified-p
|
|
3674 Info-refill-paragraphs
|
|
3675 paragraph-markers)
|
|
3676 (let ((fill-nobreak-invisible t)
|
|
3677 (fill-individual-varying-indent nil)
|
|
3678 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
|
|
3679 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
|
|
3680 (adaptive-fill-mode nil))
|
|
3681 (goto-char (point-max))
|
|
3682 (while paragraph-markers
|
|
3683 (let ((m (car paragraph-markers)))
|
|
3684 (setq paragraph-markers (cdr paragraph-markers))
|
|
3685 (when (< m (point))
|
|
3686 (goto-char m)
|
|
3687 (beginning-of-line)
|
|
3688 (let ((beg (point)))
|
|
3689 (when (zerop (forward-paragraph))
|
|
3690 (fill-individual-paragraphs beg (point) nil nil)
|
|
3691 (goto-char beg))))
|
|
3692 (set-marker m nil)))))
|
48103
|
3693
|
54754
|
3694 ;; Fontify menu items
|
|
3695 (goto-char (point-min))
|
|
3696 (when (and (or not-fontified-p fontify-visited-p)
|
|
3697 (search-forward "\n* Menu:" nil t)
|
55751
|
3698 (not (Info-index-node))
|
54754
|
3699 ;; Don't take time to annotate huge menus
|
|
3700 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
|
|
3701 (let ((n 0)
|
|
3702 cont)
|
|
3703 (while (re-search-forward
|
|
3704 (concat "^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
|
|
3705 Info-node-spec-re "\\([ \t]*\\)\\)")
|
|
3706 nil t)
|
|
3707 (when not-fontified-p
|
|
3708 (setq n (1+ n))
|
|
3709 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
|
|
3710 (put-text-property (match-beginning 0)
|
|
3711 (1+ (match-beginning 0))
|
|
3712 'font-lock-face 'info-menu-5)))
|
|
3713 (when not-fontified-p
|
|
3714 (add-text-properties
|
|
3715 (match-beginning 1) (match-end 1)
|
|
3716 (list
|
|
3717 'help-echo (if (match-end 3)
|
|
3718 (concat "mouse-2: go to " (match-string 3))
|
|
3719 "mouse-2: go to this node")
|
|
3720 'mouse-face 'highlight)))
|
|
3721 (when (or not-fontified-p fontify-visited-p)
|
|
3722 (add-text-properties
|
|
3723 (match-beginning 1) (match-end 1)
|
|
3724 (list
|
|
3725 'font-lock-face
|
|
3726 ;; Display visited menu items in a different face
|
|
3727 (if (and Info-fontify-visited-nodes
|
|
3728 (save-match-data
|
|
3729 (let ((node (if (equal (match-string 3) "")
|
|
3730 (match-string 1)
|
|
3731 (match-string 3)))
|
|
3732 (file (file-name-nondirectory Info-current-file))
|
|
3733 (hl Info-history-list)
|
|
3734 res)
|
|
3735 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
|
55174
|
3736 (setq file (file-name-nondirectory
|
|
3737 (match-string 1 node))
|
54754
|
3738 node (if (equal (match-string 2 node) "")
|
|
3739 "Top"
|
|
3740 (match-string 2 node))))
|
|
3741 (while hl
|
|
3742 (if (and (string-equal node (nth 1 (car hl)))
|
|
3743 (string-equal file
|
|
3744 (file-name-nondirectory
|
|
3745 (nth 0 (car hl)))))
|
|
3746 (setq res (car hl) hl nil)
|
|
3747 (setq hl (cdr hl))))
|
|
3748 res))) 'info-xref-visited 'info-xref))))
|
|
3749 (when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
|
|
3750 (put-text-property (match-beginning 2) (1- (match-end 6))
|
|
3751 'invisible t)
|
|
3752 ;; Unhide the file name in parens
|
|
3753 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
|
|
3754 (remove-text-properties (match-beginning 4) (match-end 4)
|
|
3755 '(invisible t)))
|
|
3756 ;; We need a stretchable space like :align-to but with
|
|
3757 ;; a minimum value.
|
|
3758 (put-text-property (1- (match-end 6)) (match-end 6) 'display
|
|
3759 (if (>= 22 (- (match-end 1)
|
|
3760 (match-beginning 0)))
|
|
3761 '(space :align-to 24)
|
|
3762 '(space :width 2)))
|
|
3763 (setq cont (looking-at "."))
|
|
3764 (while (and (= (forward-line 1) 0)
|
|
3765 (looking-at "\\([ \t]+\\)[^*\n]"))
|
|
3766 (put-text-property (match-beginning 1) (1- (match-end 1))
|
|
3767 'invisible t)
|
|
3768 (put-text-property (1- (match-end 1)) (match-end 1)
|
|
3769 'display
|
|
3770 (if cont
|
|
3771 '(space :align-to 26)
|
|
3772 '(space :align-to 24)))
|
|
3773 (setq cont t))))))
|
48103
|
3774
|
54754
|
3775 ;; Fontify menu headers
|
|
3776 ;; Add the face `info-menu-header' to any header before a menu entry
|
|
3777 (goto-char (point-min))
|
|
3778 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
|
|
3779 (put-text-property (match-beginning 0) (match-end 0)
|
|
3780 'font-lock-face 'info-menu-header)
|
|
3781 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
|
|
3782 (put-text-property (match-beginning 1) (match-end 1)
|
|
3783 'font-lock-face 'info-menu-header)))
|
|
3784
|
55174
|
3785 ;; Hide index line numbers
|
|
3786 (goto-char (point-min))
|
55751
|
3787 (when (and not-fontified-p (Info-index-node))
|
55174
|
3788 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
|
|
3789 (put-text-property (match-beginning 0) (match-end 0)
|
|
3790 'invisible t)))
|
|
3791
|
54754
|
3792 ;; Fontify http and ftp references
|
|
3793 (goto-char (point-min))
|
|
3794 (when not-fontified-p
|
|
3795 (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
|
|
3796 (add-text-properties (match-beginning 0) (match-end 0)
|
|
3797 '(font-lock-face info-xref
|
|
3798 mouse-face highlight
|
|
3799 help-echo "mouse-2: go to this URL"))))
|
|
3800
|
|
3801 (set-buffer-modified-p nil))))
|
16981
|
3802
|
|
3803
|
|
3804 ;; When an Info buffer is killed, make sure the associated tags buffer
|
|
3805 ;; is killed too.
|
|
3806 (defun Info-kill-buffer ()
|
|
3807 (and (eq major-mode 'Info-mode)
|
|
3808 Info-tag-table-buffer
|
|
3809 (kill-buffer Info-tag-table-buffer)))
|
|
3810
|
|
3811 (add-hook 'kill-buffer-hook 'Info-kill-buffer)
|
20755
|
3812
|
|
3813 ;;; Speedbar support:
|
|
3814 ;; These functions permit speedbar to display the "tags" in the
|
|
3815 ;; current info node.
|
22733
|
3816 (eval-when-compile (require 'speedbar))
|
20755
|
3817
|
22733
|
3818 (defvar Info-speedbar-key-map nil
|
|
3819 "Keymap used when in the info display mode.")
|
|
3820
|
|
3821 (defun Info-install-speedbar-variables ()
|
|
3822 "Install those variables used by speedbar to enhance Info."
|
|
3823 (if Info-speedbar-key-map
|
|
3824 nil
|
|
3825 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
|
20755
|
3826
|
22733
|
3827 ;; Basic tree features
|
|
3828 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
|
|
3829 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
|
|
3830 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
|
|
3831 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
|
|
3832 )
|
|
3833
|
|
3834 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
|
|
3835 Info-speedbar-key-map
|
|
3836 Info-speedbar-hierarchy-buttons)))
|
20755
|
3837
|
|
3838 (defvar Info-speedbar-menu-items
|
22733
|
3839 '(["Browse Node" speedbar-edit-line t]
|
|
3840 ["Expand Node" speedbar-expand-line
|
|
3841 (save-excursion (beginning-of-line)
|
|
3842 (looking-at "[0-9]+: *.\\+. "))]
|
|
3843 ["Contract Node" speedbar-contract-line
|
|
3844 (save-excursion (beginning-of-line)
|
|
3845 (looking-at "[0-9]+: *.-. "))]
|
|
3846 )
|
20755
|
3847 "Additional menu-items to add to speedbar frame.")
|
|
3848
|
22733
|
3849 ;; Make sure our special speedbar major mode is loaded
|
|
3850 (if (featurep 'speedbar)
|
|
3851 (Info-install-speedbar-variables)
|
|
3852 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
|
|
3853
|
|
3854 ;;; Info hierarchy display method
|
|
3855 ;;;###autoload
|
|
3856 (defun Info-speedbar-browser ()
|
|
3857 "Initialize speedbar to display an info node browser.
|
|
3858 This will add a speedbar major display mode."
|
|
3859 (interactive)
|
|
3860 (require 'speedbar)
|
|
3861 ;; Make sure that speedbar is active
|
|
3862 (speedbar-frame-mode 1)
|
|
3863 ;; Now, throw us into Info mode on speedbar.
|
|
3864 (speedbar-change-initial-expansion-list "Info")
|
|
3865 )
|
|
3866
|
32286
|
3867 (eval-when-compile (defvar speedbar-attached-frame))
|
|
3868
|
22733
|
3869 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
|
|
3870 "Display an Info directory hierarchy in speedbar.
|
|
3871 DIRECTORY is the current directory in the attached frame.
|
|
3872 DEPTH is the current indentation depth.
|
|
3873 NODE is an optional argument that is used to represent the
|
|
3874 specific node to expand."
|
|
3875 (if (and (not node)
|
|
3876 (save-excursion (goto-char (point-min))
|
22951
|
3877 (let ((case-fold-search t))
|
|
3878 (looking-at "Info Nodes:"))))
|
22733
|
3879 ;; Update our "current node" maybe?
|
|
3880 nil
|
|
3881 ;; We cannot use the generic list code, that depends on all leaves
|
|
3882 ;; being known at creation time.
|
|
3883 (if (not node)
|
|
3884 (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
|
3885 (let ((completions nil)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
3886 (cf (selected-frame)))
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
3887 (select-frame speedbar-attached-frame)
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
3888 (save-window-excursion
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
3889 (setq completions
|
186b2098dcd8
(Info-speedbar-hierarchy-buttons): Improved the speedbar frame management.
Eric M. Ludlam <zappo@gnu.org>
diff
changeset
|
3890 (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
|
3891 (select-frame cf)
|
22733
|
3892 (if completions
|
|
3893 (speedbar-with-writable
|
51434
|
3894 (dolist (completion completions)
|
22733
|
3895 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
|
51434
|
3896 (cdr completion)
|
|
3897 (car completion)
|
22733
|
3898 'Info-speedbar-goto-node
|
51434
|
3899 (cdr completion)
|
|
3900 'info-xref depth))
|
22733
|
3901 t)
|
|
3902 nil))))
|
28943
|
3903
|
22733
|
3904 (defun Info-speedbar-goto-node (text node indent)
|
32500
|
3905 "When user clicks on TEXT, go to an info NODE.
|
22733
|
3906 The INDENT level is ignored."
|
29446
|
3907 (select-frame speedbar-attached-frame)
|
|
3908 (let* ((buff (or (get-buffer "*info*")
|
|
3909 (progn (info) (get-buffer "*info*"))))
|
|
3910 (bwin (get-buffer-window buff 0)))
|
|
3911 (if bwin
|
|
3912 (progn
|
|
3913 (select-window bwin)
|
|
3914 (raise-frame (window-frame bwin)))
|
|
3915 (if speedbar-power-click
|
|
3916 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
|
|
3917 (select-frame speedbar-attached-frame)
|
|
3918 (switch-to-buffer buff)))
|
51434
|
3919 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
|
|
3920 (error "Invalid node %s" node)
|
|
3921 (Info-find-node (match-string 1 node) (match-string 2 node))
|
29446
|
3922 ;; If we do a find-node, and we were in info mode, restore
|
|
3923 ;; the old default method. Once we are in info mode, it makes
|
|
3924 ;; sense to return to whatever method the user was using before.
|
|
3925 (if (string= speedbar-initial-expansion-list-name "Info")
|
|
3926 (speedbar-change-initial-expansion-list
|
|
3927 speedbar-previously-used-expansion-list-name)))))
|
22733
|
3928
|
|
3929 (defun Info-speedbar-expand-node (text token indent)
|
|
3930 "Expand the node the user clicked on.
|
|
3931 TEXT is the text of the button we clicked on, a + or - item.
|
|
3932 TOKEN is data related to this node (NAME . FILE).
|
|
3933 INDENT is the current indentation depth."
|
|
3934 (cond ((string-match "+" text) ;we have to expand this file
|
|
3935 (speedbar-change-expand-button-char ?-)
|
|
3936 (if (speedbar-with-writable
|
29446
|
3937 (save-excursion
|
|
3938 (end-of-line) (forward-char 1)
|
|
3939 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
|
22733
|
3940 (speedbar-change-expand-button-char ?-)
|
|
3941 (speedbar-change-expand-button-char ??)))
|
|
3942 ((string-match "-" text) ;we have to contract this node
|
|
3943 (speedbar-change-expand-button-char ?+)
|
|
3944 (speedbar-delete-subblock indent))
|
|
3945 (t (error "Ooops... not sure what to do")))
|
|
3946 (speedbar-center-buffer-smartly))
|
|
3947
|
|
3948 (defun Info-speedbar-fetch-file-nodes (nodespec)
|
|
3949 "Fetch the subnodes from the info NODESPEC.
|
|
3950 NODESPEC is a string of the form: (file)node.
|
|
3951 Optional THISFILE represends the filename of"
|
|
3952 (save-excursion
|
|
3953 ;; Set up a buffer we can use to fake-out Info.
|
|
3954 (set-buffer (get-buffer-create "*info-browse-tmp*"))
|
|
3955 (if (not (equal major-mode 'Info-mode))
|
|
3956 (Info-mode))
|
|
3957 ;; Get the node into this buffer
|
51434
|
3958 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
|
|
3959 (error "Invalid node specification %s" nodespec)
|
|
3960 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
|
22733
|
3961 ;; Scan the created buffer
|
|
3962 (goto-char (point-min))
|
|
3963 (let ((completions nil)
|
22951
|
3964 (case-fold-search t)
|
22733
|
3965 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
|
|
3966 (match-string 1 nodespec))))
|
|
3967 ;; Always skip the first one...
|
|
3968 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
3969 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
3970 (let ((name (match-string 1)))
|
51434
|
3971 (push (cons name
|
|
3972 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
|
|
3973 (match-string 1)
|
|
3974 (if (looking-at " *\\(([^)]+)\\)\\.")
|
|
3975 (concat (match-string 1) "Top")
|
|
3976 (concat "(" thisfile ")"
|
|
3977 (if (looking-at " \\([^.]+\\).")
|
|
3978 (match-string 1)
|
|
3979 name)))))
|
|
3980 completions)))
|
22733
|
3981 (nreverse completions))))
|
|
3982
|
|
3983 ;;; Info mode node listing
|
51437
63b62b12e01c
(Info-extract-menu-node-name): Remove unused arg `errmessage'.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
3984 ;; FIXME: Seems not to be used. -stef
|
20755
|
3985 (defun Info-speedbar-buttons (buffer)
|
|
3986 "Create a speedbar display to help navigation in an Info file.
|
|
3987 BUFFER is the buffer speedbar is requesting buttons for."
|
22733
|
3988 (if (save-excursion (goto-char (point-min))
|
22951
|
3989 (let ((case-fold-search t))
|
|
3990 (not (looking-at "Info Nodes:"))))
|
22733
|
3991 (erase-buffer))
|
|
3992 (Info-speedbar-hierarchy-buttons nil 0)
|
|
3993 )
|
584
|
3994
|
28558
|
3995 (dolist (mess '("^Node has no Previous$"
|
|
3996 "^No menu in this node$"
|
|
3997 "^Node has no Next$"
|
28943
|
3998 "^No cross-references in this node^"
|
|
3999 search-failed
|
28558
|
4000 "^No \".*\" in index$"))
|
|
4001 (add-to-list 'debug-ignored-errors mess))
|
|
4002
|
55057
|
4003 ;;;; Desktop support
|
|
4004
|
|
4005 (defun Info-desktop-buffer-misc-data (desktop-dirname)
|
|
4006 "Auxiliary information to be saved in desktop file."
|
55797
|
4007 (if (not (member Info-current-file '("apropos" "history" "toc")))
|
|
4008 (list Info-current-file Info-current-node)))
|
55057
|
4009
|
|
4010 ;;;###autoload
|
|
4011 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
|
|
4012 desktop-buffer-name
|
|
4013 desktop-buffer-misc)
|
|
4014 "Restore an info buffer specified in a desktop file."
|
|
4015 (let ((first (nth 0 desktop-buffer-misc))
|
|
4016 (second (nth 1 desktop-buffer-misc)))
|
|
4017 (when (and first second)
|
55797
|
4018 (when desktop-buffer-name
|
|
4019 (set-buffer (get-buffer-create desktop-buffer-name))
|
|
4020 (Info-mode))
|
55084
|
4021 (Info-find-node first second)
|
55057
|
4022 (current-buffer))))
|
|
4023
|
584
|
4024 (provide 'info)
|
|
4025
|
52401
|
4026 ;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
|
660
|
4027 ;;; info.el ends here
|