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