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