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