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