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