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