428
|
1 ;;; info.el --- info package for Emacs.
|
|
2 ;; Keywords: help
|
|
3
|
|
4 ;; Copyright (C) 1985, 1986, 1993, 1997 Free Software Foundation, Inc.
|
771
|
5 ;; Copyright (C) 2002 Ben Wing.
|
428
|
6
|
|
7 ;; Author: Dave Gillespie <daveg@synaptics.com>
|
|
8 ;; Richard Stallman <rms@gnu.ai.mit.edu>
|
|
9 ;; Maintainer: Dave Gillespie <daveg@synaptics.com>
|
502
|
10 ;; Version: diverged at version 1.07 of 7/22/93
|
428
|
11 ;; Keywords: docs, help
|
|
12
|
|
13 ;; This file is part of XEmacs.
|
|
14
|
|
15 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
16 ;; under the terms of the GNU General Public License as published by
|
|
17 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
18 ;; any later version.
|
|
19
|
|
20 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
23 ;; General Public License for more details.
|
|
24
|
|
25 ;; You should have received a copy of the GNU General Public License
|
442
|
26 ;; along with XEmacs; see the file COPYING. If not, write to the
|
428
|
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
28 ;; Boston, MA 02111-1307, USA.
|
|
29
|
502
|
30 ;;; Synched up with: Not synched with FSF. Highly divergent, and with
|
|
31 ;;; many new features added for XEmacs.
|
428
|
32
|
|
33 ;; Commentary:
|
|
34
|
|
35 ;; This is based on an early Emacs 19 info.el file.
|
|
36 ;;
|
|
37 ;; Note that Info-directory has been replaced by Info-directory-list,
|
|
38 ;; a search path of directories in which to find Info files.
|
|
39 ;; Also, Info tries adding ".info" to a file name if the name itself
|
|
40 ;; is not found.
|
|
41 ;;
|
502
|
42 ;; See the partial change log below for further details, and look into
|
|
43 ;; ChangeLog for the rest.
|
428
|
44
|
|
45
|
|
46 ;; LCD Archive Entry:
|
|
47 ;; info-dg|Dave Gillespie|daveg@synaptics.com
|
|
48 ;; |Info reader with many enhancements; replaces standard info.el.
|
|
49 ;; |93-07-22|1.07|~/modes/info.el
|
|
50
|
|
51 ;; Also available from anonymous FTP on csvax.cs.caltech.edu.
|
|
52
|
|
53
|
|
54 ;; Change Log:
|
|
55
|
|
56 ;; Modified 3/7/1991 by Dave Gillespie:
|
|
57 ;; (Author's address: daveg@synaptics.com or daveg@csvax.cs.caltech.edu)
|
|
58 ;;
|
|
59 ;; Added keys: i, t, <, >, [, ], {, }, 6, 7, 8, 9, 0.
|
|
60 ;; Look at help for info-mode (type ? in Info) for descriptions.
|
|
61 ;;
|
|
62 ;; If Info-directory-list is undefined and there is no INFOPATH
|
|
63 ;; in the environment, use value of Info-directory for compatibility
|
|
64 ;; with Emacs 18.57.
|
|
65 ;;
|
|
66 ;; All files named "localdir" found in the path are appended to "dir",
|
|
67 ;; the Info directory. For this to work, "dir" should contain only
|
|
68 ;; one node (Top), and each "localdir" should contain no ^_ or ^L
|
|
69 ;; characters. Generally they will contain only one or several
|
|
70 ;; additional lines for the top-level menu. Note that "dir" is
|
|
71 ;; modified in memory each time it is loaded, but not on disk.
|
|
72 ;;
|
|
73 ;; If "dir" contains a line of the form: "* Locals:"
|
|
74 ;; then the "localdir"s are inserted there instead of at the end.
|
|
75
|
|
76
|
|
77 ;; Modified 4/3/1991 by Dave Gillespie:
|
|
78 ;;
|
|
79 ;; Added Info-mode-hook (suggested by Sebastian Kremer).
|
|
80 ;; Also added epoch-info-startup/select-hooks from Simon Spero's info.el.
|
|
81 ;;
|
|
82 ;; Added automatic decoding of compressed Info files.
|
|
83 ;; See documentation for the variable Info-suffix-list. Default is to
|
|
84 ;; run "uncompress" on ".Z" files and "unyabba" on ".Y" files.
|
|
85 ;; (See comp.sources.unix v24i073-076 for yabba/unyabba, a free software
|
|
86 ;; alternative to compress/uncompress.)
|
|
87 ;; Note: "dir" and "localdir" files should not be compressed.
|
|
88 ;;
|
|
89 ;; Changed variables like Info-enable-edit to be settable by M-x set-variable.
|
|
90 ;;
|
|
91 ;; Added Info-auto-advance variable. If t, SPC and DEL will act like
|
|
92 ;; } and {, i.e., they advance to the next/previous node if at the end
|
|
93 ;; of the buffer.
|
|
94 ;;
|
|
95 ;; Changed `u' to restore point to most recent location in that node.
|
|
96 ;; Added `=' to do this manually at any time. (Suggested by David Fox).
|
|
97 ;;
|
|
98 ;; Changed `m' and `0-9' to try interpreting menu name as a file name
|
|
99 ;; if not found as a node name. This allows (dir) menus of the form,
|
|
100 ;; Emacs:: Cool text editor
|
|
101 ;; as a shorthand for
|
|
102 ;; Emacs:(emacs). Cool text editor
|
|
103 ;;
|
|
104 ;; Enhanced `i' to use line-number information in the index.
|
|
105 ;; Added `,' to move among all matches to a previous `i' command.
|
|
106 ;;
|
|
107 ;; Added `a' (Info-annotate) for adding personal notes to any Info node.
|
|
108 ;; Notes are not stored in the actual Info files, but in the user's own
|
|
109 ;; ~/.infonotes file.
|
|
110 ;;
|
|
111 ;; Added Info-footnote-tag, made default be "Ref" instead of "Note".
|
|
112 ;;
|
|
113 ;; Got mouse-click stuff to work under Emacs version 18. Check it out!
|
|
114 ;; Left and right clicks scroll the Info window.
|
|
115 ;; Middle click goes to clicked-on node, e.g., "Next:", a menu, or a note.
|
|
116
|
|
117
|
|
118 ;; Modified 6/29/1991 by Dave Gillespie:
|
|
119 ;;
|
|
120 ;; Renamed epoch-info-startup/select-hooks to Info-startup/select-hook.
|
|
121 ;;
|
|
122 ;; Made Info-select-node into a command on the `!' key.
|
|
123 ;;
|
|
124 ;; Added Info-mouse-support user option.
|
|
125 ;;
|
|
126 ;; Cleaned up the implementation of some routines.
|
|
127 ;;
|
|
128 ;; Added special treatment of quoted words in annotations: The `g'
|
|
129 ;; command for a nonexistent node name scans for an annotation
|
|
130 ;; (in any node of any file) containing that name in quotes: g foo RET
|
|
131 ;; looks for an annotation containing: "foo" or: <<foo>>
|
|
132 ;; If found, it goes to that file and node.
|
|
133 ;;
|
|
134 ;; Added a call to set up Info-directory-list in Info-find-node to
|
|
135 ;; work around a bug in GNUS where it calls Info-goto-node before info.
|
|
136 ;;
|
|
137 ;; Added completion for `g' command (inspired by Richard Kim's infox.el).
|
|
138 ;; Completion knows all node names for the current file, and all annotation
|
|
139 ;; tags (see above). It does not complete file names or node names in
|
|
140 ;; other files.
|
|
141 ;;
|
|
142 ;; Added `k' (Info-emacs-key) and `*' (Info-elisp-ref) commands. You may
|
|
143 ;; wish to bind these to global keys outside of Info mode.
|
|
144 ;;
|
|
145 ;; Allowed localdir files to be full dir-like files; only the menu part
|
|
146 ;; of each localdir is copied. Also, redundant menu items are omitted.
|
|
147 ;;
|
|
148 ;; Changed Info-history to hold only one entry at a time for each node,
|
|
149 ;; and to be circular so that multiple `l's come back again to the most
|
|
150 ;; recent node. Note that the format of Info-history entries has changed,
|
|
151 ;; which may interfere with external programs that try to operate on it.
|
|
152 ;; (Also inspired by Kim's infox.el).
|
|
153 ;;
|
|
154 ;; Changed `n', `]', `l', etc. to accept prefix arguments to move several
|
|
155 ;; steps at once. Most accept negative arguments to move oppositely.
|
|
156 ;;
|
|
157 ;; Changed `?' to bury *Help* buffer afterwards to keep it out of the way.
|
|
158 ;;
|
|
159 ;; Rearranged `?' key's display to be a little better for new users.
|
|
160 ;;
|
|
161 ;; Changed `a' to save whole window configuration and restore on C-c C-c.
|
|
162 ;;
|
|
163 ;; Fixed the bug reported by Bill Reynolds on gnu.emacs.bugs.
|
|
164 ;;
|
|
165 ;; Changed Info-last to restore window-start as well as cursor position.
|
|
166 ;;
|
|
167 ;; Changed middle mouse button in space after end of node to do Info-last
|
|
168 ;; if we got here by following a cross reference, else do Info-global-next.
|
|
169 ;;
|
|
170 ;; Added some new mouse bindings: shift-left = Info-global-next,
|
|
171 ;; shift-right = Info-global-prev, shift-middle = Info-last.
|
|
172 ;;
|
|
173 ;; Fixed Info-follow-reference not to make assumptions about length
|
|
174 ;; of Info-footnote-tag [Linus Tolke].
|
|
175 ;;
|
|
176 ;; Changed default for Info-auto-advance mode to be press-twice-for-next-node.
|
|
177 ;;
|
|
178 ;; Modified x-mouse-ignore to preserve last-command variable, so that
|
|
179 ;; press-twice Info-auto-advance mode works with the mouse.
|
|
180
|
|
181
|
|
182 ;; Modified 3/4/1992 by Dave Gillespie:
|
|
183 ;;
|
|
184 ;; Added an "autoload" command to help autoload.el.
|
|
185 ;;
|
|
186 ;; Changed `*' command to look for file `elisp' as well as for `lispref'.
|
|
187 ;;
|
|
188 ;; Fixed a bug involving footnote names containing regexp special characters.
|
|
189 ;;
|
|
190 ;; Fixed a bug in completion during `f' (or `r') command.
|
|
191 ;;
|
|
192 ;; Added TAB (Info-next-reference), M-TAB, and RET keys to Info mode.
|
|
193 ;;
|
|
194 ;; Added new bindings, `C-h C-k' for Info-emacs-key and `C-h C-f' for
|
|
195 ;; Info-elisp-ref. These bindings are made when info.el is loaded, and
|
|
196 ;; only if those key sequences were previously unbound. These bindings
|
|
197 ;; work at any time, not just when Info is already running.
|
|
198
|
|
199
|
|
200 ;; Modified 3/8/1992 by Dave Gillespie:
|
|
201 ;;
|
|
202 ;; Fixed some long lines that were causing trouble with mailers.
|
|
203
|
|
204
|
|
205 ;; Modified 3/9/1992 by Dave Gillespie:
|
|
206 ;;
|
|
207 ;; Added `C-h C-i' (Info-query).
|
|
208 ;;
|
|
209 ;; Added Info-novice mode, warns if the user attempts to switch to
|
|
210 ;; a different Info file.
|
|
211 ;;
|
|
212 ;; Fixed a bug that caused problems using compressed Info files
|
|
213 ;; and Info-directory-list at the same time.
|
|
214 ;;
|
|
215 ;; Disabled Info-mouse-support by default if Epoch or Hyperbole is in use.
|
|
216 ;;
|
|
217 ;; Added an expand-file-name call to Info-find-node to fix a small bug.
|
|
218
|
|
219
|
|
220 ;; Modified 5/22/1992 by Dave Gillespie:
|
|
221 ;;
|
|
222 ;; Added "standalone" operation: "emacs -f info" runs Emacs specifically
|
|
223 ;; for use as an Info browser. In this mode, the `q' key quits Emacs
|
|
224 ;; itself. Also, "emacs -f info arg" starts in Info file "arg" instead
|
|
225 ;; of "dir".
|
|
226 ;;
|
|
227 ;; Changed to prefer "foo.info" over "foo". If both exist, "foo" is
|
|
228 ;; probably a directory or executable program!
|
|
229 ;;
|
|
230 ;; Made control-mouse act like regular-mouse does in other buffers.
|
|
231 ;; (In most systems, this will be set-cursor for left-mouse, x-cut
|
|
232 ;; for right-mouse, and x-paste, which will be an error, for
|
|
233 ;; middle-mouse.)
|
|
234 ;;
|
|
235 ;; Improved prompting and searching for `,' key.
|
|
236 ;;
|
|
237 ;; Fixed a bug where some "* Menu:" lines disappeared when "dir"
|
|
238 ;; contained several nodes.
|
|
239
|
|
240
|
|
241 ;; Modified 9/10/1992 by Dave Gillespie:
|
|
242 ;;
|
|
243 ;; Mixed in support for XEmacs. Mouse works the same as in
|
|
244 ;; the other Emacs versions by default; added Info-lucid-mouse-style
|
|
245 ;; variable, which enables mouse operation similar to XEmacs's default.
|
|
246 ;;
|
|
247 ;; Fixed a bug where RET couldn't understand "* Foo::" if "Foo" was a
|
|
248 ;; file name instead of a node name.
|
|
249 ;;
|
|
250 ;; Added `x' (Info-bookmark), a simple interface to the annotation
|
|
251 ;; tags feature. Added `j' (Info-goto-bookmark), like `g' but only
|
|
252 ;; completes bookmarks.
|
|
253 ;;
|
|
254 ;; Added `<<tag>>' as alternate to `"tag"' in annotations.
|
|
255 ;;
|
|
256 ;; Added `v' (Info-visit-file), like Info-goto-node but specialized
|
|
257 ;; for going to a new Info file (with file name completion).
|
|
258 ;;
|
|
259 ;; Added recognition of gzip'd ".z" files.
|
|
260
|
|
261
|
|
262 ;; Modified 5/9/1993 by Dave Gillespie:
|
|
263 ;;
|
|
264 ;; Merged in various things from FSF's latest Emacs 19 info.el.
|
|
265
|
|
266 ;; Modified 6/2/1993 by Dave Gillespie:
|
|
267 ;;
|
|
268 ;; Changed to use new suffix ".gz" for gzip files.
|
|
269
|
|
270
|
|
271 ;; Modified 7/22/1993 by Dave Gillespie:
|
|
272 ;;
|
|
273 ;; Changed Info-footnote-tag to "See" instead of "Ref".
|
|
274 ;;
|
|
275 ;; Extended Info-fontify-node to work with FSF version of Emacs 19.
|
|
276
|
|
277 ;; Modified 7/30/1993 by Jamie Zawinski:
|
|
278 ;;
|
|
279 ;; Commented out the tty and fsf19 mouse support, because why bother.
|
|
280 ;; Commented out the politically incorrect version of XEmacs mouse support.
|
|
281 ;; Commented out mouse scrolling bindings because the party line on that
|
|
282 ;; is "scrollbars are coming soon."
|
|
283 ;; Commented out munging of help-for-help's doc; put it in help.el.
|
|
284 ;; Did Info-edit-map the modern XEmacs way.
|
|
285 ;; Pruned extra cruft from fontification and mouse handling code.
|
|
286 ;; Fixed ASCII-centric bogosity in unreading of events.
|
|
287
|
|
288 ;; Modified 8/11/95 by Chuck Thompson:
|
|
289 ;;
|
|
290 ;; Removed any pretense of ever referencing Info-directory since it
|
|
291 ;; wasn't working anyhow.
|
|
292
|
|
293 ;; Modified 4/5/97 by Tomasz J. Cholewo:
|
|
294 ;;
|
|
295 ;; Modified Info-search to use with-caps-disable-folding
|
|
296
|
|
297 ;; Modified 6/21/97 by Hrvoje Niksic
|
|
298 ;;
|
|
299 ;; Fixed up Info-next-reference to work sanely when n < 0.
|
|
300 ;; Added S-tab binding.
|
|
301
|
|
302 ;; Modified 1997-07-10 by Karl M. Hegbloom
|
|
303 ;;
|
|
304 ;; Added `Info-minibuffer-history'
|
|
305 ;; (also added to defaults in "lisp/utils/savehist.el")
|
|
306 ;; Other changes in main ChangeLog.
|
|
307
|
|
308 ;; Modified 1998-03-29 by Oscar Figueiredo
|
|
309 ;;
|
|
310 ;; Added automatic dir/localdir (re)building capability for directories that
|
|
311 ;; contain none or when it has become older than info files in the same
|
|
312 ;; directory.
|
|
313
|
442
|
314 ;; Modified 1998-09-23 by Didier Verna <didier@xemacs.org>
|
428
|
315 ;;
|
|
316 ;; Use the new macro `with-search-caps-disable-folding'
|
|
317
|
|
318 ;; Code:
|
|
319 (eval-when-compile
|
|
320 (condition-case nil (require 'browse-url) (error nil)))
|
|
321
|
|
322 (defgroup info nil
|
|
323 "The info package for Emacs."
|
|
324 :group 'help
|
|
325 :group 'docs)
|
|
326
|
|
327 (defgroup info-faces nil
|
|
328 "The faces used by info browser."
|
|
329 :group 'info
|
|
330 :group 'faces)
|
|
331
|
|
332
|
|
333 (defcustom Info-inhibit-toolbar nil
|
|
334 "*Non-nil means don't use the specialized Info toolbar."
|
|
335 :type 'boolean
|
|
336 :group 'info)
|
|
337
|
|
338 (defcustom Info-novice nil
|
|
339 "*Non-nil means to ask for confirmation before switching Info files."
|
|
340 :type 'boolean
|
|
341 :group 'info)
|
|
342
|
|
343 (defvar Info-history nil
|
|
344 "List of info nodes user has visited.
|
|
345 Each element of list is a list (\"(FILENAME)NODENAME\" BUFPOS WINSTART).")
|
|
346
|
|
347 (defvar Info-keeping-history t
|
|
348 "Non-nil if Info-find-node should modify Info-history.
|
|
349 This is for use only by certain internal Info routines.")
|
|
350
|
|
351 (defvar Info-minibuffer-history nil
|
|
352 "Minibuffer history for Info.")
|
|
353
|
|
354 (defcustom Info-enable-edit nil
|
|
355 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info
|
|
356 can edit the current node.
|
|
357 This is convenient if you want to write info files by hand.
|
|
358 However, we recommend that you not do this.
|
|
359 It is better to write a Texinfo file and generate the Info file from that,
|
|
360 because that gives you a printed manual as well."
|
|
361 :type 'boolean
|
|
362 :group 'info)
|
|
363
|
|
364 (defcustom Info-enable-active-nodes t
|
|
365 "*Non-nil allows Info to execute Lisp code associated with nodes.
|
|
366 The Lisp code is executed when the node is selected."
|
|
367 :type 'boolean
|
|
368 :group 'info)
|
|
369
|
|
370 (defcustom Info-restoring-point t
|
|
371 "*Non-nil means to restore the cursor position when re-entering a node."
|
|
372 :type 'boolean
|
|
373 :group 'info)
|
|
374
|
|
375 (defcustom Info-auto-advance 'twice
|
|
376 "*Control what SPC and DEL do when they can't scroll any further.
|
|
377 If nil, they beep and remain in the current node.
|
|
378 If t, they move to the next node (like Info-global-next/prev).
|
|
379 If anything else, they must be pressed twice to move to the next node."
|
|
380 :type '(choice (const :tag "off" nil)
|
|
381 (const :tag "advance" t)
|
|
382 (const :tag "confirm" twice))
|
|
383 :group 'info)
|
|
384
|
|
385 (defcustom Info-fontify t
|
|
386 "*Non-nil enables font features in XEmacs.
|
|
387 This variable is ignored unless running under XEmacs."
|
|
388 :type 'boolean
|
|
389 :group 'info)
|
|
390
|
|
391 (defcustom Info-additional-search-directory-list nil
|
|
392 "*List of additional directories to search for Info documentation
|
|
393 files. These directories are not searched for merging the `dir'
|
|
394 file. An example might be something like:
|
|
395 \"/usr/local/lib/xemacs/packages/lisp/calc/\""
|
|
396 :type '(repeat directory)
|
|
397 :group 'info)
|
|
398
|
723
|
399 (defcustom Info-auto-generate-directory 'if-outdated
|
428
|
400 "*When to auto generate an info directory listing.
|
|
401 Possible values are:
|
|
402 nil or `never' never auto-generate a directory listing,
|
|
403 use any existing `dir' or `localdir' file and ignore info
|
|
404 directories containing none
|
|
405 `always' auto-generate a directory listing ignoring existing
|
|
406 `dir' and `localdir' files
|
|
407 `if-missing', the default, auto-generates a directory listing
|
442
|
408 if no `dir' or `localdir' file is present. Otherwise the
|
428
|
409 contents of any of these files is used instead.
|
|
410 `if-outdated' auto-generates a directory listing if the `dir'
|
442
|
411 and `localdir' are either inexistent or outdated (touched
|
428
|
412 less recently than an info file in the same directory)."
|
|
413 :type '(choice (const :tag "never" never)
|
|
414 (const :tag "always" always)
|
|
415 (const :tag "if-missing" if-missing)
|
|
416 (const :tag "if-outdated" if-outdated))
|
|
417 :group 'info)
|
|
418
|
442
|
419 (defcustom Info-save-auto-generated-dir 'never
|
428
|
420 "*Whether an auto-generated info directory listing should be saved.
|
|
421 Possible values are:
|
442
|
422 nil or `never', the default, auto-generated info directory
|
428
|
423 information will never be saved.
|
|
424 `always', auto-generated info directory information will be saved to
|
|
425 a `dir' file in the same directory overwriting it if it exists
|
|
426 `conservative', auto-generated info directory information will be saved
|
442
|
427 to a `dir' file in the same directory but the user is asked before
|
428
|
428 overwriting any existing file."
|
|
429 :type '(choice (const :tag "never" never)
|
|
430 (const :tag "always" always)
|
|
431 (const :tag "conservative" conservative))
|
|
432 :group 'info)
|
|
433
|
444
|
434 (defconst Info-emacs-info-file-name "xemacs.info"
|
|
435 "The filename of the XEmacs info for `Info-goto-emacs-command-node'
|
|
436 (`\\<help-mode-map>\\[Info-goto-emacs-command-node]')")
|
428
|
437
|
|
438 ;;;###autoload
|
|
439 (defvar Info-directory-list nil
|
|
440 "List of directories to search for Info documentation files.
|
|
441
|
|
442 The first directory in this list, the \"dir\" file there will become
|
438
|
443 the (dir)Top node of the Info documentation tree.
|
|
444
|
|
445 Note: DO NOT use the `customize' interface to change the value of this
|
|
446 variable. Its value is created dynamically on each startup, depending
|
|
447 on XEmacs packages installed on the system. If you want to change the
|
|
448 search path, make the needed modifications on the variable's value
|
|
449 from .emacs. For instance:
|
|
450
|
|
451 (setq Info-directory-list (cons \"~/info\" Info-directory-list))")
|
428
|
452
|
444
|
453 ;; This could as well be hard-coded since ${srcdir}/info/dir is in CVS --dv
|
|
454 (defconst Info-localdir-heading-regexp "^Local Packages:$"
|
428
|
455 "The menu part of localdir files will be inserted below this topic
|
444
|
456 heading.")
|
428
|
457
|
|
458 (defface info-node '((t (:bold t :italic t)))
|
|
459 "Face used for node links in info."
|
|
460 :group 'info-faces)
|
|
461
|
|
462 (defface info-xref '((t (:bold t)))
|
|
463 "Face used for cross-references in info."
|
|
464 :group 'info-faces)
|
|
465
|
444
|
466 ;; This list is based on Karl Berry-s advice about extensions `info' itself
|
|
467 ;; might encounter. --dv
|
|
468 (defcustom Info-suffix-list '(("" . nil)
|
|
469 (".info" . nil)
|
|
470 (".gz" . "gzip -dc %s")
|
|
471 (".info.gz" . "gzip -dc %s")
|
|
472 (".z" . "gzip -dc %s")
|
|
473 (".info.z" . "gzip -dc %s")
|
|
474 (".bz2" . "bzip2 -dc %s")
|
|
475 (".info.bz2" . "bzip2 -dc %s")
|
|
476 (".Z" . "uncompress -c %s")
|
|
477 (".info.Z" . "uncompress -c %s")
|
|
478 (".zip" . "unzip -c %s")
|
|
479 (".info.zip" . "unzip -c %s")
|
|
480 (".y" . "cat %s | unyabba")
|
|
481 ("info.y" . "cat %s | unyabba")
|
|
482 ;; These ones are for MS-DOS filenames.
|
|
483 (".inf" . nil)
|
|
484 (".igz" . "gzip -dc %s")
|
|
485 (".inz" . "gzip -c %s"))
|
|
486 "*List of file name suffixes and associated decoding commands.
|
428
|
487 Each entry should be (SUFFIX . STRING); if STRING contains %s, that is
|
|
488 changed to name of the file to decode, otherwise the file is given to
|
444
|
489 the command as standard input. If STRING is nil, no decoding is done."
|
|
490 :type '(repeat (cons (string :tag "suffix")
|
|
491 (choice :tag "command"
|
|
492 (const :tag "none" :value nil)
|
|
493 (string :tag ""))))
|
|
494 :group 'info)
|
428
|
495
|
444
|
496 (defcustom Info-footnote-tag "Note"
|
428
|
497 "*Symbol that identifies a footnote or cross-reference.
|
444
|
498 All \"*Note\" references will be changed to use this word instead."
|
|
499 :type 'string
|
|
500 :group 'info)
|
428
|
501
|
|
502 (defvar Info-current-file nil
|
|
503 "Info file that Info is now looking at, or nil.
|
|
504 This is the name that was specified in Info, not the actual file name.
|
|
505 It doesn't contain directory names or file name extensions added by Info.")
|
|
506
|
|
507 (defvar Info-current-subfile nil
|
|
508 "Info subfile that is actually in the *info* buffer now,
|
|
509 or nil if current info file is not split into subfiles.")
|
|
510
|
|
511 (defvar Info-current-node nil
|
|
512 "Name of node that Info is now looking at, or nil.")
|
|
513
|
442
|
514 (defvar Info-tag-table-marker nil
|
428
|
515 "Marker pointing at beginning of current Info file's tag table.
|
|
516 Marker points nowhere if file has no tag table.")
|
|
517
|
442
|
518 (defvar Info-tag-table-buffer nil)
|
|
519
|
428
|
520 (defvar Info-current-file-completions nil
|
|
521 "Cached completion list for current Info file.")
|
|
522
|
|
523 (defvar Info-current-annotation-completions nil
|
|
524 "Cached completion list for current annotation files.")
|
|
525
|
|
526 (defvar Info-index-alternatives nil
|
|
527 "List of possible matches for last Info-index command.")
|
444
|
528
|
428
|
529 (defvar Info-index-first-alternative nil)
|
|
530
|
|
531 (defcustom Info-annotations-path
|
|
532 (list
|
|
533 (paths-construct-path (list user-init-directory "info.notes"))
|
|
534 (paths-construct-path '("~" ".infonotes"))
|
|
535 (paths-construct-path '("usr" "lib" "info.notes")
|
|
536 (char-to-string directory-sep-char)))
|
|
537 "*Names of files that contain annotations for different Info nodes.
|
|
538 By convention, the first one should reside in your personal directory.
|
|
539 The last should be a world-writable \"public\" annotations file."
|
|
540 :type '(repeat file)
|
|
541 :group 'info)
|
|
542
|
|
543 (defcustom Info-button1-follows-hyperlink nil
|
|
544 "*Non-nil means mouse button1 click will follow hyperlink."
|
|
545 :type 'boolean
|
|
546 :group 'info)
|
|
547
|
|
548 (defvar Info-standalone nil
|
|
549 "Non-nil if Emacs was started solely as an Info browser.")
|
|
550
|
|
551 (defvar Info-in-cross-reference nil)
|
|
552 (defvar Info-window-configuration nil)
|
|
553
|
|
554 (defvar Info-dir-prologue "-*- Text -*-
|
|
555 This is the file .../info/dir, which contains the topmost node of the
|
|
556 Info hierarchy. The first time you invoke Info you start off
|
|
557 looking at that node, which is (dir)Top.
|
|
558
|
|
559 File: dir Node: Top This is the top of the INFO tree
|
442
|
560 This (the Directory node) gives a menu of major topics.
|
428
|
561
|
|
562 * Menu: The list of major topics begins on the next line.
|
|
563
|
|
564 ")
|
|
565
|
444
|
566 (defcustom Info-no-description-string "[No description available]"
|
|
567 "*Description string for info files that have none"
|
|
568 :type 'string
|
|
569 :group 'info)
|
428
|
570
|
|
571 ;;;###autoload
|
|
572 (defun info (&optional file)
|
|
573 "Enter Info, the documentation browser.
|
|
574 Optional argument FILE specifies the file to examine;
|
|
575 the default is the top-level directory of Info.
|
|
576
|
|
577 In interactive use, a prefix argument directs this command
|
|
578 to read a file name from the minibuffer."
|
|
579 (interactive (if current-prefix-arg
|
|
580 (list (read-file-name "Info file name: " nil nil t))))
|
|
581 (let ((p command-line-args))
|
|
582 (while p
|
|
583 (and (string-match "^-[fe]" (car p))
|
|
584 (equal (nth 1 p) "info")
|
|
585 (not Info-standalone)
|
|
586 (setq Info-standalone t)
|
|
587 (= (length p) 3)
|
|
588 (not (string-match "^-" (nth 2 p)))
|
|
589 (setq file (nth 2 p))
|
|
590 (setq command-line-args-left nil))
|
|
591 (setq p (cdr p))))
|
|
592 ; (Info-setup-x) ??? What was this going to be? Can anyone tell karlheg?
|
|
593 (if file
|
|
594 (unwind-protect
|
|
595 (Info-goto-node (concat "(" file ")"))
|
|
596 (and Info-standalone (info)))
|
|
597 (if (get-buffer "*info*")
|
|
598 (switch-to-buffer "*info*")
|
|
599 (Info-directory))))
|
|
600
|
|
601 ;;;###autoload
|
|
602 (defun Info-query (file)
|
|
603 "Enter Info, the documentation browser. Prompt for name of Info file."
|
|
604 (interactive "sInfo topic (default = menu): ")
|
|
605 (info)
|
|
606 (if (equal file "")
|
|
607 (Info-goto-node "(dir)")
|
|
608 (Info-goto-node (concat "(" file ")"))))
|
|
609
|
|
610 (defun Info-setup-initial ()
|
|
611 (let ((f Info-annotations-path))
|
|
612 (while f
|
|
613 (if (and (file-exists-p (car f)) (not (get-file-buffer (car f))))
|
|
614 (bury-buffer (find-file-noselect (car f))))
|
|
615 (setq f (cdr f)))))
|
|
616
|
442
|
617 ;;;###autoload
|
428
|
618 (defun Info-find-node (filename &optional nodename no-going-back tryfile line)
|
|
619 "Go to an info node specified as separate FILENAME and NODENAME.
|
|
620 Look for a plausible filename, or if not found then look for URL's and
|
771
|
621 dispatch to the appropriate fn. NO-GOING-BACK is non-nil if recovering
|
|
622 from an error in this function; it says do not attempt further (recursive)
|
|
623 error recovery. TRYFILE indicates that NODENAME might actually be a
|
|
624 filename, so if we can't find a node of this name, try going to the `Top'
|
|
625 node of a file of this name."
|
428
|
626
|
|
627 (Info-setup-initial)
|
|
628
|
|
629 (cond
|
|
630 ;; empty filename is simple case
|
|
631 ((null filename)
|
|
632 (Info-find-file-node nil nodename no-going-back tryfile line))
|
|
633 ;; Convert filename to lower case if not found as specified.
|
|
634 ;; Expand it, look harder...
|
444
|
635 ((let ((fname (substitute-in-file-name filename))
|
|
636 temp found)
|
428
|
637 (let ((dirs (cond
|
444
|
638 ;; If specified name starts with `./', then just try
|
|
639 ;; current directory. No point in searching for an absolute
|
|
640 ;; file name
|
|
641 ((string-match "^\\./" fname)
|
|
642 (list default-directory))
|
428
|
643 ((file-name-absolute-p fname)
|
444
|
644 '(nil))
|
428
|
645 (Info-additional-search-directory-list
|
|
646 (append Info-directory-list
|
|
647 Info-additional-search-directory-list))
|
|
648 (t Info-directory-list))))
|
|
649 ;; Search the directory list for file FNAME.
|
|
650 (while (and dirs (not found))
|
|
651 (setq temp (expand-file-name fname (car dirs)))
|
444
|
652 (setq found (Info-suffixed-file temp))
|
428
|
653 (setq dirs (cdr dirs)))
|
442
|
654 (if found
|
428
|
655 (progn (setq filename (expand-file-name found))
|
|
656 t))))
|
|
657 (Info-find-file-node filename nodename no-going-back tryfile line))
|
|
658 ;; Look for a URL. This pattern is stolen from w3.el to prevent
|
|
659 ;; loading it if we won't need it.
|
|
660 ((string-match (concat "^\\(wais\\|solo\\|x-exec\\|newspost\\|www\\|"
|
|
661 "mailto\\|news\\|tn3270\\|ftp\\|http\\|file\\|"
|
|
662 "telnet\\|gopher\\):")
|
|
663 filename)
|
776
|
664 (if-fboundp 'browse-url
|
428
|
665 (browse-url filename)
|
776
|
666 (error 'unimplemented "no `browse-url' package; Cannot follow URLs in this XEmacs")))
|
428
|
667 (t
|
|
668 (error "Info file %s does not exist" filename))))
|
|
669
|
|
670 (defun Info-find-file-node (filename nodename
|
|
671 &optional no-going-back tryfile line)
|
|
672 ;; This is the guts of what was Info-find-node. Whoever wrote this
|
|
673 ;; should be locked up where they can't do any more harm.
|
|
674
|
|
675 ;; Go into info buffer.
|
442
|
676 (or (eq major-mode 'Info-mode)
|
|
677 (switch-to-buffer "*info*"))
|
428
|
678 (buffer-disable-undo (current-buffer))
|
|
679 (run-hooks 'Info-startup-hook)
|
|
680 (or (eq major-mode 'Info-mode)
|
|
681 (Info-mode))
|
|
682 (or (null filename)
|
|
683 (equal Info-current-file filename)
|
|
684 (not Info-novice)
|
|
685 (string= "dir" (file-name-nondirectory Info-current-file))
|
442
|
686 (if (y-or-n-p
|
428
|
687 (format "Leave Info file `%s'? "
|
|
688 (file-name-nondirectory Info-current-file)))
|
|
689 (message "")
|
|
690 (keyboard-quit)))
|
|
691 ;; Record the node we are leaving.
|
|
692 (if (and Info-current-file (not no-going-back))
|
|
693 (Info-history-add Info-current-file Info-current-node (point)))
|
|
694 (widen)
|
|
695 (setq Info-current-node nil
|
|
696 Info-in-cross-reference nil)
|
|
697 (unwind-protect
|
|
698 (progn
|
|
699 ;; Switch files if necessary
|
|
700 (or (null filename)
|
|
701 (equal Info-current-file filename)
|
|
702 (let ((buffer-read-only nil))
|
|
703 (setq Info-current-file nil
|
|
704 Info-current-subfile nil
|
|
705 Info-current-file-completions nil
|
771
|
706 ;; Nooooooooooo! Info-index can extend across more
|
|
707 ;; than one file (e.g. XEmacs, Lispref)
|
|
708 ;; Info-index-alternatives nil
|
428
|
709 buffer-file-name nil)
|
|
710 (erase-buffer)
|
|
711 (if (string= "dir" (file-name-nondirectory filename))
|
|
712 (Info-insert-dir)
|
|
713 (Info-insert-file-contents filename t)
|
|
714 (setq default-directory (file-name-directory filename)))
|
|
715 (set-buffer-modified-p nil)
|
|
716 ;; See whether file has a tag table. Record the location if yes.
|
|
717 (set-marker Info-tag-table-marker nil)
|
|
718 (goto-char (point-max))
|
|
719 (forward-line -8)
|
|
720 (or (equal nodename "*")
|
|
721 (not (search-forward "\^_\nEnd tag table\n" nil t))
|
|
722 (let (pos)
|
|
723 ;; We have a tag table. Find its beginning.
|
|
724 ;; Is this an indirect file?
|
|
725 (search-backward "\nTag table:\n")
|
|
726 (setq pos (point))
|
|
727 (if (save-excursion
|
|
728 (forward-line 2)
|
|
729 (looking-at "(Indirect)\n"))
|
|
730 ;; It is indirect. Copy it to another buffer
|
|
731 ;; and record that the tag table is in that buffer.
|
442
|
732 (let ((buf (current-buffer))
|
|
733 (m Info-tag-table-marker))
|
|
734 (or
|
|
735 Info-tag-table-buffer
|
|
736 (setq
|
|
737 Info-tag-table-buffer
|
|
738 (generate-new-buffer " *info tag table*")))
|
|
739 (save-excursion
|
|
740 (set-buffer Info-tag-table-buffer)
|
|
741 (buffer-disable-undo (current-buffer))
|
|
742 (setq case-fold-search t)
|
|
743 (erase-buffer)
|
|
744 (insert-buffer-substring buf)
|
|
745 (set-marker m (match-end 0))))
|
428
|
746 (set-marker Info-tag-table-marker pos))))
|
|
747 (setq Info-current-file
|
|
748 (file-name-sans-versions buffer-file-name))))
|
|
749 (if (equal nodename "*")
|
|
750 (progn (setq Info-current-node nodename)
|
|
751 (Info-set-mode-line)
|
|
752 (goto-char (point-min)))
|
|
753 ;; Search file for a suitable node.
|
|
754 (let* ((qnode (regexp-quote nodename))
|
|
755 (regexp (concat "Node: *" qnode " *[,\t\n\177]"))
|
|
756 (guesspos (point-min))
|
|
757 (found t))
|
|
758 ;; First get advice from tag table if file has one.
|
|
759 ;; Also, if this is an indirect info file,
|
|
760 ;; read the proper subfile into this buffer.
|
|
761 (if (marker-position Info-tag-table-marker)
|
442
|
762 (let (foun found-mode (m Info-tag-table-marker))
|
|
763 (save-excursion
|
|
764 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
765 (goto-char m)
|
|
766 (setq foun (re-search-forward regexp nil t))
|
444
|
767 (if foun
|
442
|
768 (setq guesspos (read (current-buffer))))
|
|
769 (setq found-mode major-mode))
|
444
|
770 (if foun
|
442
|
771 ;; If this is an indirect file,
|
|
772 ;; determine which file really holds this node
|
|
773 ;; and read it in.
|
|
774 (if (not (eq major-mode found-mode))
|
|
775 (setq guesspos
|
|
776 (Info-read-subfile guesspos))))))
|
428
|
777 (goto-char (max (point-min) (- guesspos 1000)))
|
|
778 ;; Now search from our advised position (or from beg of buffer)
|
|
779 ;; to find the actual node.
|
|
780 (catch 'foo
|
|
781 (while (search-forward "\n\^_" nil t)
|
|
782 (forward-line 1)
|
|
783 (let ((beg (point)))
|
|
784 (forward-line 1)
|
|
785 (if (re-search-backward regexp beg t)
|
|
786 (throw 'foo t))))
|
|
787 (setq found nil)
|
|
788 (let ((bufs (delq nil (mapcar 'get-file-buffer
|
|
789 Info-annotations-path)))
|
|
790 (pattern (if (string-match "\\`<<.*>>\\'" qnode) qnode
|
|
791 (format "\"%s\"\\|<<%s>>" qnode qnode)))
|
|
792 (pat2 (concat "------ *File: *\\([^ ].*[^ ]\\) *Node: "
|
|
793 "*\\([^ ].*[^ ]\\) *Line: *\\([0-9]+\\)"))
|
|
794 (afile nil) anode aline)
|
|
795 (while (and bufs (not anode))
|
|
796 (save-excursion
|
|
797 (set-buffer (car bufs))
|
|
798 (goto-char (point-min))
|
|
799 (if (re-search-forward pattern nil t)
|
|
800 (if (re-search-backward pat2 nil t)
|
|
801 (setq afile (buffer-substring (match-beginning 1)
|
|
802 (match-end 1))
|
|
803 anode (buffer-substring (match-beginning 2)
|
|
804 (match-end 2))
|
|
805 aline (string-to-int
|
|
806 (buffer-substring (match-beginning 3)
|
|
807 (match-end 3)))))))
|
|
808 (setq bufs (cdr bufs)))
|
|
809 (if anode
|
|
810 (Info-find-node afile anode t nil aline)
|
|
811 (if tryfile
|
|
812 (condition-case nil
|
|
813 (Info-find-node nodename "Top" t)
|
|
814 (error nil)))))
|
|
815 (or Info-current-node
|
|
816 (error "No such node: %s" nodename)))
|
|
817 (if found
|
|
818 (progn
|
|
819 (Info-select-node)
|
|
820 (goto-char (point-min))
|
|
821 (if line (forward-line line)))))))
|
|
822 ;; If we did not finish finding the specified node,
|
|
823 ;; go back to the previous one.
|
|
824 (or Info-current-node no-going-back
|
|
825 (let ((hist (car Info-history)))
|
|
826 ;; The following is no longer safe with new Info-history system
|
|
827 ;; (setq Info-history (cdr Info-history))
|
|
828 (Info-goto-node (car hist) t)
|
|
829 (goto-char (+ (point-min) (nth 1 hist)))))))
|
|
830
|
|
831 ;; Cache the contents of the (virtual) dir file, once we have merged
|
|
832 ;; it for the first time, so we can save time subsequently.
|
|
833 (defvar Info-dir-contents nil)
|
|
834
|
|
835 ;; Cache for the directory we decided to use for the default-directory
|
|
836 ;; of the merged dir text.
|
|
837 (defvar Info-dir-contents-directory nil)
|
|
838
|
|
839 ;; Record the file attributes of all the files from which we
|
|
840 ;; constructed Info-dir-contents.
|
|
841 (defvar Info-dir-file-attributes nil)
|
|
842
|
|
843 (defun Info-insert-dir ()
|
|
844 "Construct the Info directory node by merging the files named
|
444
|
845 \"dir\" or \"localdir\" from the directories in `Info-directory-list'.
|
428
|
846 The \"dir\" files will take precedence in cases where both exist. It
|
|
847 sets the *info* buffer's `default-directory' to the first directory we
|
|
848 actually get any text from."
|
|
849 (if (and Info-dir-contents Info-dir-file-attributes
|
|
850 ;; Verify that none of the files we used has changed
|
|
851 ;; since we used it.
|
|
852 (eval (cons 'and
|
|
853 (mapcar #'(lambda (elt)
|
|
854 (let ((curr (file-attributes (car elt))))
|
|
855 ;; Don't compare the access time.
|
|
856 (if curr (setcar (nthcdr 4 curr) 0))
|
|
857 (setcar (nthcdr 4 (cdr elt)) 0)
|
|
858 (equal (cdr elt) curr)))
|
|
859 Info-dir-file-attributes))))
|
|
860 (insert Info-dir-contents)
|
|
861 (let ((dirs (reverse Info-directory-list))
|
|
862 buffers lbuffers buffer others nodes dirs-done)
|
|
863
|
|
864 (setq Info-dir-file-attributes nil)
|
|
865
|
|
866 ;; Search the directory list for the directory file.
|
|
867 (while dirs
|
|
868 (let ((truename (file-truename (expand-file-name (car dirs)))))
|
|
869 (or (member truename dirs-done)
|
|
870 (member (directory-file-name truename) dirs-done)
|
444
|
871 ;; Karl Berry recently added the ability all possibilities for
|
|
872 ;; extension as for normal info files. This code however is
|
|
873 ;; still unsatisfactory: if one day, we find a compressed dir
|
|
874 ;; file (which looks possible), we should be able to handle it
|
|
875 ;; (which means decompress and read it, update it, save and
|
|
876 ;; recompress it). --dv
|
|
877 (let ((trials '("dir" "DIR"
|
|
878 "dir.info" "DIR.INFO"
|
|
879 "dir.inf" "DIR.INF"
|
|
880 "localdir" "LOCALDIR"
|
|
881 "localdir.info" "LOCALDIR.INFO"
|
|
882 "localdir.inf" "LOCALDIR.INF"))
|
|
883 buf file attrs)
|
|
884 (catch 'found
|
|
885 (while (setq file (pop trials))
|
|
886 (setq file (expand-file-name file truename))
|
|
887 (and (setq attrs (file-attributes file))
|
|
888 (throw 'found t))))
|
|
889 (unless file
|
|
890 (setq file (expand-file-name "dir" truename)))
|
428
|
891 (setq dirs-done
|
|
892 (cons truename
|
|
893 (cons (directory-file-name truename)
|
|
894 dirs-done)))
|
|
895 (Info-maybe-update-dir file)
|
|
896 (setq attrs (file-attributes file))
|
|
897 (if (or (setq buf (find-buffer-visiting file))
|
|
898 attrs)
|
|
899 (save-excursion
|
|
900 (or buffers
|
|
901 (message "Composing main Info directory..."))
|
|
902 (set-buffer (or buf
|
|
903 (generate-new-buffer
|
|
904 (if (string-match "localdir" file)
|
|
905 "localdir"
|
|
906 "info dir"))))
|
442
|
907 (if (not buf)
|
428
|
908 (insert-file-contents file))
|
|
909 (if (string-match "localdir" (buffer-name))
|
|
910 (setq lbuffers (cons (current-buffer) lbuffers))
|
|
911 (setq buffers (cons (current-buffer) buffers)))
|
|
912 (if attrs
|
|
913 (setq Info-dir-file-attributes
|
|
914 (cons (cons file attrs)
|
|
915 Info-dir-file-attributes)))))))
|
|
916 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs)))
|
|
917 (setq dirs (cdr dirs))))
|
442
|
918
|
428
|
919 ;; ensure that the localdir files are inserted last, and reverse
|
|
920 ;; the list of them so that when they get pushed in, they appear
|
|
921 ;; in the same order they got specified in the path, from top to
|
|
922 ;; bottom.
|
|
923 (nconc buffers (reverse lbuffers))
|
442
|
924
|
428
|
925 (or buffers
|
|
926 (error "Can't find the Info directory node"))
|
|
927 ;; Distinguish the dir file that comes with Emacs from all the
|
|
928 ;; others. Yes, that is really what this is supposed to do.
|
|
929 ;; If it doesn't work, fix it.
|
|
930 (setq buffer (car buffers)
|
|
931 ;; reverse it since they are pushed down from the top. the
|
|
932 ;; `Info-directory-list can be specified in natural order
|
|
933 ;; this way.
|
|
934 others (reverse (cdr buffers)))
|
|
935
|
|
936 ;; Insert the entire original dir file as a start; note that we've
|
|
937 ;; already saved its default directory to use as the default
|
|
938 ;; directory for the whole concatenation.
|
|
939 (insert-buffer buffer)
|
|
940
|
|
941 ;; Look at each of the other buffers one by one.
|
|
942 (while others
|
|
943 (let ((other (car others))
|
|
944 (info-buffer (current-buffer)))
|
|
945 (if (string-match "localdir" (buffer-name other))
|
|
946 (save-excursion
|
|
947 (set-buffer info-buffer)
|
|
948 (goto-char (point-max))
|
|
949 (cond
|
|
950 ((re-search-backward "^ *\\* *Locals *: *$" nil t)
|
|
951 (delete-region (match-beginning 0) (match-end 0)))
|
|
952 ;; look for a line like |Local XEmacs packages:
|
|
953 ;; or mismatch on some text ...
|
|
954 ((re-search-backward Info-localdir-heading-regexp nil t)
|
|
955 ;; This is for people who underline topic headings with
|
|
956 ;; equal signs or dashes.
|
|
957 (when (save-excursion
|
|
958 (forward-line 1)
|
|
959 (beginning-of-line)
|
|
960 (looking-at "^[ \t]*[-=*]+"))
|
|
961 (forward-line 1))
|
|
962 (forward-line 1)
|
|
963 (beginning-of-line))
|
|
964 (t (search-backward "\^L" nil t)))
|
|
965 ;; Insert menu part of the file
|
|
966 (let* ((pt (point))
|
|
967 (len (length (buffer-string nil nil other))))
|
|
968 (insert (buffer-string nil nil other))
|
|
969 (goto-char (+ pt len))
|
|
970 (save-excursion
|
|
971 (goto-char pt)
|
|
972 (if (search-forward "* Menu:" (+ pt len) t)
|
|
973 (progn
|
|
974 (forward-line 1)
|
|
975 (delete-region pt (point)))))))
|
|
976 ;; In each, find all the menus.
|
|
977 (save-excursion
|
|
978 (set-buffer other)
|
|
979 (goto-char (point-min))
|
|
980 ;; Find each menu, and add an elt to NODES for it.
|
|
981 (while (re-search-forward "^\\* Menu:" nil t)
|
|
982 (let (beg nodename end)
|
|
983 (forward-line 1)
|
|
984 (setq beg (point))
|
|
985 (search-backward "\n\^_")
|
|
986 (search-forward "Node: ")
|
|
987 (setq nodename (Info-following-node-name))
|
|
988 (search-forward "\n\^_" nil 'move)
|
|
989 (beginning-of-line)
|
|
990 (setq end (point))
|
|
991 (setq nodes (cons (list nodename other beg end) nodes))))))
|
|
992 (setq others (cdr others))))
|
442
|
993
|
428
|
994 ;; Add to the main menu a menu item for each other node.
|
|
995 (re-search-forward "^\\* Menu:" nil t)
|
|
996 (forward-line 1)
|
|
997 (let ((menu-items '("top"))
|
|
998 (nodes nodes)
|
|
999 (case-fold-search t)
|
|
1000 (end (save-excursion (search-forward "\^_" nil t) (point))))
|
|
1001 (while nodes
|
|
1002 (let ((nodename (car (car nodes))))
|
|
1003 (save-excursion
|
|
1004 (or (member (downcase nodename) menu-items)
|
|
1005 (re-search-forward (concat "^\\* "
|
|
1006 (regexp-quote nodename)
|
|
1007 "::")
|
|
1008 end t)
|
|
1009 (progn
|
|
1010 (insert "* " nodename "::" "\n")
|
|
1011 (setq menu-items (cons nodename menu-items))))))
|
|
1012 (setq nodes (cdr nodes))))
|
|
1013 ;; Now take each node of each of the other buffers
|
|
1014 ;; and merge it into the main buffer.
|
|
1015 (while nodes
|
|
1016 (let ((nodename (car (car nodes))))
|
|
1017 (goto-char (point-min))
|
|
1018 ;; Find the like-named node in the main buffer.
|
|
1019 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
|
|
1020 (regexp-quote nodename)
|
|
1021 "[,\n\t]")
|
|
1022 nil t)
|
|
1023 (progn
|
|
1024 (search-forward "\n\^_" nil 'move)
|
|
1025 (beginning-of-line)
|
|
1026 (insert "\n"))
|
|
1027 ;; If none exists, add one.
|
|
1028 (goto-char (point-max))
|
|
1029 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
|
|
1030 ;; Merge the text from the other buffer's menu
|
|
1031 ;; into the menu in the like-named node in the main buffer.
|
|
1032 (apply 'insert-buffer-substring (cdr (car nodes))))
|
|
1033 (setq nodes (cdr nodes)))
|
|
1034 ;; Kill all the buffers we just made.
|
|
1035 (while buffers
|
|
1036 (kill-buffer (car buffers))
|
|
1037 (setq buffers (cdr buffers)))
|
|
1038 (while lbuffers
|
|
1039 (kill-buffer (car lbuffers))
|
|
1040 (setq lbuffers (cdr lbuffers)))
|
|
1041 (message "Composing main Info directory...done"))
|
|
1042 (setq Info-dir-contents (buffer-string)))
|
|
1043 (setq default-directory Info-dir-contents-directory)
|
|
1044 (setq buffer-file-name (caar Info-dir-file-attributes)))
|
|
1045
|
444
|
1046 (defmacro Info-directory-files (dir-file &optional all full nosort files-only)
|
|
1047 "Return a list of Info files living in the same directory as DIR-FILE.
|
|
1048 This list actually contains the files living in this directory, except for
|
|
1049 the dir file itself and the secondary info files (foo-1 foo-2 etc).
|
|
1050
|
|
1051 If the optional argument ALL is non nil, the secondary info files are also
|
|
1052 included in the list.
|
|
1053
|
|
1054 Please refer to the function `directory-files' for the meaning of the other
|
|
1055 optional arguments."
|
|
1056 `(let* ((dir (file-name-directory ,dir-file))
|
|
1057 (all-files (remove ,dir-file (directory-files dir ',full nil ',nosort
|
|
1058 ',files-only))))
|
|
1059 (setq all-files
|
|
1060 (if ,full
|
|
1061 (remove (concat dir ".")
|
|
1062 (remove (concat dir "..") all-files))
|
|
1063 (remove "."
|
|
1064 (remove ".." all-files))))
|
|
1065 (if ,all
|
|
1066 all-files
|
|
1067 (let ((suff-match
|
|
1068 (concat "-[0-9]+\\("
|
|
1069 ;; Extract all known compression suffixes from
|
|
1070 ;; Info-suffix-list. These suffixes can typically be
|
|
1071 ;; found in entries of the form `.info.something'.
|
|
1072 (let ((suff-list Info-suffix-list)
|
|
1073 suff regexp)
|
|
1074 (while (setq suff (pop suff-list))
|
|
1075 (and (string-match "^\\.info" (car suff))
|
|
1076 (setq regexp (concat regexp
|
|
1077 (regexp-quote
|
|
1078 (substring
|
|
1079 (car suff) 5))
|
|
1080 (and suff-list "\\|")))))
|
|
1081 regexp)
|
|
1082 "\\)?$"))
|
|
1083 info-files file)
|
|
1084 (while (setq file (pop all-files))
|
|
1085 (or (string-match suff-match file)
|
|
1086 (push file info-files)))
|
|
1087 (reverse info-files)
|
|
1088 ))
|
|
1089 ))
|
|
1090
|
428
|
1091 (defun Info-maybe-update-dir (file)
|
|
1092 "Rebuild dir or localdir according to `Info-auto-generate-directory'."
|
|
1093 (unless (or (not (file-exists-p (file-name-directory file)))
|
444
|
1094 (null (Info-directory-files file 'all)))
|
428
|
1095 (if (not (find-buffer-visiting file))
|
|
1096 (if (not (file-exists-p file))
|
747
|
1097 (if (or (memq Info-auto-generate-directory
|
|
1098 '(always if-missing if-outdated)))
|
428
|
1099 (Info-build-dir-anew (file-name-directory file)))
|
|
1100 (if (or (eq Info-auto-generate-directory 'always)
|
|
1101 (and (eq Info-auto-generate-directory 'if-outdated)
|
|
1102 (Info-dir-outdated-p file)))
|
|
1103 (Info-rebuild-dir file))))))
|
|
1104
|
|
1105 ;; Record which *.info files are newer than the dir file
|
|
1106 (defvar Info-dir-newer-info-files nil)
|
|
1107
|
|
1108 (defun Info-dir-outdated-p (file)
|
|
1109 "Return non-nil if dir or localdir is outdated.
|
|
1110 dir or localdir are outdated when an info file in the same
|
|
1111 directory has been modified more recently."
|
|
1112 (let ((dir-mod-time (nth 5 (file-attributes file)))
|
444
|
1113 f-mod-time newer)
|
428
|
1114 (setq Info-dir-newer-info-files nil)
|
442
|
1115 (mapcar
|
428
|
1116 #'(lambda (f)
|
|
1117 (prog2
|
|
1118 (setq f-mod-time (nth 5 (file-attributes f)))
|
|
1119 (setq newer (or (> (car f-mod-time) (car dir-mod-time))
|
|
1120 (and (= (car f-mod-time) (car dir-mod-time))
|
444
|
1121 (> (car (cdr f-mod-time))
|
|
1122 (car (cdr dir-mod-time))))))
|
|
1123 (if (and (file-readable-p f) newer)
|
442
|
1124 (setq Info-dir-newer-info-files
|
428
|
1125 (cons f Info-dir-newer-info-files)))))
|
444
|
1126 (Info-directory-files file nil 'fullname 'nosort t))
|
428
|
1127 Info-dir-newer-info-files))
|
|
1128
|
|
1129 (defun Info-extract-dir-entry-from (file)
|
|
1130 "Extract the dir entry from the info FILE.
|
|
1131 The dir entry is delimited by the markers `START-INFO-DIR-ENTRY'
|
444
|
1132 and `END-INFO-DIR-ENTRY'."
|
428
|
1133 (save-excursion
|
|
1134 (set-buffer (get-buffer-create " *Info-tmp*"))
|
|
1135 (when (file-readable-p file)
|
|
1136 (insert-file-contents file nil nil nil t)
|
|
1137 (goto-char (point-min))
|
|
1138 (let (beg)
|
|
1139 (unless (null (re-search-forward "^START-INFO-DIR-ENTRY" nil t))
|
|
1140 (forward-line 1)
|
|
1141 (setq beg (point))
|
|
1142 (unless (null (re-search-forward "^END-INFO-DIR-ENTRY" nil t))
|
|
1143 (goto-char (match-beginning 0))
|
|
1144 (car (Info-parse-dir-entries beg (point)))))))))
|
|
1145
|
444
|
1146 ;; Parse dir entries contained between START and END into a list of the form
|
428
|
1147 ;; (filename topic node (description-line-1 description-line-2 ...))
|
444
|
1148 (defun Info-parse-dir-entries (start end)
|
428
|
1149 (let (entry entries)
|
|
1150 (save-excursion
|
|
1151 (save-restriction
|
444
|
1152 (narrow-to-region start end)
|
|
1153 (goto-char start)
|
|
1154 (while (re-search-forward
|
|
1155 "^\\* \\([^:]+\\):\\([ \t]*(\\([^)]*\\))\\w*\\.\\|:\\)" nil t)
|
428
|
1156 (setq entry (list (match-string 2)
|
|
1157 (match-string 1)
|
|
1158 (downcase (or (match-string 3)
|
|
1159 (match-string 1)))))
|
442
|
1160 (setq entry
|
|
1161 (cons (nreverse
|
|
1162 (cdr
|
|
1163 (nreverse
|
|
1164 (split-string
|
|
1165 (buffer-substring
|
428
|
1166 (re-search-forward "[ \t]*" nil t)
|
|
1167 (or (and (re-search-forward "^[^ \t]" nil t)
|
|
1168 (goto-char (match-beginning 0)))
|
|
1169 (point-max)))
|
|
1170 "[ \t]*\n[ \t]*"))))
|
|
1171 entry))
|
|
1172 (setq entries (cons (nreverse entry) entries)))))
|
|
1173 (nreverse entries)))
|
|
1174
|
|
1175 (defun Info-dump-dir-entries (entries)
|
|
1176 (let ((tab-width 8)
|
|
1177 (description-col 0)
|
|
1178 len)
|
|
1179 (mapcar #'(lambda (e)
|
|
1180 (setq e (cdr e)) ; Drop filename
|
|
1181 (setq len (length (concat (car e)
|
|
1182 (car (cdr e)))))
|
|
1183 (if (> len description-col)
|
|
1184 (setq description-col len)))
|
|
1185 entries)
|
442
|
1186 (setq description-col (+ 5 description-col))
|
428
|
1187 (mapcar #'(lambda (e)
|
|
1188 (setq e (cdr e)) ; Drop filename
|
|
1189 (insert "* " (car e) ":" (car (cdr e)))
|
|
1190 (setq e (car (cdr (cdr e))))
|
|
1191 (while e
|
|
1192 (indent-to-column description-col)
|
|
1193 (insert (car e) "\n")
|
|
1194 (setq e (cdr e))))
|
|
1195 entries)
|
|
1196 (insert "\n")))
|
|
1197
|
|
1198
|
|
1199 (defun Info-build-dir-anew (directory)
|
|
1200 "Build info directory information for DIRECTORY.
|
442
|
1201 The generated directory listing may be saved to a `dir' according
|
444
|
1202 to the value of `Info-save-auto-generated-dir'."
|
428
|
1203 (save-excursion
|
|
1204 (let* ((dirfile (expand-file-name "dir" directory))
|
|
1205 (to-temp (or (null Info-save-auto-generated-dir)
|
|
1206 (eq Info-save-auto-generated-dir 'never)
|
|
1207 (and (not (file-writable-p dirfile))
|
444
|
1208 (message "File not writable %s. Using temporary."
|
|
1209 dirfile))))
|
|
1210 (info-files (Info-directory-files dirfile nil 'fullname nil t)))
|
428
|
1211 (if to-temp
|
|
1212 (message "Creating temporary dir in %s..." directory)
|
|
1213 (message "Creating %s..." dirfile))
|
|
1214 (set-buffer (find-file-noselect dirfile t))
|
|
1215 (setq buffer-read-only nil)
|
|
1216 (erase-buffer)
|
444
|
1217 (insert Info-dir-prologue "Info files in " directory ":\n\n")
|
442
|
1218 (Info-dump-dir-entries
|
|
1219 (mapcar
|
428
|
1220 #'(lambda (f)
|
|
1221 (or (Info-extract-dir-entry-from f)
|
|
1222 (list 'dummy
|
444
|
1223 (progn (string-match "\\([^.]*\\)\\(\\..*\\)?$"
|
|
1224 (file-name-nondirectory f))
|
|
1225 (capitalize
|
|
1226 (match-string 1 (file-name-nondirectory f))))
|
428
|
1227 ":"
|
|
1228 (list Info-no-description-string))))
|
|
1229 info-files))
|
|
1230 (if to-temp
|
|
1231 (set-buffer-modified-p nil)
|
|
1232 (save-buffer))
|
|
1233 (if to-temp
|
|
1234 (message "Creating temporary dir in %s...done" directory)
|
|
1235 (message "Creating %s...done" dirfile)))))
|
|
1236
|
|
1237
|
|
1238 (defun Info-rebuild-dir (file)
|
|
1239 "Build info directory information in the directory of dir FILE.
|
442
|
1240 Description of info files are merged from the info files in the
|
428
|
1241 directory and the contents of FILE with the description in info files
|
442
|
1242 taking precedence over descriptions in FILE.
|
|
1243 The generated directory listing may be saved to a `dir' according to
|
444
|
1244 the value of `Info-save-auto-generated-dir'."
|
428
|
1245 (save-excursion
|
|
1246 (save-restriction
|
|
1247 (let (dir-section-contents dir-full-contents
|
|
1248 dir-entry
|
|
1249 file-dir-entry
|
|
1250 mark next-section
|
|
1251 not-first-section
|
442
|
1252 (to-temp
|
428
|
1253 (or (null Info-save-auto-generated-dir)
|
|
1254 (eq Info-save-auto-generated-dir 'never)
|
|
1255 (and (eq Info-save-auto-generated-dir 'always)
|
|
1256 (not (file-writable-p file))
|
|
1257 (message "File not writable %s. Using temporary." file))
|
|
1258 (and (eq Info-save-auto-generated-dir 'conservative)
|
|
1259 (or (and (not (file-writable-p file))
|
444
|
1260 (message
|
|
1261 "File not writable %s. Using temporary." file))
|
442
|
1262 (not (y-or-n-p
|
|
1263 (message "%s is outdated. Overwrite ? "
|
428
|
1264 file))))))))
|
|
1265 (set-buffer (find-file-noselect file t))
|
|
1266 (setq buffer-read-only nil)
|
|
1267 (if to-temp
|
|
1268 (message "Rebuilding temporary %s..." file)
|
|
1269 (message "Rebuilding %s..." file))
|
|
1270 (catch 'done
|
|
1271 (setq buffer-read-only nil)
|
|
1272 (goto-char (point-min))
|
|
1273 (unless (and (search-forward "\^_")
|
|
1274 (re-search-forward "^\\* Menu:.*$" nil t)
|
|
1275 (setq mark (and (re-search-forward "^\\* " nil t)
|
|
1276 (match-beginning 0))))
|
|
1277 (throw 'done nil))
|
|
1278 (setq dir-full-contents (Info-parse-dir-entries mark (point-max)))
|
444
|
1279 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$"
|
|
1280 nil t)
|
428
|
1281 (match-beginning 0))
|
|
1282 (point-max)))
|
|
1283 (while next-section
|
|
1284 (narrow-to-region mark next-section)
|
444
|
1285 (setq dir-section-contents (nreverse (Info-parse-dir-entries
|
|
1286 (point-min) (point-max))))
|
428
|
1287 (mapcar
|
|
1288 #'(lambda (file)
|
|
1289 (setq dir-entry (assoc (downcase
|
|
1290 (file-name-sans-extension
|
|
1291 (file-name-nondirectory file)))
|
|
1292 dir-section-contents)
|
|
1293 file-dir-entry (Info-extract-dir-entry-from file))
|
|
1294 (if dir-entry
|
|
1295 (if file-dir-entry
|
444
|
1296 ;; A dir entry in the info file takes precedence over
|
|
1297 ;; an existing entry in the dir file
|
428
|
1298 (setcdr dir-entry (cdr file-dir-entry)))
|
|
1299 (unless (or not-first-section
|
|
1300 (assoc (downcase
|
|
1301 (file-name-sans-extension
|
|
1302 (file-name-nondirectory file)))
|
|
1303 dir-full-contents))
|
|
1304 (if file-dir-entry
|
444
|
1305 (setq dir-section-contents
|
|
1306 (cons file-dir-entry dir-section-contents))
|
442
|
1307 (setq dir-section-contents
|
428
|
1308 (cons (list 'dummy
|
|
1309 (capitalize (file-name-sans-extension
|
444
|
1310 (file-name-nondirectory
|
|
1311 file)))
|
428
|
1312 ":"
|
442
|
1313 (list Info-no-description-string))
|
428
|
1314 dir-section-contents))))))
|
|
1315 Info-dir-newer-info-files)
|
|
1316 (delete-region (point-min) (point-max))
|
|
1317 (Info-dump-dir-entries (nreverse dir-section-contents))
|
|
1318 (widen)
|
|
1319 (if (= next-section (point-max))
|
|
1320 (setq next-section nil)
|
|
1321 (or (setq mark (and (re-search-forward "^\\* " nil t)
|
|
1322 (match-beginning 0)))
|
|
1323 (throw 'done nil))
|
444
|
1324 (setq next-section (or (and (re-search-forward
|
|
1325 "^[^* \t].*:[ \t]*$" nil t)
|
428
|
1326 (match-beginning 0))
|
|
1327 (point-max))))
|
|
1328 (setq not-first-section t)))
|
|
1329 (if to-temp
|
|
1330 (progn
|
|
1331 (set-buffer-modified-p nil)
|
|
1332 (message "Rebuilding temporary %s...done" file))
|
|
1333 (save-buffer)
|
|
1334 (message "Rebuilding %s...done" file))))))
|
|
1335
|
442
|
1336 ;;;###autoload
|
428
|
1337 (defun Info-batch-rebuild-dir ()
|
444
|
1338 "(Re)build `dir' files in the directories remaining on the command line.
|
|
1339 Use this from the command line, with `-batch', it won't work in an
|
|
1340 interactive XEmacs.
|
|
1341
|
|
1342 Each file is processed even if an error occurred previously. For example,
|
|
1343 invoke \"xemacs -batch -f Info-batch-rebuild-dir /usr/local/info\"."
|
428
|
1344 ;; command-line-args-left is what is left of the command line (from
|
|
1345 ;; startup.el)
|
|
1346 (defvar command-line-args-left) ; Avoid 'free variable' warning
|
|
1347 (if (not noninteractive)
|
|
1348 (error "`Info-batch-rebuild-dir' is to be used only with -batch"))
|
|
1349 (let ((Info-save-auto-generated-dir 'always)
|
|
1350 dir localdir)
|
|
1351 (while command-line-args-left
|
|
1352 (if (not (file-directory-p (car command-line-args-left)))
|
|
1353 (message "Warning: Skipped %s. Not a directory."
|
|
1354 (car command-line-args-left))
|
|
1355 (setq dir (expand-file-name "dir" (car command-line-args-left)))
|
444
|
1356 (setq localdir (expand-file-name "localdir"
|
|
1357 (car command-line-args-left)))
|
442
|
1358 (cond
|
428
|
1359 ((file-exists-p dir)
|
|
1360 (Info-rebuild-dir dir))
|
|
1361 ((file-exists-p localdir)
|
|
1362 (Info-rebuild-dir localdir))
|
|
1363 (t
|
|
1364 (Info-build-dir-anew (car command-line-args-left)))))
|
|
1365 (setq command-line-args-left (cdr command-line-args-left)))
|
|
1366 (message "Done")
|
|
1367 (kill-emacs 0)))
|
|
1368
|
|
1369 (defun Info-history-add (file node point)
|
|
1370 (if Info-keeping-history
|
|
1371 (let* ((name (format "(%s)%s" (Info-file-name-only file) node))
|
|
1372 (found (assoc name Info-history)))
|
|
1373 (if found
|
|
1374 (setq Info-history (delq found Info-history)))
|
|
1375 (setq Info-history (cons (list name (- point (point-min))
|
|
1376 (and (eq (window-buffer)
|
|
1377 (current-buffer))
|
|
1378 (- (window-start) (point-min))))
|
|
1379 Info-history)))))
|
|
1380
|
|
1381 (defun Info-file-name-only (file)
|
|
1382 (let ((dir (file-name-directory file))
|
|
1383 (p Info-directory-list))
|
|
1384 (while (and p (not (equal (car p) dir)))
|
|
1385 (setq p (cdr p)))
|
|
1386 (if p (file-name-nondirectory file) file)))
|
|
1387
|
|
1388 (defun Info-read-subfile (nodepos)
|
|
1389 (let (lastfilepos
|
|
1390 lastfilename)
|
442
|
1391 (save-excursion
|
|
1392 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
1393 (goto-char (point-min))
|
|
1394 (search-forward "\n\^_")
|
|
1395 (forward-line 2)
|
|
1396 (catch 'foo
|
|
1397 (while (not (looking-at "\^_"))
|
|
1398 (if (not (eolp))
|
444
|
1399 (let ((start (point))
|
442
|
1400 thisfilepos thisfilename)
|
|
1401 (search-forward ": ")
|
444
|
1402 (setq thisfilename (buffer-substring start (- (point) 2)))
|
442
|
1403 (setq thisfilepos (read (current-buffer)))
|
|
1404 ;; read in version 19 stops at the end of number.
|
|
1405 ;; Advance to the next line.
|
|
1406 (if (eolp)
|
|
1407 (forward-line 1))
|
|
1408 (if (> thisfilepos nodepos)
|
|
1409 (throw 'foo t))
|
|
1410 (setq lastfilename thisfilename)
|
|
1411 (setq lastfilepos thisfilepos))
|
|
1412 (throw 'foo t)))))
|
428
|
1413 (or (equal Info-current-subfile lastfilename)
|
|
1414 (let ((buffer-read-only nil))
|
|
1415 (setq buffer-file-name nil)
|
|
1416 (widen)
|
|
1417 (erase-buffer)
|
|
1418 (Info-insert-file-contents (Info-suffixed-file
|
|
1419 (expand-file-name lastfilename
|
|
1420 (file-name-directory
|
444
|
1421 Info-current-file))
|
|
1422 'exact)
|
428
|
1423 t)
|
|
1424 (set-buffer-modified-p nil)
|
|
1425 (setq Info-current-subfile lastfilename)))
|
|
1426 (goto-char (point-min))
|
|
1427 (search-forward "\n\^_")
|
|
1428 (+ (- nodepos lastfilepos) (point))))
|
|
1429
|
444
|
1430 (defun Info-all-case-regexp (str)
|
|
1431 (let ((regexp "")
|
|
1432 (len (length str))
|
|
1433 (i 0)
|
|
1434 c)
|
|
1435 (while (< i len)
|
|
1436 (setq c (aref str i))
|
|
1437 (cond ((or (and (>= c ?A) (<= c ?Z))
|
|
1438 (and (>= c ?a) (<= c ?z)))
|
|
1439 (setq regexp (concat regexp
|
|
1440 "["
|
|
1441 (char-to-string (downcase c))
|
|
1442 "\\|"
|
|
1443 (char-to-string (upcase c))
|
|
1444 "]")))
|
|
1445 (t
|
|
1446 (setq regexp (concat regexp (char-to-string c)))))
|
|
1447 (setq i (1+ i)))
|
|
1448 regexp))
|
|
1449
|
|
1450 (defun Info-suffixed-file (name &optional exact)
|
|
1451 "Look for an info file named NAME. This function tries to be smart in
|
|
1452 finding the file corresponding to NAME: if it doesn't exist, several
|
|
1453 variants are looked for, notably by appending suffixes from
|
|
1454 `Info-suffix-list' and by trying to change the characters case in NAME.
|
|
1455
|
|
1456 The optional argument EXACT prevents this function from trying different case
|
|
1457 versions of NAME. Only the suffixes are tried."
|
|
1458 (catch 'found
|
|
1459 ;; First, try NAME alone:
|
|
1460 (and (file-regular-p name) (throw 'found name))
|
|
1461 ;; Then, try different variants
|
|
1462 (let ((suff-match (concat "\\("
|
|
1463 (let ((suff-list Info-suffix-list)
|
|
1464 suff regexp)
|
|
1465 (while (setq suff (pop suff-list))
|
|
1466 (setq regexp
|
|
1467 (concat regexp
|
|
1468 (regexp-quote (car suff))
|
|
1469 (and suff-list "\\|"))))
|
|
1470 regexp)
|
|
1471 "\\)?$"))
|
|
1472 (dir (file-name-directory name))
|
|
1473 file files)
|
|
1474 (setq name (file-name-nondirectory name))
|
|
1475 (setq files
|
|
1476 (condition-case data ;; protect against invalid directory
|
|
1477 ;; First, try NAME[.<suffix>]
|
|
1478 (append
|
|
1479 (directory-files dir 'fullname
|
|
1480 (concat "^" (regexp-quote name) suff-match)
|
|
1481 nil t)
|
|
1482 (if exact
|
|
1483 nil
|
|
1484 ;; Then, try to match the name independantly of the
|
|
1485 ;; characters case.
|
|
1486 (directory-files dir 'fullname
|
|
1487 (Info-all-case-regexp
|
|
1488 (concat "^"
|
|
1489 (regexp-quote name)
|
|
1490 suff-match))
|
|
1491 nil t)))
|
|
1492 (t
|
|
1493 (display-warning 'info
|
|
1494 (format "directory `%s' error: %s" dir data))
|
|
1495 nil)))
|
|
1496 (while (setq file (pop files))
|
|
1497 (and (file-regular-p file)
|
|
1498 (throw 'found file)))
|
|
1499 )))
|
428
|
1500
|
|
1501 (defun Info-insert-file-contents (file &optional visit)
|
|
1502 (setq file (expand-file-name file default-directory))
|
444
|
1503 (let ((suff Info-suffix-list)
|
|
1504 len)
|
|
1505 (while (and suff
|
|
1506 (setq len (length (car (car suff))))
|
|
1507 (or (<= (length file) len)
|
|
1508 (not (or
|
|
1509 (equal (substring file (- len))
|
|
1510 (car (car suff)))
|
|
1511 (equal (substring file (- len))
|
|
1512 (upcase (car (car suff)))))
|
|
1513 )))
|
428
|
1514 (setq suff (cdr suff)))
|
|
1515 (if (stringp (cdr (car suff)))
|
|
1516 (let ((command (if (string-match "%s" (cdr (car suff)))
|
|
1517 (format (cdr (car suff)) file)
|
|
1518 (concat (cdr (car suff)) " < " file))))
|
|
1519 (message "%s..." command)
|
|
1520 (call-process shell-file-name nil t nil "-c" command)
|
|
1521 (message "")
|
|
1522 (when visit
|
|
1523 (setq buffer-file-name file)
|
|
1524 (set-buffer-modified-p nil)
|
|
1525 (clear-visited-file-modtime)))
|
|
1526 (insert-file-contents file visit))))
|
|
1527
|
|
1528 (defun Info-select-node ()
|
|
1529 "Select the node that point is in, after using `g *' to select whole file."
|
|
1530 (interactive)
|
|
1531 (widen)
|
|
1532 (save-excursion
|
|
1533 ;; Find beginning of node.
|
|
1534 (search-backward "\n\^_")
|
|
1535 (forward-line 2)
|
|
1536 ;; Get nodename spelled as it is in the node.
|
|
1537 (re-search-forward "Node:[ \t]*")
|
|
1538 (setq Info-current-node
|
|
1539 (buffer-substring (point)
|
|
1540 (progn
|
|
1541 (skip-chars-forward "^,\t\n")
|
|
1542 (point))))
|
|
1543 (Info-set-mode-line)
|
|
1544 ;; Find the end of it, and narrow.
|
|
1545 (beginning-of-line)
|
|
1546 (let (active-expression)
|
|
1547 (narrow-to-region (point)
|
|
1548 (if (re-search-forward "\n[\^_\f]" nil t)
|
|
1549 (prog1
|
|
1550 (1- (point))
|
|
1551 (if (looking-at "[\n\^_\f]*execute: ")
|
|
1552 (progn
|
|
1553 (goto-char (match-end 0))
|
|
1554 (setq active-expression
|
|
1555 (read (current-buffer))))))
|
|
1556 (point-max)))
|
|
1557 (or (equal Info-footnote-tag "Note")
|
|
1558 (progn
|
|
1559 (goto-char (point-min))
|
|
1560 (let ((buffer-read-only nil)
|
|
1561 (bufmod (buffer-modified-p))
|
|
1562 (case-fold-search t))
|
|
1563 (while (re-search-forward "\\*[Nn]ote\\([ \n]\\)" nil t)
|
|
1564 (replace-match (concat "*" Info-footnote-tag "\ ")))
|
|
1565 (set-buffer-modified-p bufmod))))
|
|
1566 (Info-reannotate-node)
|
|
1567 ;; XEmacs: remove v19 test
|
|
1568 (and Info-fontify
|
|
1569 (Info-fontify-node))
|
|
1570 (run-hooks 'Info-select-hook)
|
|
1571 (if Info-enable-active-nodes (eval active-expression)))))
|
|
1572
|
|
1573 (defun Info-set-mode-line ()
|
|
1574 (setq modeline-buffer-identification
|
|
1575 (list (cons modeline-buffer-id-left-extent "Info: ")
|
|
1576 (cons modeline-buffer-id-right-extent
|
|
1577 (concat
|
|
1578 "("
|
|
1579 (if Info-current-file
|
444
|
1580 (let ((name (file-name-nondirectory
|
|
1581 Info-current-file)))
|
|
1582 (if (string-match "^\\([^.]*\\)\\..*$" name)
|
|
1583 (match-string 1 name)
|
428
|
1584 name))
|
|
1585 "")
|
|
1586 ")"
|
|
1587 (or Info-current-node ""))))))
|
771
|
1588
|
428
|
1589
|
|
1590 ;; Go to an info node specified with a filename-and-nodename string
|
|
1591 ;; of the sort that is found in pointers in nodes.
|
|
1592
|
|
1593 ;;;###autoload
|
|
1594 (defun Info-goto-node (nodename &optional no-going-back tryfile)
|
|
1595 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME.
|
|
1596 Actually, the following interpretations of NAME are tried in order:
|
|
1597 (FILENAME)NODENAME
|
|
1598 (FILENAME) (using Top node)
|
|
1599 NODENAME (in current file)
|
|
1600 TAGNAME (see below)
|
|
1601 FILENAME (using Top node)
|
|
1602 where TAGNAME is a string that appears in quotes: \"TAGNAME\", in an
|
|
1603 annotation for any node of any file. (See `a' and `x' commands.)"
|
|
1604 (interactive (list (Info-read-node-name "Goto node, file or tag: ")
|
|
1605 nil t))
|
|
1606 (let (filename)
|
|
1607 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
|
|
1608 nodename)
|
|
1609 (setq filename (if (= (match-beginning 1) (match-end 1))
|
|
1610 ""
|
|
1611 (substring nodename (match-beginning 2) (match-end 2)))
|
|
1612 nodename (substring nodename (match-beginning 3) (match-end 3)))
|
|
1613 (let ((trim (string-match "\\s *\\'" filename)))
|
|
1614 (if trim (setq filename (substring filename 0 trim))))
|
|
1615 (let ((trim (string-match "\\s *\\'" nodename)))
|
|
1616 (if trim (setq nodename (substring nodename 0 trim))))
|
|
1617 (Info-find-node (if (equal filename "") nil filename)
|
|
1618 (if (equal nodename "") "Top" nodename)
|
|
1619 no-going-back (and tryfile (equal filename "")))))
|
|
1620
|
|
1621 (defun Info-goto-bookmark ()
|
|
1622 (interactive)
|
|
1623 (let ((completion-ignore-case nil)
|
|
1624 (tag (completing-read "Goto tag: "
|
|
1625 (Info-build-annotation-completions)
|
|
1626 nil t nil
|
|
1627 'Info-minibuffer-history)))
|
|
1628 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
|
|
1629
|
|
1630 ;;;###autoload
|
438
|
1631 (defun Info-visit-file (file)
|
428
|
1632 "Directly visit an info file."
|
438
|
1633 (interactive "fVisit Info file: ")
|
|
1634 (Info-find-node (expand-file-name file) "Top"))
|
428
|
1635
|
|
1636 (defun Info-restore-point (&optional always)
|
|
1637 "Restore point to same location it had last time we were in this node."
|
|
1638 (interactive "p")
|
|
1639 (if (or Info-restoring-point always)
|
|
1640 (let* ((name (format "(%s)%s"
|
|
1641 (Info-file-name-only Info-current-file)
|
|
1642 Info-current-node))
|
|
1643 (p (assoc name Info-history)))
|
|
1644 (if p (Info-restore-history-entry p)))))
|
|
1645
|
|
1646 (defun Info-restore-history-entry (entry)
|
|
1647 (goto-char (+ (nth 1 entry) (point-min)))
|
|
1648 (and (nth 2 entry)
|
|
1649 (get-buffer-window (current-buffer))
|
|
1650 (set-window-start (get-buffer-window (current-buffer))
|
|
1651 (+ (nth 2 entry) (point-min)))))
|
|
1652
|
438
|
1653 (defvar Info-read-node-completion-table)
|
|
1654
|
|
1655 ;; This function is used as the "completion table" while reading a node name.
|
|
1656 ;; It does completion using the alist in Info-read-node-completion-table
|
|
1657 ;; unless STRING starts with an open-paren.
|
|
1658 (defun Info-read-node-name-1 (string predicate code)
|
|
1659 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
|
|
1660 (cond ((eq code nil)
|
|
1661 (if no-completion
|
|
1662 string
|
444
|
1663 (try-completion string Info-read-node-completion-table
|
|
1664 predicate)))
|
438
|
1665 ((eq code t)
|
|
1666 (if no-completion
|
|
1667 nil
|
444
|
1668 (all-completions string Info-read-node-completion-table
|
|
1669 predicate)))
|
438
|
1670 ((eq code 'lambda)
|
|
1671 (if no-completion
|
|
1672 t
|
|
1673 (assoc string Info-read-node-completion-table))))))
|
|
1674
|
428
|
1675 (defun Info-read-node-name (prompt &optional default)
|
|
1676 (Info-setup-initial)
|
|
1677 (let* ((completion-ignore-case t)
|
438
|
1678 (Info-read-node-completion-table (Info-build-node-completions))
|
|
1679 (nodename (completing-read prompt 'Info-read-node-name-1
|
|
1680 nil t nil 'Info-minibuffer-history
|
|
1681 default)))
|
428
|
1682 (if (equal nodename "")
|
|
1683 (or default
|
|
1684 (Info-read-node-name prompt))
|
|
1685 nodename)))
|
|
1686
|
|
1687 (defun Info-build-annotation-completions ()
|
|
1688 (or Info-current-annotation-completions
|
|
1689 (save-excursion
|
|
1690 (let ((bufs (delq nil (mapcar 'get-file-buffer
|
|
1691 Info-annotations-path)))
|
|
1692 (compl nil))
|
|
1693 (while bufs
|
|
1694 (set-buffer (car bufs))
|
|
1695 (goto-char (point-min))
|
|
1696 (while (re-search-forward "<<\\(.*\\)>>" nil t)
|
|
1697 (setq compl (cons (list (buffer-substring (match-beginning 1)
|
|
1698 (match-end 1)))
|
|
1699 compl)))
|
|
1700 (setq bufs (cdr bufs)))
|
|
1701 (setq Info-current-annotation-completions compl)))))
|
|
1702
|
|
1703 (defun Info-build-node-completions ()
|
|
1704 (or Info-current-file-completions
|
442
|
1705 (let ((m Info-tag-table-marker)
|
|
1706 (compl (Info-build-annotation-completions)))
|
428
|
1707 (save-excursion
|
|
1708 (save-restriction
|
|
1709 (widen)
|
|
1710 (if (marker-buffer Info-tag-table-marker)
|
|
1711 (progn
|
|
1712 (set-buffer (marker-buffer Info-tag-table-marker))
|
442
|
1713 (goto-char m)
|
428
|
1714 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
|
|
1715 (setq compl
|
|
1716 (cons (list (buffer-substring (match-beginning 1)
|
|
1717 (match-end 1)))
|
|
1718 compl))))
|
|
1719 (goto-char (point-min))
|
|
1720 (while (search-forward "\n\^_" nil t)
|
|
1721 (forward-line 1)
|
444
|
1722 (let ((start (point)))
|
428
|
1723 (forward-line 1)
|
|
1724 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
|
444
|
1725 start t)
|
442
|
1726 (setq compl
|
428
|
1727 (cons (list (buffer-substring (match-beginning 1)
|
|
1728 (match-end 1)))
|
|
1729 compl))))))))
|
|
1730 (setq Info-current-file-completions compl))))
|
|
1731
|
|
1732 (defvar Info-last-search nil
|
|
1733 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
|
|
1734
|
|
1735
|
|
1736 ;;;###autoload
|
|
1737 (defun Info-search (regexp)
|
|
1738 "Search for REGEXP, starting from point, and select node it's found in."
|
438
|
1739 (interactive (list
|
|
1740 (read-from-minibuffer
|
|
1741 (if Info-last-search
|
|
1742 (format "Search (regexp, default %s): "
|
|
1743 Info-last-search)
|
|
1744 "Search (regexp): ")
|
|
1745 nil nil nil nil nil Info-last-search)))
|
|
1746 (setq Info-last-search regexp)
|
428
|
1747 (with-search-caps-disable-folding regexp t
|
|
1748 (let ((found ())
|
|
1749 (onode Info-current-node)
|
|
1750 (ofile Info-current-file)
|
|
1751 (opoint (point))
|
|
1752 (osubfile Info-current-subfile))
|
|
1753 (save-excursion
|
|
1754 (save-restriction
|
|
1755 (widen)
|
|
1756 (if (null Info-current-subfile)
|
|
1757 (progn (re-search-forward regexp) (setq found (point)))
|
|
1758 (condition-case nil
|
|
1759 (progn (re-search-forward regexp) (setq found (point)))
|
|
1760 (search-failed nil)))))
|
444
|
1761 (if (not found)
|
|
1762 ;; can only happen in subfile case -- else would have erred
|
428
|
1763 (unwind-protect
|
|
1764 (let ((list ()))
|
442
|
1765 (save-excursion
|
|
1766 (set-buffer (marker-buffer Info-tag-table-marker))
|
|
1767 (goto-char (point-min))
|
|
1768 (search-forward "\n\^_\nIndirect:")
|
|
1769 (save-restriction
|
|
1770 (narrow-to-region (point)
|
|
1771 (progn (search-forward "\n\^_")
|
|
1772 (1- (point))))
|
|
1773 (goto-char (point-min))
|
|
1774 (search-forward (concat "\n" osubfile ": "))
|
|
1775 (beginning-of-line)
|
|
1776 (while (not (eobp))
|
|
1777 (re-search-forward "\\(^.*\\): [0-9]+$")
|
|
1778 (goto-char (+ (match-end 1) 2))
|
|
1779 (setq list (cons (cons (read (current-buffer))
|
444
|
1780 (buffer-substring
|
|
1781 (match-beginning 1)
|
|
1782 (match-end 1)))
|
442
|
1783 list))
|
|
1784 (goto-char (1+ (match-end 0))))
|
|
1785 (setq list (nreverse list)
|
|
1786 list (cdr list))))
|
428
|
1787 (while list
|
|
1788 (message "Searching subfile %s..." (cdr (car list)))
|
|
1789 (Info-read-subfile (car (car list)))
|
|
1790 (setq list (cdr list))
|
|
1791 (goto-char (point-min))
|
|
1792 (if (re-search-forward regexp nil t)
|
|
1793 (setq found (point) list ())))
|
|
1794 (if found
|
|
1795 (message "")
|
|
1796 (signal 'search-failed (list regexp))))
|
|
1797 (if (not found)
|
|
1798 (progn (Info-read-subfile opoint)
|
|
1799 (goto-char opoint)
|
|
1800 (Info-select-node)))))
|
|
1801 (widen)
|
|
1802 (goto-char found)
|
|
1803 (Info-select-node)
|
|
1804 (or (and (equal onode Info-current-node)
|
|
1805 (equal ofile Info-current-file))
|
502
|
1806 (Info-history-add ofile onode opoint))))
|
|
1807 (message "Found \"%s\" in %s. Press `z' to continue search."
|
|
1808 regexp Info-current-node)
|
|
1809 )
|
|
1810
|
|
1811 (defun Info-search-next ()
|
|
1812 "Repeat search starting from point with last regexp used in `Info-search'."
|
|
1813 (interactive)
|
|
1814 (Info-search Info-last-search))
|
|
1815
|
428
|
1816
|
|
1817 ;; Extract the value of the node-pointer named NAME.
|
442
|
1818 ;; If there is none, use ERRORNAME in the error message;
|
428
|
1819 ;; if ERRORNAME is nil, just return nil.
|
|
1820 (defun Info-extract-pointer (name &optional errorname)
|
|
1821 (save-excursion
|
|
1822 (goto-char (point-min))
|
|
1823 (forward-line 4)
|
|
1824 (let ((case-fold-search t))
|
|
1825 (if (re-search-backward (concat name ":") nil t)
|
|
1826 (progn
|
|
1827 (goto-char (match-end 0))
|
|
1828 (Info-following-node-name))
|
|
1829 (if (eq errorname t)
|
|
1830 nil
|
|
1831 (error (concat "Node has no " (capitalize (or errorname name)))))))))
|
|
1832
|
|
1833 ;; Return the node name in the buffer following point.
|
|
1834 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
|
440
|
1835 ;; saying which chars may appear in the node name.
|
428
|
1836 (defun Info-following-node-name (&optional allowedchars)
|
|
1837 (skip-chars-forward " \t")
|
|
1838 (buffer-substring
|
|
1839 (point)
|
|
1840 (progn
|
|
1841 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
|
|
1842 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
|
|
1843 (if (looking-at "(")
|
|
1844 (skip-chars-forward "^)")))
|
438
|
1845 (skip-chars-backward " .")
|
428
|
1846 (point))))
|
|
1847
|
|
1848 (defun Info-next (&optional n)
|
|
1849 "Go to the next node of this node.
|
|
1850 A positive or negative prefix argument moves by multiple nodes."
|
|
1851 (interactive "p")
|
|
1852 (or n (setq n 1))
|
|
1853 (if (< n 0)
|
|
1854 (Info-prev (- n))
|
|
1855 (while (>= (setq n (1- n)) 0)
|
|
1856 (Info-goto-node (Info-extract-pointer "next")))))
|
|
1857
|
|
1858 (defun Info-prev (&optional n)
|
|
1859 "Go to the previous node of this node.
|
|
1860 A positive or negative prefix argument moves by multiple nodes."
|
|
1861 (interactive "p")
|
|
1862 (or n (setq n 1))
|
|
1863 (if (< n 0)
|
|
1864 (Info-next (- n))
|
|
1865 (while (>= (setq n (1- n)) 0)
|
|
1866 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))))
|
|
1867
|
|
1868 (defun Info-up (&optional n)
|
|
1869 "Go to the superior node of this node.
|
|
1870 A positive prefix argument moves up several times."
|
|
1871 (interactive "p")
|
|
1872 (or n (setq n 1))
|
|
1873 (while (>= (setq n (1- n)) 0)
|
|
1874 (Info-goto-node (Info-extract-pointer "up")))
|
|
1875 (if (interactive-p) (Info-restore-point)))
|
|
1876
|
|
1877 (defun Info-last (&optional n)
|
|
1878 "Go back to the last node visited.
|
|
1879 With a prefix argument, go to Nth most recently visited node. History is
|
|
1880 circular; after oldest node, history comes back around to most recent one.
|
|
1881 Argument can be negative to go through the circle in the other direction.
|
|
1882 \(In other words, `l' is like \"undo\" and `C-u - l' is like \"redo\".)"
|
|
1883 (interactive "p")
|
|
1884 (or n (setq n 1))
|
|
1885 (or Info-history
|
|
1886 (error "This is the first Info node you looked at"))
|
|
1887 (let ((len (1+ (length Info-history))))
|
|
1888 (setq n (% (+ n (* len 100)) len)))
|
|
1889 (if (> n 0)
|
|
1890 (let ((entry (nth (1- n) Info-history)))
|
|
1891 (Info-history-add Info-current-file Info-current-node (point))
|
|
1892 (while (>= (setq n (1- n)) 0)
|
|
1893 (setq Info-history (nconc (cdr Info-history)
|
|
1894 (list (car Info-history)))))
|
|
1895 (setq Info-history (cdr Info-history))
|
|
1896 (let ((Info-keeping-history nil))
|
|
1897 (Info-goto-node (car entry)))
|
|
1898 (Info-restore-history-entry entry))))
|
|
1899
|
|
1900 (defun Info-directory ()
|
|
1901 "Go to the Info directory node."
|
|
1902 (interactive)
|
|
1903 (Info-find-node "dir" "top"))
|
|
1904
|
|
1905 (defun Info-follow-reference (footnotename)
|
|
1906 "Follow cross reference named NAME to the node it refers to.
|
|
1907 NAME may be an abbreviation of the reference name."
|
|
1908 (interactive
|
|
1909 (let ((completion-ignore-case t)
|
|
1910 completions default (start-point (point)) str i)
|
|
1911 (save-excursion
|
|
1912 (goto-char (point-min))
|
|
1913 (while (re-search-forward (format "\\*%s[ \n\t]*\\([^:]*\\):"
|
|
1914 Info-footnote-tag)
|
|
1915 nil t)
|
|
1916 (setq str (buffer-substring
|
|
1917 (match-beginning 1)
|
|
1918 (1- (point))))
|
|
1919 ;; See if this one should be the default.
|
|
1920 (and (null default)
|
|
1921 (< (match-beginning 0) start-point)
|
|
1922 (<= start-point (point))
|
|
1923 (setq default t))
|
|
1924 (setq i 0)
|
|
1925 (while (setq i (string-match "[ \n\t]+" str i))
|
|
1926 (setq str (concat (substring str 0 i) " "
|
|
1927 (substring str (match-end 0))))
|
|
1928 (setq i (1+ i)))
|
|
1929 ;; Record as a completion and perhaps as default.
|
|
1930 (if (eq default t) (setq default str))
|
|
1931 (setq completions
|
|
1932 (cons (cons str nil)
|
|
1933 completions))))
|
|
1934 (if completions
|
|
1935 (let ((item (completing-read (if default
|
|
1936 (concat "Follow reference named: ("
|
|
1937 default ") ")
|
|
1938 "Follow reference named: ")
|
|
1939 completions nil t nil
|
438
|
1940 'Info-minibuffer-history
|
|
1941 default)))
|
428
|
1942 (if (and (string= item "") default)
|
|
1943 (list default)
|
|
1944 (list item)))
|
|
1945 (error "No cross-references in this node"))))
|
|
1946 (let (target i (str (concat "\\*" Info-footnote-tag " "
|
|
1947 (regexp-quote footnotename))))
|
|
1948 (while (setq i (string-match " " str i))
|
|
1949 (setq str (concat (substring str 0 i) "\\([ \t\n]+\\)"
|
|
1950 (substring str (1+ i))))
|
|
1951 (setq i (+ i 10)))
|
|
1952 (save-excursion
|
|
1953 (goto-char (point-min))
|
|
1954 (or (re-search-forward str nil t)
|
|
1955 (error "No cross-reference named %s" footnotename))
|
|
1956 (goto-char (match-end 1))
|
|
1957 (setq target
|
|
1958 (Info-extract-menu-node-name "Bad format cross reference" t)))
|
|
1959 (while (setq i (string-match "[ \t\n]+" target i))
|
|
1960 (setq target (concat (substring target 0 i) " "
|
|
1961 (substring target (match-end 0))))
|
|
1962 (setq i (+ i 1)))
|
|
1963 (Info-goto-node target)
|
|
1964 (setq Info-in-cross-reference t)))
|
|
1965
|
|
1966 (defun Info-next-reference (n)
|
|
1967 (interactive "p")
|
|
1968 (let ((pat (format "\\*%s[ \n\t]*\\([^:]*\\):\\|^\\* .*:\\|<<.*>>"
|
|
1969 Info-footnote-tag))
|
|
1970 (old-pt (point))
|
|
1971 wrapped found-nomenu)
|
|
1972 (while (< n 0)
|
|
1973 (unless (re-search-backward pat nil t)
|
|
1974 ;; Don't wrap more than once in a buffer where only the
|
|
1975 ;; menu references are found.
|
|
1976 (when (and wrapped (not found-nomenu))
|
|
1977 (goto-char old-pt)
|
|
1978 (error "No cross references in this node"))
|
|
1979 (setq wrapped t)
|
|
1980 (goto-char (point-max))
|
|
1981 (unless (re-search-backward pat nil t)
|
|
1982 (goto-char old-pt)
|
|
1983 (error "No cross references in this node")))
|
|
1984 (unless (save-excursion
|
|
1985 (goto-char (match-beginning 0))
|
|
1986 (when (looking-at "\\* Menu:")
|
|
1987 (decf n)))
|
|
1988 (setq found-nomenu t))
|
|
1989 (incf n))
|
|
1990 (while (> n 0)
|
|
1991 (or (eobp) (forward-char 1))
|
|
1992 (unless (re-search-forward pat nil t)
|
|
1993 (when (and wrapped (not found-nomenu))
|
|
1994 (goto-char old-pt)
|
|
1995 (error "No cross references in this node"))
|
|
1996 (setq wrapped t)
|
|
1997 (goto-char (point-min))
|
|
1998 (unless (re-search-forward pat nil t)
|
|
1999 (goto-char old-pt)
|
|
2000 (error "No cross references in this node")))
|
|
2001 (unless (save-excursion
|
|
2002 (goto-char (match-beginning 0))
|
|
2003 (when (looking-at "\\* Menu:")
|
|
2004 (incf n)))
|
|
2005 (setq found-nomenu t))
|
|
2006 (decf n))
|
|
2007 (when (looking-at "\\* Menu:")
|
|
2008 (error "No cross references in this node"))
|
|
2009 (goto-char (match-beginning 0))))
|
|
2010
|
|
2011 (defun Info-prev-reference (n)
|
|
2012 (interactive "p")
|
|
2013 (Info-next-reference (- n)))
|
|
2014
|
|
2015 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
|
|
2016 (skip-chars-forward " \t\n")
|
444
|
2017 (let ((start (point))
|
428
|
2018 str i)
|
|
2019 (skip-chars-forward "^:")
|
|
2020 (forward-char 1)
|
|
2021 (setq str
|
|
2022 (if (looking-at ":")
|
444
|
2023 (buffer-substring start (1- (point)))
|
428
|
2024 (skip-chars-forward " \t\n")
|
438
|
2025 ;; Kludge.
|
|
2026 ;; Allow dots in node name not followed by whitespace.
|
|
2027 (re-search-forward
|
446
|
2028 (concat "\\(([^)]+)[^.,"
|
438
|
2029 (if multi-line "" "\n")
|
|
2030 "]*\\|\\([^.,\t"
|
|
2031 (if multi-line "" "\n")
|
|
2032 ;; We consider dots followed by newline as
|
|
2033 ;; end of nodename even if multil-line.
|
|
2034 ;; Also stops at .). It is generated by @pxref.
|
|
2035 ;; Skips sequential dots.
|
|
2036 "]\\|\\.+[^ \t\n)]\\)+\\)"))
|
|
2037 (match-string 1)))
|
428
|
2038 (while (setq i (string-match "\n" str i))
|
|
2039 (aset str i ?\ ))
|
|
2040 str))
|
|
2041
|
|
2042 (defun Info-menu (menu-item)
|
|
2043 "Go to node for menu item named (or abbreviated) NAME.
|
|
2044 Completion is allowed, and the menu item point is on is the default."
|
|
2045 (interactive
|
|
2046 (let ((completions '())
|
|
2047 ;; If point is within a menu item, use that item as the default
|
|
2048 (default nil)
|
|
2049 (p (point))
|
|
2050 (last nil))
|
|
2051 (save-excursion
|
|
2052 (goto-char (point-min))
|
|
2053 (let ((case-fold-search t))
|
|
2054 (if (not (search-forward "\n* menu:" nil t))
|
|
2055 (error "No menu in this node")))
|
|
2056 (while (re-search-forward
|
|
2057 "\n\\* \\([^:\t\n]*\\):" nil t)
|
|
2058 (if (and (null default)
|
|
2059 (prog1 (if last (< last p) nil)
|
|
2060 (setq last (match-beginning 0)))
|
|
2061 (<= p last))
|
|
2062 (setq default (car (car completions))))
|
|
2063 (setq completions (cons (cons (buffer-substring
|
|
2064 (match-beginning 1)
|
|
2065 (match-end 1))
|
|
2066 (match-beginning 1))
|
|
2067 completions)))
|
|
2068 (if (and (null default) last
|
|
2069 (< last p)
|
|
2070 (<= p (progn (end-of-line) (point))))
|
|
2071 (setq default (car (car completions)))))
|
|
2072 (let ((item nil))
|
|
2073 (while (null item)
|
|
2074 (setq item (let ((completion-ignore-case t))
|
|
2075 (completing-read (if default
|
|
2076 (format "Menu item (default %s): "
|
|
2077 default)
|
|
2078 "Menu item: ")
|
|
2079 completions nil t nil
|
438
|
2080 'Info-minibuffer-history
|
|
2081 default)))
|
428
|
2082 ;; we rely on the fact that completing-read accepts an input
|
|
2083 ;; of "" even when the require-match argument is true and ""
|
|
2084 ;; is not a valid possibility
|
|
2085 (if (string= item "")
|
|
2086 (if default
|
|
2087 (setq item default)
|
|
2088 ;; ask again
|
|
2089 (setq item nil))))
|
|
2090 (list item))))
|
|
2091 ;; there is a problem here in that if several menu items have the same
|
|
2092 ;; name you can only go to the node of the first with this command.
|
|
2093 (Info-goto-node (Info-extract-menu-item menu-item) nil t))
|
442
|
2094
|
428
|
2095 (defun Info-extract-menu-item (menu-item &optional noerror)
|
|
2096 (save-excursion
|
|
2097 (goto-char (point-min))
|
|
2098 (if (let ((case-fold-search t))
|
|
2099 (search-forward "\n* menu:" nil t))
|
|
2100 (if (or (search-forward (concat "\n* " menu-item ":") nil t)
|
|
2101 (search-forward (concat "\n* " menu-item) nil t))
|
|
2102 (progn
|
|
2103 (beginning-of-line)
|
|
2104 (forward-char 2)
|
|
2105 (Info-extract-menu-node-name))
|
|
2106 (and (not noerror) (error "No such item in menu")))
|
|
2107 (and (not noerror) (error "No menu in this node")))))
|
|
2108
|
|
2109 ;; If COUNT is nil, use the last item in the menu.
|
|
2110 (defun Info-extract-menu-counting (count &optional noerror noindex)
|
|
2111 (save-excursion
|
|
2112 (goto-char (point-min))
|
|
2113 (if (let ((case-fold-search t))
|
|
2114 (and (search-forward "\n* menu:" nil t)
|
|
2115 (or (not noindex)
|
|
2116 (not (string-match "\\<Index\\>" Info-current-node)))))
|
|
2117 (if (search-forward "\n* " nil t count)
|
|
2118 (progn
|
|
2119 (or count
|
|
2120 (while (search-forward "\n* " nil t)))
|
|
2121 (Info-extract-menu-node-name))
|
|
2122 (and (not noerror) (error "Too few items in menu")))
|
|
2123 (and (not noerror) (error "No menu in this node")))))
|
|
2124
|
|
2125 (defun Info-nth-menu-item (n)
|
|
2126 "Go to the node of the Nth menu item."
|
|
2127 (interactive "P")
|
|
2128 (or n (setq n (- last-command-char ?0)))
|
|
2129 (if (< n 1) (error "Index must be at least 1"))
|
|
2130 (Info-goto-node (Info-extract-menu-counting n) nil t))
|
|
2131
|
|
2132 (defun Info-last-menu-item ()
|
|
2133 "Go to the node of the tenth menu item."
|
|
2134 (interactive)
|
|
2135 (Info-goto-node (Info-extract-menu-counting nil) nil t))
|
|
2136
|
|
2137 (defun Info-top ()
|
|
2138 "Go to the Top node of this file."
|
|
2139 (interactive)
|
|
2140 (Info-goto-node "Top"))
|
|
2141
|
|
2142 (defun Info-end ()
|
|
2143 "Go to the final node in this file."
|
|
2144 (interactive)
|
|
2145 (Info-top)
|
|
2146 (let ((Info-keeping-history nil)
|
|
2147 node)
|
|
2148 (Info-last-menu-item)
|
|
2149 (while (setq node (or (Info-extract-pointer "next" t)
|
|
2150 (Info-extract-menu-counting nil t t)))
|
|
2151 (Info-goto-node node))
|
|
2152 (or (equal (Info-extract-pointer "up" t) "Top")
|
|
2153 (let ((executing-kbd-macro "")) ; suppress messages
|
|
2154 (condition-case nil
|
|
2155 (Info-global-next 10000)
|
|
2156 (error nil))))))
|
|
2157
|
|
2158 (defun Info-global-next (&optional n)
|
|
2159 "Go to the next node in this file, traversing node structure as necessary.
|
|
2160 This works only if the Info file is structured as a hierarchy of nodes.
|
|
2161 A positive or negative prefix argument moves by multiple nodes."
|
|
2162 (interactive "p")
|
|
2163 (or n (setq n 1))
|
|
2164 (if (< n 0)
|
|
2165 (Info-global-prev (- n))
|
|
2166 (while (>= (setq n (1- n)) 0)
|
|
2167 (let (node)
|
|
2168 (cond ((and (string-match "^Top$" Info-current-node)
|
|
2169 (setq node (Info-extract-pointer "next" t))
|
|
2170 (Info-extract-menu-item node t))
|
|
2171 (Info-goto-node node))
|
|
2172 ((setq node (Info-extract-menu-counting 1 t t))
|
|
2173 (message "Going down...")
|
|
2174 (Info-goto-node node))
|
|
2175 (t
|
|
2176 (let ((Info-keeping-history Info-keeping-history)
|
|
2177 (orignode Info-current-node)
|
|
2178 (ups ""))
|
|
2179 (while (not (Info-extract-pointer "next" t))
|
|
2180 (if (and (setq node (Info-extract-pointer "up" t))
|
|
2181 (not (equal node "Top")))
|
|
2182 (progn
|
|
2183 (message "Going%s..." (setq ups (concat ups " up")))
|
|
2184 (Info-goto-node node)
|
|
2185 (setq Info-keeping-history nil))
|
|
2186 (if orignode
|
|
2187 (let ((Info-keeping-history nil))
|
|
2188 (Info-goto-node orignode)))
|
|
2189 (error "Last node in file")))
|
|
2190 (Info-next))))))))
|
|
2191
|
|
2192 (defun Info-page-next (&optional n)
|
|
2193 "Scroll forward one screenful, or go to next global node.
|
|
2194 A positive or negative prefix argument moves by multiple screenfuls."
|
|
2195 (interactive "p")
|
|
2196 (or n (setq n 1))
|
|
2197 (if (< n 0)
|
|
2198 (Info-page-prev (- n))
|
|
2199 (while (>= (setq n (1- n)) 0)
|
|
2200 (if (pos-visible-in-window-p (point-max))
|
|
2201 (progn
|
|
2202 (Info-global-next)
|
|
2203 (message "Node: %s" Info-current-node))
|
|
2204 (scroll-up)))))
|
|
2205
|
|
2206 (defun Info-scroll-next (arg)
|
|
2207 (interactive "P")
|
|
2208 (if Info-auto-advance
|
|
2209 (if (and (pos-visible-in-window-p (point-max))
|
|
2210 (not (eq Info-auto-advance t))
|
|
2211 (not (eq last-command this-command)))
|
|
2212 (message "Hit %s again to go to next node"
|
|
2213 (if (= last-command-char 0)
|
|
2214 "mouse button"
|
|
2215 (key-description (char-to-string last-command-char))))
|
|
2216 (Info-page-next)
|
|
2217 (setq this-command 'Info))
|
|
2218 (scroll-up arg)))
|
|
2219
|
|
2220 (defun Info-global-prev (&optional n)
|
|
2221 "Go to the previous node in this file, traversing structure as necessary.
|
|
2222 This works only if the Info file is structured as a hierarchy of nodes.
|
|
2223 A positive or negative prefix argument moves by multiple nodes."
|
|
2224 (interactive "p")
|
|
2225 (or n (setq n 1))
|
|
2226 (if (< n 0)
|
|
2227 (Info-global-next (- n))
|
|
2228 (while (>= (setq n (1- n)) 0)
|
|
2229 (let ((upnode (Info-extract-pointer "up" t))
|
|
2230 (prevnode (Info-extract-pointer "prev[ious]*" t)))
|
|
2231 (if (or (not prevnode)
|
|
2232 (equal prevnode upnode))
|
|
2233 (if (string-match "^Top$" Info-current-node)
|
|
2234 (error "First node in file")
|
|
2235 (message "Going up...")
|
|
2236 (Info-up))
|
|
2237 (Info-goto-node prevnode)
|
|
2238 (let ((downs "")
|
|
2239 (Info-keeping-history nil)
|
|
2240 node)
|
|
2241 (while (setq node (Info-extract-menu-counting nil t t))
|
|
2242 (message "Going%s..." (setq downs (concat downs " down")))
|
|
2243 (Info-goto-node node))))))))
|
|
2244
|
|
2245 (defun Info-page-prev (&optional n)
|
|
2246 "Scroll backward one screenful, or go to previous global node.
|
|
2247 A positive or negative prefix argument moves by multiple screenfuls."
|
|
2248 (interactive "p")
|
|
2249 (or n (setq n 1))
|
|
2250 (if (< n 0)
|
|
2251 (Info-page-next (- n))
|
|
2252 (while (>= (setq n (1- n)) 0)
|
|
2253 (if (pos-visible-in-window-p (point-min))
|
|
2254 (progn
|
|
2255 (Info-global-prev)
|
|
2256 (message "Node: %s" Info-current-node)
|
|
2257 (goto-char (point-max))
|
|
2258 (recenter -1)
|
|
2259 (move-to-window-line 0))
|
|
2260 (scroll-down)))))
|
|
2261
|
|
2262 (defun Info-scroll-prev (arg)
|
|
2263 (interactive "P")
|
|
2264 (if Info-auto-advance
|
|
2265 (if (and (pos-visible-in-window-p (point-min))
|
|
2266 (not (eq Info-auto-advance t))
|
|
2267 (not (eq last-command this-command)))
|
|
2268 (message "Hit %s again to go to previous node"
|
|
2269 (if (mouse-event-p last-command-event)
|
|
2270 "mouse button"
|
|
2271 (key-description (event-key last-command-event))))
|
|
2272 (Info-page-prev)
|
|
2273 (setq this-command 'Info))
|
|
2274 (scroll-down arg)))
|
502
|
2275
|
428
|
2276
|
502
|
2277 (defun Info-find-index-alternatives (topic)
|
428
|
2278 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
|
|
2279 (regexp-quote topic)
|
438
|
2280 "\\(.*\\)\\.[ t]*\\([0-9]*\\)$"))
|
428
|
2281 node)
|
|
2282 (message "Searching index for `%s'..." topic)
|
|
2283 (Info-goto-node "Top")
|
|
2284 (let ((case-fold-search t))
|
|
2285 (or (search-forward "\n* menu:" nil t)
|
|
2286 (error "No index"))
|
|
2287 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
|
|
2288 (error "No index")))
|
|
2289 (goto-char (match-beginning 1))
|
|
2290 (let ((Info-keeping-history nil)
|
|
2291 (Info-fontify (and Info-fontify (equal topic ""))))
|
|
2292 (Info-goto-node (Info-extract-menu-node-name)))
|
|
2293 (or (equal topic "")
|
|
2294 (let ((matches nil)
|
502
|
2295 (Info-keeping-history nil))
|
428
|
2296 (while
|
|
2297 (progn
|
|
2298 (goto-char (point-min))
|
|
2299 (while (re-search-forward pattern nil t)
|
|
2300 (setq matches
|
|
2301 (cons (list (buffer-substring (match-beginning 1)
|
|
2302 (match-end 1))
|
771
|
2303 (format "(%s)%s" Info-current-file
|
|
2304 (buffer-substring
|
|
2305 (match-beginning 2)
|
|
2306 (match-end 2)))
|
428
|
2307 Info-current-node
|
|
2308 (string-to-int (concat "0"
|
|
2309 (buffer-substring
|
|
2310 (match-beginning 3)
|
|
2311 (match-end 3)))))
|
|
2312 matches)))
|
|
2313 (and (setq node (Info-extract-pointer "next" t))
|
|
2314 (string-match "\\<Index\\>" node)))
|
|
2315 (let ((Info-fontify nil))
|
|
2316 (Info-goto-node node)))
|
502
|
2317 (nreverse matches)))))
|
|
2318
|
|
2319 (defun Info-index (topic &optional starting-nodes)
|
|
2320 "Look up a string in the index for this file.
|
|
2321 The index is defined as the first node in the top-level menu whose
|
|
2322 name contains the word \"Index\", plus any immediately following
|
|
2323 nodes whose names also contain the word \"Index\".
|
|
2324 If there are no exact matches to the specified topic, this chooses
|
|
2325 the first match which is a case-insensitive substring of a topic.
|
|
2326 Use the `,' command to see the other matches.
|
|
2327 Give a blank topic name to go to the Index node itself.
|
|
2328
|
|
2329 If STARTING-NODES is given, it should be a list of nodes specifying
|
|
2330 files in which the indices will be searched. The results will be
|
|
2331 combined together."
|
|
2332 (interactive "sIndex topic: ")
|
|
2333 (let ((matches (if starting-nodes
|
|
2334 (mapcan #'(lambda (node)
|
|
2335 (Info-goto-node node)
|
|
2336 (Info-find-index-alternatives topic))
|
|
2337 starting-nodes)
|
|
2338 (Info-find-index-alternatives topic)))
|
|
2339 exact found)
|
|
2340 (or matches
|
|
2341 (progn
|
|
2342 (if (or (not starting-nodes) (< (length starting-nodes) 2))
|
|
2343 (Info-last))
|
|
2344 (error "No \"%s\" in index" topic)))
|
|
2345 ;; Here it is a feature that assoc is case-sensitive.
|
|
2346 (while (setq found (assoc topic matches))
|
|
2347 (setq exact (cons found exact)
|
|
2348 matches (delq found matches)))
|
|
2349 (setq Info-index-alternatives (nconc exact matches)
|
|
2350 Info-index-first-alternative (car Info-index-alternatives))
|
|
2351 (Info-index-next 0)))
|
428
|
2352
|
|
2353 (defun Info-index-next (num)
|
|
2354 "Go to the next matching index item from the last `i' command."
|
|
2355 (interactive "p")
|
|
2356 (or Info-index-alternatives
|
|
2357 (error "No previous `i' command in this file"))
|
|
2358 (while (< num 0)
|
|
2359 (setq num (+ num (length Info-index-alternatives))))
|
|
2360 (while (> num 0)
|
|
2361 (setq Info-index-alternatives
|
|
2362 (nconc (cdr Info-index-alternatives)
|
|
2363 (list (car Info-index-alternatives)))
|
|
2364 num (1- num)))
|
|
2365 (Info-goto-node (nth 1 (car Info-index-alternatives)))
|
|
2366 (if (> (nth 3 (car Info-index-alternatives)) 0)
|
|
2367 (forward-line (nth 3 (car Info-index-alternatives)))
|
|
2368 (forward-line 3) ; don't search in headers
|
|
2369 (let ((name (car (car Info-index-alternatives))))
|
|
2370 (if (or (re-search-forward (format
|
|
2371 "\\(Function\\|Command\\): %s\\( \\|$\\)"
|
|
2372 (regexp-quote name)) nil t)
|
|
2373 (re-search-forward (format "^`%s[ ']" (regexp-quote name)) nil t)
|
|
2374 (search-forward (format "`%s'" name) nil t)
|
|
2375 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
|
|
2376 (search-forward
|
|
2377 (format "`%s'" (substring name 0 (match-beginning 1)))
|
|
2378 nil t))
|
|
2379 (search-forward name nil t))
|
|
2380 (beginning-of-line)
|
|
2381 (goto-char (point-min)))))
|
|
2382 (message "Found \"%s\" in %s. %s"
|
|
2383 (car (car Info-index-alternatives))
|
|
2384 (nth 2 (car Info-index-alternatives))
|
|
2385 (if (cdr Info-index-alternatives)
|
|
2386 (if (eq (car (cdr Info-index-alternatives))
|
|
2387 Info-index-first-alternative)
|
|
2388 "(Press `,' to repeat)"
|
|
2389 (format "(Press `,' for %d more)"
|
|
2390 (- (1- (length Info-index-alternatives))
|
|
2391 (length (memq Info-index-first-alternative
|
|
2392 (cdr Info-index-alternatives))))))
|
|
2393 "(Only match)")))
|
|
2394
|
|
2395
|
|
2396 ;;;###autoload
|
|
2397 (defun Info-emacs-command (command)
|
|
2398 "Look up an Emacs command in the Emacs manual in the Info system.
|
|
2399 This command is designed to be used whether you are already in Info or not."
|
|
2400 (interactive "CLook up command in Emacs manual: ")
|
|
2401 (save-window-excursion
|
|
2402 (info)
|
|
2403 (Info-find-node Info-emacs-info-file-name "Top")
|
|
2404 (Info-index (symbol-name command)))
|
|
2405 (pop-to-buffer "*info*"))
|
|
2406
|
|
2407
|
|
2408 ;;;###autoload
|
|
2409 (defun Info-goto-emacs-command-node (key)
|
|
2410 "Look up an Emacs command in the Emacs manual in the Info system.
|
|
2411 This command is designed to be used whether you are already in Info or not."
|
|
2412 (interactive "CLook up command in Emacs manual: ")
|
|
2413 (Info-emacs-command key))
|
|
2414
|
|
2415 ;;;###autoload
|
|
2416 (defun Info-goto-emacs-key-command-node (key)
|
|
2417 "Look up an Emacs key sequence in the Emacs manual in the Info system.
|
|
2418 This command is designed to be used whether you are already in Info or not."
|
|
2419 (interactive "kLook up key in Emacs manual: ")
|
|
2420 (let ((command (key-binding key)))
|
|
2421 (cond ((eq command 'keyboard-quit)
|
|
2422 (keyboard-quit))
|
|
2423 ((null command)
|
|
2424 (error "%s is undefined" (key-description key)))
|
|
2425 ((and (interactive-p) (eq command 'execute-extended-command))
|
|
2426 (call-interactively 'Info-goto-emacs-command-node))
|
|
2427 (t
|
|
2428 (Info-goto-emacs-command-node command)))))
|
|
2429
|
|
2430 ;;;###autoload
|
|
2431 (defun Info-emacs-key (key)
|
|
2432 "Look up an Emacs key sequence in the Emacs manual in the Info system.
|
|
2433 This command is designed to be used whether you are already in Info or not."
|
|
2434 (interactive "kLook up key in Emacs manual: ")
|
|
2435 (cond ((eq (key-binding key) 'keyboard-quit)
|
|
2436 (keyboard-quit))
|
|
2437 ((and (interactive-p) (eq (key-binding key) 'execute-extended-command))
|
|
2438 (call-interactively 'Info-goto-emacs-command-node))
|
|
2439 (t
|
|
2440 (save-window-excursion
|
|
2441 (info)
|
|
2442 (Info-find-node Info-emacs-info-file-name "Top")
|
|
2443 (setq key (key-description key))
|
|
2444 (let (p)
|
|
2445 (if (setq p (string-match "[@{}]" key))
|
|
2446 (setq key (concat (substring key 0 p) "@" (substring key p))))
|
|
2447 (if (string-match "^ESC " key)
|
|
2448 (setq key (concat "M-" (substring key 4))))
|
|
2449 (if (string-match "^M-C-" key)
|
|
2450 (setq key (concat "C-M-" (substring key 4)))))
|
|
2451 (Info-index key))
|
|
2452 (pop-to-buffer "*info*"))))
|
|
2453
|
|
2454 ;;;###autoload
|
|
2455 (defun Info-elisp-ref (func)
|
|
2456 "Look up an Emacs Lisp function in the Elisp manual in the Info system.
|
|
2457 This command is designed to be used whether you are already in Info or not."
|
|
2458 (interactive (let ((fn (function-at-point))
|
442
|
2459 (enable-recursive-minibuffers t)
|
428
|
2460 val)
|
|
2461 (setq val (completing-read
|
|
2462 (format "Look up Emacs Lisp function%s: "
|
|
2463 (if fn
|
|
2464 (format " (default %s)" fn)
|
|
2465 ""))
|
456
|
2466 obarray 'fboundp t
|
|
2467 nil nil (and fn (symbol-name fn))))
|
428
|
2468 (list (if (equal val "")
|
|
2469 fn (intern val)))))
|
|
2470 (save-window-excursion
|
|
2471 (info)
|
|
2472 (condition-case nil
|
|
2473 (Info-find-node "lispref" "Top")
|
|
2474 (error (Info-find-node "elisp" "Top")))
|
|
2475 (Info-index (symbol-name func)))
|
|
2476 (pop-to-buffer "*info*"))
|
502
|
2477
|
|
2478 (defun Info-read-search-text-regexp ()
|
|
2479 (read-from-minibuffer
|
|
2480 (if (and (boundp 'Info-last-search) Info-last-search)
|
|
2481 (format "Search (regexp, default %s): "
|
|
2482 Info-last-search)
|
|
2483 "Search (regexp): ")
|
|
2484 nil nil nil nil nil (and (boundp 'Info-last-search) Info-last-search)))
|
|
2485
|
|
2486 ;;;###autoload
|
|
2487 (defun Info-search-text-in-lispref (regexp)
|
|
2488 "Search for REGEXP in Lispref text and select node it's found in."
|
|
2489 (interactive (list (Info-read-search-text-regexp)))
|
|
2490 (Info-goto-node "(Lispref)")
|
|
2491 (Info-search regexp))
|
|
2492
|
|
2493 ;;;###autoload
|
|
2494 (defun Info-search-text-in-xemacs (regexp)
|
|
2495 "Search for REGEXP in User's Manual text and select node it's found in."
|
|
2496 (interactive (list (Info-read-search-text-regexp)))
|
|
2497 (Info-goto-node "(XEmacs)")
|
|
2498 (Info-search regexp))
|
|
2499
|
|
2500 ;;;###autoload
|
|
2501 (defun Info-search-index-in-lispref (regexp)
|
|
2502 "Search for REGEXP in Lispref index and select node it's found in."
|
|
2503 (interactive "sIndex topic: ")
|
|
2504 (Info-goto-node "(Lispref)")
|
|
2505 (Info-index regexp))
|
|
2506
|
|
2507 ;;;###autoload
|
|
2508 (defun Info-search-index-in-xemacs-and-lispref (regexp)
|
|
2509 "Search for REGEXP in both User's Manual and Lispref indices.
|
|
2510 Select node it's found in."
|
|
2511 (interactive "sIndex topic: ")
|
|
2512 (Info-index regexp '("(XEmacs)" "(Lispref)")))
|
|
2513
|
428
|
2514
|
|
2515 (defun Info-reannotate-node ()
|
|
2516 (let ((bufs (delq nil (mapcar 'get-file-buffer Info-annotations-path))))
|
|
2517 (if bufs
|
|
2518 (let ((ibuf (current-buffer))
|
|
2519 (file (concat "\\(" (regexp-quote
|
|
2520 (file-name-nondirectory Info-current-file))
|
|
2521 "\\|" (regexp-quote Info-current-file) "\\)"))
|
|
2522 (node (regexp-quote Info-current-node))
|
|
2523 (savept (point)))
|
|
2524 (goto-char (point-min))
|
|
2525 (if (search-forward "\n------ NOTE:\n" nil t)
|
|
2526 (let ((buffer-read-only nil)
|
|
2527 (bufmod (buffer-modified-p))
|
|
2528 top)
|
|
2529 (setq savept (copy-marker savept))
|
|
2530 (goto-char (point-min))
|
|
2531 (while (search-forward "\n------ NOTE:" nil t)
|
|
2532 (setq top (1+ (match-beginning 0)))
|
|
2533 (if (search-forward "\n------\n" nil t)
|
|
2534 (delete-region top (point)))
|
|
2535 (backward-char 1))
|
|
2536 (set-buffer-modified-p bufmod)))
|
|
2537 (save-excursion
|
|
2538 (while bufs
|
|
2539 (set-buffer (car bufs))
|
|
2540 (goto-char (point-min))
|
|
2541 (while (re-search-forward
|
|
2542 (format
|
|
2543 "------ *File: *%s *Node: *%s *Line: *\\([0-9]+\\) *\n"
|
|
2544 file node)
|
|
2545 nil t)
|
|
2546 (let ((line (string-to-int
|
|
2547 (buffer-substring (match-beginning 2)
|
|
2548 (match-end 2))))
|
|
2549 (top (point))
|
|
2550 bot)
|
|
2551 (search-forward "\n------\n" nil t)
|
|
2552 (setq bot (point))
|
|
2553 (save-excursion
|
|
2554 (set-buffer ibuf)
|
|
2555 (if (integerp savept) (setq savept (copy-marker savept)))
|
|
2556 (if (= line 0)
|
|
2557 (goto-char (point-max))
|
|
2558 (goto-char (point-min))
|
|
2559 (forward-line line))
|
|
2560 (let ((buffer-read-only nil)
|
|
2561 (bufmod (buffer-modified-p)))
|
|
2562 (insert "------ NOTE:\n")
|
|
2563 (insert-buffer-substring (car bufs) top bot)
|
|
2564 (set-buffer-modified-p bufmod)))))
|
|
2565 (setq bufs (cdr bufs))))
|
|
2566 (goto-char savept)))))
|
|
2567
|
|
2568 (defvar Info-annotate-map nil
|
|
2569 "Local keymap used within `a' command of Info.")
|
444
|
2570
|
428
|
2571 (if Info-annotate-map
|
|
2572 nil
|
|
2573 ;; (setq Info-annotate-map (nconc (make-sparse-keymap) text-mode-map))
|
|
2574 (setq Info-annotate-map (copy-keymap text-mode-map))
|
|
2575 (define-key Info-annotate-map "\C-c\C-c" 'Info-cease-annotate))
|
|
2576
|
|
2577 (defun Info-annotate-mode ()
|
|
2578 "Major mode for adding an annotation to an Info node.
|
|
2579 Like text mode with the addition of Info-cease-annotate
|
|
2580 which returns to Info mode for browsing.
|
|
2581 \\{Info-annotate-map}")
|
|
2582
|
|
2583 (defun Info-annotate (arg)
|
|
2584 "Add a personal annotation to the current Info node.
|
|
2585 Only you will be able to see this annotation. Annotations are stored
|
|
2586 in the file \"~/.xemacs/info.notes\" by default. If point is inside
|
|
2587 an existing annotation, edit that annotation. A prefix argument
|
|
2588 specifies which annotations file (from `Info-annotations-path') is to
|
|
2589 be edited; default is 1."
|
|
2590 (interactive "p")
|
|
2591 (setq arg (1- arg))
|
|
2592 (if (or (< arg 0) (not (nth arg Info-annotations-path)))
|
|
2593 (if (= arg 0)
|
|
2594 (setq Info-annotations-path
|
|
2595 (list (read-file-name
|
|
2596 "Annotations file: " "~/" "~/.infonotes")))
|
|
2597 (error "File number must be in the range from 1 to %d"
|
|
2598 (length Info-annotations-path))))
|
|
2599 (let ((which nil)
|
|
2600 (file (file-name-nondirectory Info-current-file))
|
|
2601 (d Info-directory-list)
|
|
2602 where pt)
|
|
2603 (while (and d (not (equal (expand-file-name file (car d))
|
|
2604 Info-current-file)))
|
|
2605 (setq d (cdr d)))
|
|
2606 (or d (setq file Info-current-file))
|
|
2607 (if (and (save-excursion
|
|
2608 (goto-char (min (point-max) (+ (point) 13)))
|
|
2609 (and (search-backward "------ NOTE:\n" nil t)
|
|
2610 (setq pt (match-end 0))
|
|
2611 (search-forward "\n------\n" nil t)))
|
|
2612 (< (point) (match-end 0)))
|
|
2613 (setq which (format "File: *%s *Node: *%s *Line:.*\n%s"
|
|
2614 (regexp-quote file)
|
|
2615 (regexp-quote Info-current-node)
|
|
2616 (regexp-quote
|
|
2617 (buffer-substring pt (match-beginning 0))))
|
|
2618 where (max (- (point) pt) 0)))
|
|
2619 (let ((node Info-current-node)
|
|
2620 (line (if (looking-at "[ \n]*\\'") 0
|
|
2621 (count-lines (point-min) (point)))))
|
|
2622 (or which
|
|
2623 (let ((buffer-read-only nil)
|
|
2624 (bufmod (buffer-modified-p)))
|
|
2625 (beginning-of-line)
|
|
2626 (if (bobp) (goto-char (point-max)))
|
|
2627 (insert "------ NOTE:\n------\n")
|
|
2628 (backward-char 20)
|
|
2629 (set-buffer-modified-p bufmod)))
|
|
2630 ;; (setq Info-window-start (window-start))
|
|
2631 (setq Info-window-configuration (current-window-configuration))
|
|
2632 (pop-to-buffer (find-file-noselect (nth arg Info-annotations-path)))
|
|
2633 (use-local-map Info-annotate-map)
|
|
2634 (setq major-mode 'Info-annotate-mode)
|
|
2635 (setq mode-name "Info Annotate")
|
|
2636 (if which
|
|
2637 (if (save-excursion
|
|
2638 (goto-char (point-min))
|
|
2639 (re-search-forward which nil t))
|
|
2640 (progn
|
|
2641 (goto-char (match-beginning 0))
|
|
2642 (forward-line 1)
|
|
2643 (forward-char where)))
|
|
2644 (let ((bufmod (buffer-modified-p)))
|
|
2645 (goto-char (point-max))
|
|
2646 (insert (format "\n------ File: %s Node: %s Line: %d\n"
|
|
2647 file node line))
|
|
2648 (setq pt (point))
|
|
2649 (insert "\n------\n"
|
|
2650 "\nPress C-c C-c to save and return to Info.\n")
|
|
2651 (goto-char pt)
|
|
2652 (set-buffer-modified-p bufmod))))))
|
|
2653
|
|
2654 (defun Info-cease-annotate ()
|
|
2655 (interactive)
|
|
2656 (let ((bufmod (buffer-modified-p)))
|
|
2657 (while (save-excursion
|
|
2658 (goto-char (point-min))
|
|
2659 (re-search-forward "\n\n?Press .* to save and return to Info.\n"
|
|
2660 nil t))
|
|
2661 (delete-region (1+ (match-beginning 0)) (match-end 0)))
|
|
2662 (while (save-excursion
|
|
2663 (goto-char (point-min))
|
|
2664 (re-search-forward "\n------ File:.*Node:.*Line:.*\n+------\n"
|
|
2665 nil t))
|
|
2666 (delete-region (match-beginning 0) (match-end 0)))
|
|
2667 (set-buffer-modified-p bufmod))
|
|
2668 (save-buffer)
|
|
2669 (fundamental-mode)
|
|
2670 (bury-buffer)
|
|
2671 (or (one-window-p) (delete-window))
|
|
2672 (info)
|
|
2673 (setq Info-current-annotation-completions nil)
|
|
2674 (set-window-configuration Info-window-configuration)
|
|
2675 (Info-reannotate-node))
|
|
2676
|
|
2677 (defun Info-bookmark (arg tag)
|
|
2678 (interactive "p\nsBookmark name: ")
|
|
2679 (Info-annotate arg)
|
|
2680 (if (or (string-match "^\"\\(.*\\)\"$" tag)
|
|
2681 (string-match "^<<\\(.*\\)>>$" tag))
|
|
2682 (setq tag (substring tag (match-beginning 1) (match-end 1))))
|
|
2683 (let ((pt (point)))
|
|
2684 (search-forward "\n------\n")
|
|
2685 (let ((end (- (point) 8)))
|
|
2686 (goto-char pt)
|
|
2687 (if (re-search-forward "<<[^>\n]*>>" nil t)
|
|
2688 (delete-region (match-beginning 0) (match-end 0))
|
|
2689 (goto-char end))
|
|
2690 (or (equal tag "")
|
|
2691 (insert "<<" tag ">>"))))
|
|
2692 (Info-cease-annotate))
|
|
2693
|
|
2694 (defun Info-exit ()
|
|
2695 "Exit Info by selecting some other buffer."
|
|
2696 (interactive)
|
|
2697 (if Info-standalone
|
|
2698 (save-buffers-kill-emacs)
|
|
2699 (bury-buffer (current-buffer))
|
|
2700 (if (and (featurep 'toolbar)
|
|
2701 (boundp 'toolbar-info-frame)
|
|
2702 (eq toolbar-info-frame (selected-frame)))
|
|
2703 (condition-case ()
|
|
2704 (delete-frame toolbar-info-frame)
|
|
2705 (error (bury-buffer)))
|
|
2706 (switch-to-buffer (other-buffer (current-buffer))))))
|
|
2707
|
|
2708 (defun Info-undefined ()
|
|
2709 "Make command be undefined in Info."
|
|
2710 (interactive)
|
|
2711 (ding))
|
|
2712
|
|
2713 (defun Info-help ()
|
|
2714 "Enter the Info tutorial."
|
|
2715 (interactive)
|
|
2716 (delete-other-windows)
|
|
2717 (Info-find-node "info"
|
|
2718 (if (< (window-height) 23)
|
|
2719 "Help-Small-Screen"
|
|
2720 "Help")))
|
|
2721
|
|
2722 (defun Info-summary ()
|
|
2723 "Display a brief summary of all Info commands."
|
|
2724 (interactive)
|
|
2725 (save-window-excursion
|
|
2726 (switch-to-buffer "*Help*")
|
|
2727 (erase-buffer)
|
|
2728 (insert (documentation 'Info-mode))
|
|
2729 (goto-char (point-min))
|
|
2730 (let (flag)
|
|
2731 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
|
|
2732 (message (if flag "Type Space to see more"
|
|
2733 "Type Space to return to Info"))
|
|
2734 (let ((e (next-command-event)))
|
|
2735 (if (/= ?\ (event-to-character e))
|
|
2736 (progn (setq unread-command-event e) nil)
|
|
2737 flag)))
|
|
2738 (scroll-up)))
|
|
2739 (message "")
|
|
2740 (bury-buffer "*Help*")))
|
|
2741
|
|
2742 (defun Info-get-token (pos start all &optional errorstring)
|
|
2743 "Return the token around POS,
|
|
2744 POS must be somewhere inside the token
|
|
2745 START is a regular expression which will match the
|
|
2746 beginning of the tokens delimited string
|
|
2747 ALL is a regular expression with a single
|
|
2748 parenthized subpattern which is the token to be
|
|
2749 returned. E.g. '{\(.*\)}' would return any string
|
|
2750 enclosed in braces around POS.
|
|
2751 SIG optional fourth argument, controls action on no match
|
|
2752 nil: return nil
|
|
2753 t: beep
|
|
2754 a string: signal an error, using that string."
|
|
2755 (save-excursion
|
|
2756 (goto-char (point-min))
|
|
2757 (re-search-backward "\\`") ; Bug fix due to Nicholas J. Foskett.
|
|
2758 (goto-char pos)
|
|
2759 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
|
|
2760 (let (found)
|
|
2761 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
|
|
2762 (not (setq found (and (<= (match-beginning 0) pos)
|
|
2763 (> (match-end 0) pos))))))
|
|
2764 (if (and found (<= (match-beginning 0) pos)
|
|
2765 (> (match-end 0) pos))
|
|
2766 (buffer-substring (match-beginning 1) (match-end 1))
|
|
2767 (cond ((null errorstring)
|
|
2768 nil)
|
|
2769 ((eq errorstring t)
|
|
2770 (beep)
|
|
2771 nil)
|
|
2772 (t
|
|
2773 (error "No %s around position %d" errorstring pos)))))))
|
|
2774
|
|
2775 (defun Info-follow-clicked-node (event)
|
|
2776 "Follow a node reference near clicked point. Like M, F, N, P or U command.
|
|
2777 At end of the node's text, moves to the next node."
|
|
2778 (interactive "@e")
|
|
2779 (or (and (event-point event)
|
|
2780 (Info-follow-nearest-node
|
|
2781 (max (progn
|
|
2782 (select-window (event-window event))
|
|
2783 (event-point event))
|
|
2784 (1+ (point-min)))))
|
|
2785 (error "click on a cross-reference to follow")))
|
|
2786
|
|
2787 (defun Info-maybe-follow-clicked-node (event &optional click-count)
|
|
2788 "Follow a node reference (if any) near clicked point.
|
|
2789 Like M, F, N, P or U command. At end of the node's text, moves to the
|
|
2790 next node. No error is given if there is no node to follow."
|
|
2791 (interactive "@e")
|
|
2792 (and Info-button1-follows-hyperlink
|
|
2793 (event-point event)
|
|
2794 (Info-follow-nearest-node
|
|
2795 (max (progn
|
|
2796 (select-window (event-window event))
|
|
2797 (event-point event))
|
|
2798 (1+ (point-min))))))
|
|
2799
|
|
2800 (defun Info-find-nearest-node (point)
|
|
2801 (let (node)
|
|
2802 (cond
|
|
2803 ((= point (point-min)) nil) ; don't trigger on accidental RET.
|
|
2804 ((setq node (Info-get-token point
|
|
2805 (format "\\*%s[ \n]" Info-footnote-tag)
|
|
2806 (format "\\*%s[ \n]\\([^:]*\\):"
|
|
2807 Info-footnote-tag)))
|
|
2808 (list "Following cross-reference %s..."
|
|
2809 (list 'Info-follow-reference node)))
|
|
2810 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\)::"))
|
|
2811 (list "Selecting menu item %s..."
|
|
2812 (list 'Info-goto-node node nil t)))
|
|
2813 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\):"))
|
|
2814 (list "Selecting menu item %s..."
|
|
2815 (list 'Info-menu node)))
|
|
2816 ((setq node (Info-get-token point "Up: " "Up: \\([^,\n\t]*\\)"))
|
|
2817 (list "Going up..."
|
|
2818 (list 'Info-goto-node node)))
|
|
2819 ((setq node (Info-get-token point "Next: " "Next: \\([^,\n\t]*\\)"))
|
|
2820 (list "Next node..."
|
|
2821 (list 'Info-goto-node node)))
|
|
2822 ((setq node (Info-get-token point "File: " "File: \\([^,\n\t]*\\)"))
|
|
2823 (list "Top node..."
|
|
2824 (list 'Info-goto-node "Top")))
|
|
2825 ((setq node (Info-get-token point "Prev[ious]*: "
|
|
2826 "Prev[ious]*: \\([^,\n\t]*\\)"))
|
|
2827 (list "Previous node..."
|
|
2828 (list 'Info-goto-node node)))
|
|
2829 ((setq node (Info-get-token point "Node: " "Node: \\([^,\n\t]*\\)"))
|
|
2830 (list "Reselecting %s..."
|
|
2831 (list 'Info-goto-node node)))
|
|
2832 ((save-excursion (goto-char point) (looking-at "[ \n]*\\'"))
|
|
2833 (if Info-in-cross-reference
|
|
2834 (list "Back to last node..."
|
|
2835 '(Info-last))
|
|
2836 (list "Next node..."
|
|
2837 '(Info-global-next)))))
|
|
2838 ))
|
|
2839
|
|
2840 (defun Info-follow-nearest-node (point)
|
|
2841 "Follow a node reference near point. Like M, F, N, P or U command.
|
|
2842 At end of the node's text, moves to the next node."
|
|
2843 (interactive "d")
|
|
2844 (let ((data (Info-find-nearest-node point)))
|
|
2845 (if (null data)
|
|
2846 nil
|
|
2847 (let ((msg (format (car data) (nth 1 (nth 1 data)))))
|
|
2848 (message "%s" msg)
|
|
2849 (eval (nth 1 data))
|
|
2850 (message "%sdone" msg))
|
|
2851 t)))
|
|
2852
|
|
2853 (defun Info-indicated-node (event)
|
|
2854 (condition-case ()
|
|
2855 (save-excursion
|
|
2856 (cond ((eventp event)
|
|
2857 (set-buffer (event-buffer event))
|
|
2858 (setq event (event-point event))))
|
|
2859 (let* ((data (Info-find-nearest-node event))
|
|
2860 (name (nth 1 (nth 1 data))))
|
|
2861 (and name (nth 1 data))))
|
|
2862 (error nil)))
|
|
2863
|
|
2864 (defun Info-mouse-track-double-click-hook (event click-count)
|
|
2865 "Handle double-clicks by turning pages, like the `gv' ghostscript viewer"
|
|
2866 (if (/= click-count 2)
|
|
2867 ;; Return nil so any other hooks are performed.
|
|
2868 nil
|
|
2869 (let* ((fw (face-width 'default))
|
|
2870 (fh (face-height 'default))
|
|
2871 (x (/ (event-x-pixel event) fw))
|
|
2872 (y (/ (event-y-pixel event) fw))
|
|
2873 (w (/ (window-pixel-width (event-window event)) fw))
|
|
2874 (h (/ (window-pixel-height (event-window event)) fh))
|
|
2875 (bx 3)
|
|
2876 (by 2))
|
|
2877 (cond
|
|
2878 ((<= y by) (Info-up) t)
|
|
2879 ((>= y (- h by)) (Info-nth-menu-item 1) t)
|
|
2880 ((<= x bx) (Info-prev) t)
|
|
2881 ((>= x (- w bx)) (Info-next) t)
|
|
2882 (t nil)))))
|
|
2883
|
|
2884 (defvar Info-mode-map nil
|
|
2885 "Keymap containing Info commands.")
|
444
|
2886
|
428
|
2887 (if Info-mode-map
|
|
2888 nil
|
|
2889 (setq Info-mode-map (make-sparse-keymap))
|
|
2890 (suppress-keymap Info-mode-map)
|
|
2891 (define-key Info-mode-map "." 'beginning-of-buffer)
|
|
2892 (define-key Info-mode-map " " 'Info-scroll-next)
|
|
2893 (define-key Info-mode-map "1" 'Info-nth-menu-item)
|
|
2894 (define-key Info-mode-map "2" 'Info-nth-menu-item)
|
|
2895 (define-key Info-mode-map "3" 'Info-nth-menu-item)
|
|
2896 (define-key Info-mode-map "4" 'Info-nth-menu-item)
|
|
2897 (define-key Info-mode-map "5" 'Info-nth-menu-item)
|
|
2898 (define-key Info-mode-map "6" 'Info-nth-menu-item)
|
|
2899 (define-key Info-mode-map "7" 'Info-nth-menu-item)
|
|
2900 (define-key Info-mode-map "8" 'Info-nth-menu-item)
|
|
2901 (define-key Info-mode-map "9" 'Info-nth-menu-item)
|
|
2902 (define-key Info-mode-map "0" 'Info-last-menu-item)
|
|
2903 (define-key Info-mode-map "?" 'Info-summary)
|
|
2904 (define-key Info-mode-map "a" 'Info-annotate)
|
|
2905 (define-key Info-mode-map "b" 'beginning-of-buffer)
|
|
2906 (define-key Info-mode-map "d" 'Info-directory)
|
|
2907 (define-key Info-mode-map "e" 'Info-edit)
|
|
2908 (define-key Info-mode-map "f" 'Info-follow-reference)
|
|
2909 (define-key Info-mode-map "g" 'Info-goto-node)
|
|
2910 (define-key Info-mode-map "h" 'Info-help)
|
|
2911 (define-key Info-mode-map "i" 'Info-index)
|
|
2912 (define-key Info-mode-map "j" 'Info-goto-bookmark)
|
|
2913 (define-key Info-mode-map "k" 'Info-emacs-key)
|
|
2914 (define-key Info-mode-map "l" 'Info-last)
|
|
2915 (define-key Info-mode-map "m" 'Info-menu)
|
|
2916 (define-key Info-mode-map "n" 'Info-next)
|
|
2917 (define-key Info-mode-map "p" 'Info-prev)
|
|
2918 (define-key Info-mode-map "q" 'Info-exit)
|
|
2919 (define-key Info-mode-map "r" 'Info-follow-reference)
|
|
2920 (define-key Info-mode-map "s" 'Info-search)
|
|
2921 (define-key Info-mode-map "t" 'Info-top)
|
|
2922 (define-key Info-mode-map "u" 'Info-up)
|
|
2923 (define-key Info-mode-map "v" 'Info-visit-file)
|
|
2924 (define-key Info-mode-map "x" 'Info-bookmark)
|
502
|
2925 (define-key Info-mode-map "z" 'Info-search-next)
|
428
|
2926 (define-key Info-mode-map "<" 'Info-top)
|
|
2927 (define-key Info-mode-map ">" 'Info-end)
|
|
2928 (define-key Info-mode-map "[" 'Info-global-prev)
|
|
2929 (define-key Info-mode-map "]" 'Info-global-next)
|
|
2930 (define-key Info-mode-map "{" 'Info-page-prev)
|
|
2931 (define-key Info-mode-map "}" 'Info-page-next)
|
|
2932 (define-key Info-mode-map "=" 'Info-restore-point)
|
|
2933 (define-key Info-mode-map "!" 'Info-select-node)
|
|
2934 (define-key Info-mode-map "@" 'Info-follow-nearest-node)
|
|
2935 (define-key Info-mode-map "," 'Info-index-next)
|
|
2936 (define-key Info-mode-map "*" 'Info-elisp-ref)
|
|
2937 (define-key Info-mode-map [tab] 'Info-next-reference)
|
|
2938 (define-key Info-mode-map [(meta tab)] 'Info-prev-reference)
|
|
2939 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference)
|
|
2940 (define-key Info-mode-map "\r" 'Info-follow-nearest-node)
|
|
2941 ;; XEmacs addition
|
|
2942 (define-key Info-mode-map 'backspace 'Info-scroll-prev)
|
|
2943 (define-key Info-mode-map 'delete 'Info-scroll-prev)
|
|
2944 (define-key Info-mode-map 'button2 'Info-follow-clicked-node)
|
|
2945 (define-key Info-mode-map 'button3 'Info-select-node-menu))
|
|
2946
|
|
2947
|
|
2948 ;; Info mode is suitable only for specially formatted data.
|
|
2949 (put 'info-mode 'mode-class 'special)
|
|
2950
|
|
2951 (defun Info-mode ()
|
|
2952 "Info mode is for browsing through the Info documentation tree.
|
|
2953 Documentation in Info is divided into \"nodes\", each of which
|
|
2954 discusses one topic and contains references to other nodes
|
|
2955 which discuss related topics. Info has commands to follow
|
|
2956 the references and show you other nodes.
|
|
2957
|
|
2958 h Invoke the Info tutorial.
|
|
2959 q Quit Info: return to the previously selected file or buffer.
|
|
2960
|
|
2961 Selecting other nodes:
|
|
2962 n Move to the \"next\" node of this node.
|
|
2963 p Move to the \"previous\" node of this node.
|
|
2964 m Pick menu item specified by name (or abbreviation).
|
|
2965 1-9, 0 Pick first..ninth, last item in node's menu.
|
|
2966 Menu items select nodes that are \"subsections\" of this node.
|
|
2967 u Move \"up\" from this node (i.e., from a subsection to a section).
|
|
2968 f or r Follow a cross reference by name (or abbrev). Type `l' to get back.
|
|
2969 RET Follow cross reference or menu item indicated by cursor.
|
|
2970 i Look up a topic in this file's Index and move to that node.
|
|
2971 , (comma) Move to the next match from a previous `i' command.
|
|
2972 l (letter L) Move back to the last node you were in.
|
|
2973
|
|
2974 Moving within a node:
|
|
2975 Space Scroll forward a full screen. DEL Scroll backward.
|
|
2976 b Go to beginning of node. Meta-> Go to end of node.
|
|
2977 TAB Go to next cross-reference. Meta-TAB Go to previous ref.
|
|
2978
|
|
2979 Mouse commands:
|
|
2980 Left Button Set point (usual text-mode functionality)
|
|
2981 Middle Button Click on a highlighted node reference to go to it.
|
|
2982 Right Button Pop up a menu of applicable Info commands.
|
|
2983
|
|
2984 Left Button Double Click in window edges:
|
|
2985 Top edge: Go up to the parent node, like `u'.
|
|
2986 Left edge: Go to the previous node, like `p'.
|
|
2987 Right edge: Go to the next node, like `n'.
|
|
2988 Bottom edge: Follow first menu item, like `1'.
|
|
2989
|
|
2990 Advanced commands:
|
|
2991 g Move to node, file, or annotation tag specified by name.
|
|
2992 Examples: `g Rectangles' `g (Emacs)Rectangles' `g Emacs'.
|
|
2993 v Move to file, with filename completion.
|
|
2994 k Look up a key sequence in Emacs manual (also C-h C-k at any time).
|
|
2995 * Look up a function name in Emacs Lisp manual (also C-h C-f).
|
|
2996 d Go to the main directory of Info files.
|
|
2997 < or t Go to Top (first) node of this file.
|
|
2998 > Go to last node in this file.
|
|
2999 \[ Go to previous node, treating file as one linear document.
|
|
3000 \] Go to next node, treating file as one linear document.
|
|
3001 { Scroll backward, or go to previous node if at top.
|
|
3002 } Scroll forward, or go to next node if at bottom.
|
|
3003 = Restore cursor position from last time in this node.
|
|
3004 a Add a private note (annotation) to the current node.
|
|
3005 x, j Add, jump to a bookmark (annotation tag).
|
|
3006 s Search this Info file for a node containing the specified regexp.
|
|
3007 e Edit the contents of the current node."
|
|
3008 (kill-all-local-variables)
|
|
3009 (setq major-mode 'Info-mode)
|
|
3010 (setq mode-name "Info")
|
|
3011 (use-local-map Info-mode-map)
|
|
3012 (set-syntax-table text-mode-syntax-table)
|
|
3013 (setq local-abbrev-table text-mode-abbrev-table)
|
|
3014 (setq case-fold-search t)
|
|
3015 (setq buffer-read-only t)
|
|
3016 ; (setq buffer-mouse-map Info-mode-mouse-map)
|
|
3017 (make-local-variable 'Info-current-file)
|
|
3018 (make-local-variable 'Info-current-subfile)
|
|
3019 (make-local-variable 'Info-current-node)
|
|
3020 (make-local-variable 'Info-tag-table-marker)
|
442
|
3021 (setq Info-tag-table-marker (make-marker))
|
|
3022 (make-local-variable 'Info-tag-table-buffer)
|
|
3023 (setq Info-tag-table-buffer nil)
|
428
|
3024 (make-local-variable 'Info-current-file-completions)
|
|
3025 (make-local-variable 'Info-current-annotation-completions)
|
|
3026 (make-local-variable 'Info-index-alternatives)
|
|
3027 (make-local-variable 'Info-history)
|
|
3028 ;; Faces are now defined by `defface'...
|
548
|
3029 (make-local-hook 'mouse-track-click-hook)
|
|
3030 (add-hook 'mouse-track-click-hook 'Info-maybe-follow-clicked-node t t)
|
|
3031 (add-hook 'mouse-track-click-hook 'Info-mouse-track-double-click-hook t t)
|
428
|
3032 ;; #### The console-on-window-system-p check is to allow this to
|
|
3033 ;; work on tty's. The real problem here is that featurep really
|
|
3034 ;; needs to have some device/console domain knowledge added to it.
|
|
3035 (defvar info::toolbar)
|
|
3036 (if (and (featurep 'toolbar)
|
|
3037 (console-on-window-system-p)
|
|
3038 (not Info-inhibit-toolbar))
|
|
3039 (set-specifier default-toolbar (cons (current-buffer) info::toolbar)))
|
|
3040 (if (featurep 'menubar)
|
|
3041 (progn
|
|
3042 ;; make a local copy of the menubar, so our modes don't
|
|
3043 ;; change the global menubar
|
|
3044 (easy-menu-add '("Info" :filter Info-menu-filter))))
|
|
3045 (run-hooks 'Info-mode-hook)
|
|
3046 (Info-set-mode-line))
|
|
3047
|
|
3048 (defvar Info-edit-map nil
|
|
3049 "Local keymap used within `e' command of Info.")
|
444
|
3050
|
428
|
3051 (if Info-edit-map
|
|
3052 nil
|
|
3053 ;; XEmacs: remove FSF stuff
|
|
3054 (setq Info-edit-map (make-sparse-keymap))
|
|
3055 (set-keymap-name Info-edit-map 'Info-edit-map)
|
|
3056 (set-keymap-parents Info-edit-map (list text-mode-map))
|
|
3057 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
|
|
3058
|
|
3059 ;; Info-edit mode is suitable only for specially formatted data.
|
|
3060 (put 'info-edit-mode 'mode-class 'special)
|
|
3061
|
|
3062 (defun Info-edit-mode ()
|
|
3063 "Major mode for editing the contents of an Info node.
|
|
3064 Like text mode with the addition of `Info-cease-edit'
|
|
3065 which returns to Info mode for browsing.
|
|
3066 \\{Info-edit-map}"
|
|
3067 )
|
|
3068
|
|
3069 (defun Info-edit ()
|
|
3070 "Edit the contents of this Info node.
|
|
3071 Allowed only if variable `Info-enable-edit' is non-nil."
|
|
3072 (interactive)
|
|
3073 (or Info-enable-edit
|
|
3074 (error "Editing info nodes is not enabled"))
|
|
3075 (use-local-map Info-edit-map)
|
|
3076 (setq major-mode 'Info-edit-mode)
|
|
3077 (setq mode-name "Info Edit")
|
|
3078 (kill-local-variable 'modeline-buffer-identification)
|
|
3079 (setq buffer-read-only nil)
|
|
3080 ;; Make mode line update.
|
|
3081 (set-buffer-modified-p (buffer-modified-p))
|
|
3082 (message (substitute-command-keys
|
|
3083 "Editing: Type \\[Info-cease-edit] to return to info")))
|
|
3084
|
|
3085 (defun Info-cease-edit ()
|
|
3086 "Finish editing Info node; switch back to Info proper."
|
|
3087 (interactive)
|
|
3088 ;; Do this first, so nothing has changed if user C-g's at query.
|
|
3089 (and (buffer-modified-p)
|
442
|
3090 (y-or-n-p "Save the file? ")
|
428
|
3091 (save-buffer))
|
|
3092 (use-local-map Info-mode-map)
|
|
3093 (setq major-mode 'Info-mode)
|
|
3094 (setq mode-name "Info")
|
|
3095 (Info-set-mode-line)
|
|
3096 (setq buffer-read-only t)
|
|
3097 ;; Make mode line update.
|
|
3098 (set-buffer-modified-p (buffer-modified-p))
|
|
3099 (and (marker-position Info-tag-table-marker)
|
|
3100 (buffer-modified-p)
|
|
3101 (message "Tags may have changed. Use Info-tagify if necessary")))
|
|
3102
|
|
3103 (defun Info-find-emacs-command-nodes (command)
|
|
3104 "Return a list of locations documenting COMMAND in the XEmacs Info manual.
|
|
3105 The locations are of the format used in Info-history, i.e.
|
|
3106 \(FILENAME NODENAME BUFFERPOS\)."
|
|
3107 (let ((where '())
|
|
3108 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
|
|
3109 ":\\s *\\(.*\\)\\.$")))
|
|
3110 (save-excursion
|
|
3111 (Info-find-node "XEmacs" "Command Index")
|
|
3112 ;; Take the index node off the Info history.
|
|
3113 ;; ??? says this isn't safe someplace else... hmmm.
|
|
3114 (setq Info-history (cdr Info-history))
|
|
3115 (goto-char (point-max))
|
|
3116 (while (re-search-backward cmd-desc nil t)
|
|
3117 (setq where (cons (list Info-current-file
|
|
3118 (buffer-substring
|
|
3119 (match-beginning 1)
|
|
3120 (match-end 1))
|
|
3121 0)
|
|
3122 where)))
|
|
3123 where)))
|
|
3124
|
|
3125 ;;; fontification and mousability for info
|
|
3126
|
|
3127 (defun Info-highlight-region (start end face)
|
|
3128 (let ((extent nil)
|
|
3129 (splitp (string-match "\n[ \t]+" (buffer-substring start end))))
|
|
3130 (if splitp
|
|
3131 (save-excursion
|
|
3132 (setq extent (make-extent start (progn (goto-char start)
|
|
3133 (end-of-line)
|
|
3134 (point))))
|
|
3135 (set-extent-face extent face)
|
|
3136 (set-extent-property extent 'info t)
|
|
3137 (set-extent-property extent 'highlight t)
|
|
3138 (skip-chars-forward "\n\t ")
|
|
3139 (setq extent (make-extent (point) end)))
|
|
3140 (setq extent (make-extent start end)))
|
|
3141 (set-extent-face extent face)
|
|
3142 (set-extent-property extent 'info t)
|
|
3143 (set-extent-property extent 'highlight t)))
|
|
3144
|
|
3145 (defun Info-fontify-node ()
|
|
3146 (save-excursion
|
|
3147 (let ((case-fold-search t)
|
|
3148 (xref-regexp (concat "\\*"
|
|
3149 (regexp-quote Info-footnote-tag)
|
|
3150 "[ \n\t]*\\([^:]*\\):")))
|
|
3151 ;; Clear the old extents
|
|
3152 (map-extents #'(lambda (x y) (delete-extent x))
|
|
3153 (current-buffer) (point-min) (point-max) nil)
|
|
3154 ;; Break the top line iff it is > 79 characters. Some info nodes
|
|
3155 ;; have top lines that span 3 lines because of long node titles.
|
|
3156 ;; eg: (Info-find-node "lispref.info" "Window-Level Event Position Info")
|
|
3157 (toggle-read-only -1)
|
|
3158 (let ((extent nil)
|
|
3159 (len 0)
|
|
3160 (done nil)
|
|
3161 (p (point-min)))
|
|
3162 (goto-char (point-min))
|
|
3163 (re-search-forward "Node: *[^,]+, " nil t)
|
|
3164 (setq len (- (point) (point-min))
|
|
3165 extent (make-extent (point-min) (point)))
|
|
3166 (set-extent-property extent 'invisible t)
|
|
3167 (while (not done)
|
|
3168 (goto-char p)
|
|
3169 (end-of-line)
|
|
3170 (if (< (current-column) (+ 78 len))
|
|
3171 (setq done t)
|
|
3172 (goto-char p)
|
|
3173 (forward-char (+ 79 len))
|
|
3174 (re-search-backward "," nil t)
|
|
3175 (forward-char 1)
|
|
3176 (insert "\n")
|
|
3177 (just-one-space)
|
446
|
3178 (delete-backward-char 1)
|
428
|
3179 (setq p (point)
|
|
3180 len 0))))
|
|
3181 (toggle-read-only 1)
|
|
3182 ;; Highlight xrefs in the top few lines of the node
|
|
3183 (goto-char (point-min))
|
|
3184 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
|
|
3185 (progn
|
|
3186 (goto-char (match-end 0))
|
|
3187 (while
|
|
3188 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?\n?")
|
|
3189 (goto-char (match-end 0))
|
444
|
3190 (Info-highlight-region (match-beginning 1) (match-end 1)
|
|
3191 'info-xref))))
|
428
|
3192 ;; Now get the xrefs in the body
|
|
3193 (goto-char (point-min))
|
|
3194 (while (re-search-forward xref-regexp nil t)
|
|
3195 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
|
|
3196 nil
|
444
|
3197 (Info-highlight-region (match-beginning 1) (match-end 1)
|
|
3198 'info-xref)))
|
428
|
3199 ;; then highlight the nodes in the menu.
|
|
3200 (goto-char (point-min))
|
|
3201 (if (and (search-forward "\n* menu:" nil t))
|
|
3202 (while (re-search-forward
|
|
3203 "^\\* \\([^:\t\n]*\\):?:[ \t\n]" nil t)
|
444
|
3204 (Info-highlight-region (match-beginning 1) (match-end 1)
|
|
3205 'info-node)))
|
428
|
3206 (set-buffer-modified-p nil))))
|
|
3207
|
|
3208 (defun Info-construct-menu (&optional event)
|
|
3209 "Construct a menu of Info commands.
|
|
3210 Adds an entry for the node at EVENT, or under point if EVENT is omitted.
|
|
3211 Used to construct the menubar submenu and popup menu."
|
|
3212 (or event (setq event (point)))
|
|
3213 (let ((case-fold-search t)
|
442
|
3214 (xref-regexp (concat "\\*"
|
428
|
3215 (regexp-quote Info-footnote-tag)
|
|
3216 "[ \n\t]*\\([^:]*\\):"))
|
|
3217 up-p prev-p next-p menu xrefs subnodes in)
|
|
3218 (save-excursion
|
|
3219 ;; `one-space' fixes "Notes:" xrefs that are split across lines.
|
|
3220 (flet
|
|
3221 ((one-space (text)
|
|
3222 (let (i)
|
|
3223 (while (setq i (string-match "[ \n\t]+" text i))
|
|
3224 (setq text (concat (substring text 0 i) " "
|
|
3225 (substring text (match-end 0))))
|
|
3226 (setq i (1+ i)))
|
|
3227 text)))
|
|
3228 (goto-char (point-min))
|
|
3229 (if (looking-at ".*\\bNext:") (setq next-p t))
|
|
3230 (if (looking-at ".*\\bPrev:") (setq prev-p t))
|
|
3231 (if (looking-at ".*Up:") (setq up-p t))
|
|
3232 (setq menu (nconc
|
|
3233 (if (setq in (Info-indicated-node event))
|
|
3234 (list (vector (one-space (cadr in)) in t)
|
|
3235 "--:shadowEtchedIn"))
|
|
3236 (list
|
|
3237 ["Goto Info Top-level" Info-directory]
|
|
3238 (vector "Next Node" 'Info-next :active next-p)
|
|
3239 (vector "Previous Node" 'Info-prev :active prev-p)
|
|
3240 (vector "Parent Node (Up)" 'Info-up :active up-p)
|
|
3241 ["Goto Node..." Info-goto-node]
|
|
3242 ["Goto Last Visited Node " Info-last])))
|
|
3243 ;; Find the xrefs and make a list
|
|
3244 (while (re-search-forward xref-regexp nil t)
|
|
3245 (setq xrefs (cons (one-space (buffer-substring (match-beginning 1)
|
|
3246 (match-end 1)))
|
|
3247 xrefs))))
|
|
3248 (setq xrefs (nreverse xrefs))
|
|
3249 (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more)))
|
|
3250 ;; Find the subnodes and make a list
|
|
3251 (goto-char (point-min))
|
|
3252 (if (search-forward "\n* menu:" nil t)
|
|
3253 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
|
|
3254 (setq subnodes (cons (buffer-substring (match-beginning 1)
|
|
3255 (match-end 1))
|
|
3256 subnodes))))
|
|
3257 (setq subnodes (nreverse subnodes))
|
|
3258 (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more))))
|
|
3259 (if xrefs
|
|
3260 (nconc menu (list "--:shadowDoubleEtchedIn"
|
|
3261 " Cross-References"
|
|
3262 "--:singleLine")
|
|
3263 (mapcar #'(lambda (xref)
|
|
3264 (if (eq xref 'more)
|
|
3265 "...more..."
|
|
3266 (vector xref
|
|
3267 (list 'Info-follow-reference xref))))
|
|
3268 xrefs)))
|
|
3269 (if subnodes
|
|
3270 (nconc menu (list "--:shadowDoubleEtchedIn"
|
|
3271 " Sub-Nodes"
|
|
3272 "--:singleLine")
|
|
3273 (mapcar #'(lambda (node)
|
|
3274 (if (eq node 'more)
|
|
3275 "...more..."
|
|
3276 (vector node (list 'Info-menu node))))
|
|
3277 subnodes)))
|
|
3278 menu))
|
|
3279
|
|
3280 (defun Info-menu-filter (menu)
|
|
3281 "This is the menu filter for the \"Info\" submenu."
|
|
3282 (Info-construct-menu))
|
|
3283
|
|
3284 (defun Info-select-node-menu (event)
|
|
3285 "Pops up a menu of applicable Info commands."
|
|
3286 (interactive "e")
|
|
3287 (select-window (event-window event))
|
|
3288 (let ((menu (Info-construct-menu event)))
|
|
3289 (setq menu (nconc (list "Info" ; title: not displayed
|
|
3290 " Info Commands"
|
|
3291 "--:shadowDoubleEtchedOut")
|
|
3292 menu))
|
|
3293 (let ((popup-menu-titles nil))
|
|
3294 (popup-menu menu))))
|
|
3295
|
|
3296 ;;; Info toolbar support
|
|
3297
|
|
3298 ;; exit icon taken from GNUS
|
|
3299 (defvar info::toolbar-exit-icon
|
|
3300 (if (featurep 'toolbar)
|
|
3301 (toolbar-make-button-list
|
|
3302 (expand-file-name (if (featurep 'xpm) "info-exit.xpm" "info-exit.xbm")
|
|
3303 toolbar-icon-directory)))
|
|
3304 "Exit Info icon")
|
|
3305
|
|
3306 (defvar info::toolbar-up-icon
|
|
3307 (if (featurep 'toolbar)
|
|
3308 (toolbar-make-button-list
|
|
3309 (expand-file-name (if (featurep 'xpm) "info-up.xpm" "info-up.xbm")
|
|
3310 toolbar-icon-directory)))
|
|
3311 "Up icon")
|
|
3312
|
|
3313 (defvar info::toolbar-next-icon
|
|
3314 (if (featurep 'toolbar)
|
|
3315 (toolbar-make-button-list
|
|
3316 (expand-file-name (if (featurep 'xpm) "info-next.xpm" "info-next.xbm")
|
|
3317 toolbar-icon-directory)))
|
|
3318 "Next icon")
|
|
3319
|
|
3320 (defvar info::toolbar-prev-icon
|
|
3321 (if (featurep 'toolbar)
|
|
3322 (toolbar-make-button-list
|
|
3323 (expand-file-name (if (featurep 'xpm) "info-prev.xpm" "info-prev.xbm")
|
|
3324 toolbar-icon-directory)))
|
|
3325 "Prev icon")
|
|
3326
|
|
3327 (defvar info::toolbar
|
|
3328 (if (featurep 'toolbar)
|
|
3329 ; disabled until we get the next/prev-win icons working again.
|
|
3330 ; (cons (first initial-toolbar-spec)
|
|
3331 ; (cons (second initial-toolbar-spec)
|
|
3332 '([info::toolbar-exit-icon
|
|
3333 Info-exit
|
|
3334 t
|
|
3335 "Exit info"]
|
|
3336 [info::toolbar-next-icon
|
|
3337 Info-next
|
|
3338 t
|
|
3339 "Next entry in same section"]
|
|
3340 [info::toolbar-prev-icon
|
|
3341 Info-prev
|
|
3342 t
|
|
3343 "Prev entry in same section"]
|
|
3344 [info::toolbar-up-icon
|
|
3345 Info-up
|
|
3346 t
|
|
3347 "Up entry to enclosing section"]
|
|
3348 )))
|
|
3349 ;))
|
|
3350
|
|
3351 (provide 'info)
|
|
3352
|
|
3353 (run-hooks 'Info-load-hook)
|
|
3354
|
|
3355 ;;; info.el ends here
|