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