1 ;;; info.el --- info package for Emacs.
4 ;; Copyright (C) 1985, 1986, 1993, 1997 Free Software Foundation, Inc.
6 ;; Author: Dave Gillespie <daveg@synaptics.com>
7 ;; Richard Stallman <rms@gnu.ai.mit.edu>
8 ;; Maintainer: Dave Gillespie <daveg@synaptics.com>
9 ;; Version: 1.07 of 7/22/93
10 ;; Keywords: docs, help
12 ;; This file is part of XEmacs.
14 ;; XEmacs is free software; you can redistribute it and/or modify it
15 ;; under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; XEmacs is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;; General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with XEmacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
29 ;;; Synched up with: Not synched with FSF.
33 ;; This is based on an early Emacs 19 info.el file.
35 ;; Note that Info-directory has been replaced by Info-directory-list,
36 ;; a search path of directories in which to find Info files.
37 ;; Also, Info tries adding ".info" to a file name if the name itself
40 ;; See the change log below for further details.
44 ;; info-dg|Dave Gillespie|daveg@synaptics.com
45 ;; |Info reader with many enhancements; replaces standard info.el.
46 ;; |93-07-22|1.07|~/modes/info.el
48 ;; Also available from anonymous FTP on csvax.cs.caltech.edu.
53 ;; Modified 3/7/1991 by Dave Gillespie:
54 ;; (Author's address: daveg@synaptics.com or daveg@csvax.cs.caltech.edu)
56 ;; Added keys: i, t, <, >, [, ], {, }, 6, 7, 8, 9, 0.
57 ;; Look at help for info-mode (type ? in Info) for descriptions.
59 ;; If Info-directory-list is undefined and there is no INFOPATH
60 ;; in the environment, use value of Info-directory for compatibility
63 ;; All files named "localdir" found in the path are appended to "dir",
64 ;; the Info directory. For this to work, "dir" should contain only
65 ;; one node (Top), and each "localdir" should contain no ^_ or ^L
66 ;; characters. Generally they will contain only one or several
67 ;; additional lines for the top-level menu. Note that "dir" is
68 ;; modified in memory each time it is loaded, but not on disk.
70 ;; If "dir" contains a line of the form: "* Locals:"
71 ;; then the "localdir"s are inserted there instead of at the end.
74 ;; Modified 4/3/1991 by Dave Gillespie:
76 ;; Added Info-mode-hook (suggested by Sebastian Kremer).
77 ;; Also added epoch-info-startup/select-hooks from Simon Spero's info.el.
79 ;; Added automatic decoding of compressed Info files.
80 ;; See documentation for the variable Info-suffix-list. Default is to
81 ;; run "uncompress" on ".Z" files and "unyabba" on ".Y" files.
82 ;; (See comp.sources.unix v24i073-076 for yabba/unyabba, a free software
83 ;; alternative to compress/uncompress.)
84 ;; Note: "dir" and "localdir" files should not be compressed.
86 ;; Changed variables like Info-enable-edit to be settable by M-x set-variable.
88 ;; Added Info-auto-advance variable. If t, SPC and DEL will act like
89 ;; } and {, i.e., they advance to the next/previous node if at the end
92 ;; Changed `u' to restore point to most recent location in that node.
93 ;; Added `=' to do this manually at any time. (Suggested by David Fox).
95 ;; Changed `m' and `0-9' to try interpreting menu name as a file name
96 ;; if not found as a node name. This allows (dir) menus of the form,
97 ;; Emacs:: Cool text editor
99 ;; Emacs:(emacs). Cool text editor
101 ;; Enhanced `i' to use line-number information in the index.
102 ;; Added `,' to move among all matches to a previous `i' command.
104 ;; Added `a' (Info-annotate) for adding personal notes to any Info node.
105 ;; Notes are not stored in the actual Info files, but in the user's own
106 ;; ~/.infonotes file.
108 ;; Added Info-footnote-tag, made default be "Ref" instead of "Note".
110 ;; Got mouse-click stuff to work under Emacs version 18. Check it out!
111 ;; Left and right clicks scroll the Info window.
112 ;; Middle click goes to clicked-on node, e.g., "Next:", a menu, or a note.
115 ;; Modified 6/29/1991 by Dave Gillespie:
117 ;; Renamed epoch-info-startup/select-hooks to Info-startup/select-hook.
119 ;; Made Info-select-node into a command on the `!' key.
121 ;; Added Info-mouse-support user option.
123 ;; Cleaned up the implementation of some routines.
125 ;; Added special treatment of quoted words in annotations: The `g'
126 ;; command for a nonexistent node name scans for an annotation
127 ;; (in any node of any file) containing that name in quotes: g foo RET
128 ;; looks for an annotation containing: "foo" or: <<foo>>
129 ;; If found, it goes to that file and node.
131 ;; Added a call to set up Info-directory-list in Info-find-node to
132 ;; work around a bug in GNUS where it calls Info-goto-node before info.
134 ;; Added completion for `g' command (inspired by Richard Kim's infox.el).
135 ;; Completion knows all node names for the current file, and all annotation
136 ;; tags (see above). It does not complete file names or node names in
139 ;; Added `k' (Info-emacs-key) and `*' (Info-elisp-ref) commands. You may
140 ;; wish to bind these to global keys outside of Info mode.
142 ;; Allowed localdir files to be full dir-like files; only the menu part
143 ;; of each localdir is copied. Also, redundant menu items are omitted.
145 ;; Changed Info-history to hold only one entry at a time for each node,
146 ;; and to be circular so that multiple `l's come back again to the most
147 ;; recent node. Note that the format of Info-history entries has changed,
148 ;; which may interfere with external programs that try to operate on it.
149 ;; (Also inspired by Kim's infox.el).
151 ;; Changed `n', `]', `l', etc. to accept prefix arguments to move several
152 ;; steps at once. Most accept negative arguments to move oppositely.
154 ;; Changed `?' to bury *Help* buffer afterwards to keep it out of the way.
156 ;; Rearranged `?' key's display to be a little better for new users.
158 ;; Changed `a' to save whole window configuration and restore on C-c C-c.
160 ;; Fixed the bug reported by Bill Reynolds on gnu.emacs.bugs.
162 ;; Changed Info-last to restore window-start as well as cursor position.
164 ;; Changed middle mouse button in space after end of node to do Info-last
165 ;; if we got here by following a cross reference, else do Info-global-next.
167 ;; Added some new mouse bindings: shift-left = Info-global-next,
168 ;; shift-right = Info-global-prev, shift-middle = Info-last.
170 ;; Fixed Info-follow-reference not to make assumptions about length
171 ;; of Info-footnote-tag [Linus Tolke].
173 ;; Changed default for Info-auto-advance mode to be press-twice-for-next-node.
175 ;; Modified x-mouse-ignore to preserve last-command variable, so that
176 ;; press-twice Info-auto-advance mode works with the mouse.
179 ;; Modified 3/4/1992 by Dave Gillespie:
181 ;; Added an "autoload" command to help autoload.el.
183 ;; Changed `*' command to look for file `elisp' as well as for `lispref'.
185 ;; Fixed a bug involving footnote names containing regexp special characters.
187 ;; Fixed a bug in completion during `f' (or `r') command.
189 ;; Added TAB (Info-next-reference), M-TAB, and RET keys to Info mode.
191 ;; Added new bindings, `C-h C-k' for Info-emacs-key and `C-h C-f' for
192 ;; Info-elisp-ref. These bindings are made when info.el is loaded, and
193 ;; only if those key sequences were previously unbound. These bindings
194 ;; work at any time, not just when Info is already running.
197 ;; Modified 3/8/1992 by Dave Gillespie:
199 ;; Fixed some long lines that were causing trouble with mailers.
202 ;; Modified 3/9/1992 by Dave Gillespie:
204 ;; Added `C-h C-i' (Info-query).
206 ;; Added Info-novice mode, warns if the user attempts to switch to
207 ;; a different Info file.
209 ;; Fixed a bug that caused problems using compressed Info files
210 ;; and Info-directory-list at the same time.
212 ;; Disabled Info-mouse-support by default if Epoch or Hyperbole is in use.
214 ;; Added an expand-file-name call to Info-find-node to fix a small bug.
217 ;; Modified 5/22/1992 by Dave Gillespie:
219 ;; Added "standalone" operation: "emacs -f info" runs Emacs specifically
220 ;; for use as an Info browser. In this mode, the `q' key quits Emacs
221 ;; itself. Also, "emacs -f info arg" starts in Info file "arg" instead
224 ;; Changed to prefer "foo.info" over "foo". If both exist, "foo" is
225 ;; probably a directory or executable program!
227 ;; Made control-mouse act like regular-mouse does in other buffers.
228 ;; (In most systems, this will be set-cursor for left-mouse, x-cut
229 ;; for right-mouse, and x-paste, which will be an error, for
232 ;; Improved prompting and searching for `,' key.
234 ;; Fixed a bug where some "* Menu:" lines disappeared when "dir"
235 ;; contained several nodes.
238 ;; Modified 9/10/1992 by Dave Gillespie:
240 ;; Mixed in support for XEmacs. Mouse works the same as in
241 ;; the other Emacs versions by default; added Info-lucid-mouse-style
242 ;; variable, which enables mouse operation similar to XEmacs's default.
244 ;; Fixed a bug where RET couldn't understand "* Foo::" if "Foo" was a
245 ;; file name instead of a node name.
247 ;; Added `x' (Info-bookmark), a simple interface to the annotation
248 ;; tags feature. Added `j' (Info-goto-bookmark), like `g' but only
249 ;; completes bookmarks.
251 ;; Added `<<tag>>' as alternate to `"tag"' in annotations.
253 ;; Added `v' (Info-visit-file), like Info-goto-node but specialized
254 ;; for going to a new Info file (with file name completion).
256 ;; Added recognition of gzip'd ".z" files.
259 ;; Modified 5/9/1993 by Dave Gillespie:
261 ;; Merged in various things from FSF's latest Emacs 19 info.el.
263 ;; Modified 6/2/1993 by Dave Gillespie:
265 ;; Changed to use new suffix ".gz" for gzip files.
268 ;; Modified 7/22/1993 by Dave Gillespie:
270 ;; Changed Info-footnote-tag to "See" instead of "Ref".
272 ;; Extended Info-fontify-node to work with FSF version of Emacs 19.
274 ;; Modified 7/30/1993 by Jamie Zawinski:
276 ;; Commented out the tty and fsf19 mouse support, because why bother.
277 ;; Commented out the politically incorrect version of XEmacs mouse support.
278 ;; Commented out mouse scrolling bindings because the party line on that
279 ;; is "scrollbars are coming soon."
280 ;; Commented out munging of help-for-help's doc; put it in help.el.
281 ;; Did Info-edit-map the modern XEmacs way.
282 ;; Pruned extra cruft from fontification and mouse handling code.
283 ;; Fixed ASCII-centric bogosity in unreading of events.
285 ;; Modified 8/11/95 by Chuck Thompson:
287 ;; Removed any pretense of ever referencing Info-directory since it
288 ;; wasn't working anyhow.
290 ;; Modified 4/5/97 by Tomasz J. Cholewo:
292 ;; Modified Info-search to use with-caps-disable-folding
294 ;; Modified 6/21/97 by Hrvoje Niksic
296 ;; Fixed up Info-next-reference to work sanely when n < 0.
297 ;; Added S-tab binding.
299 ;; Modified 1997-07-10 by Karl M. Hegbloom
301 ;; Added `Info-minibuffer-history'
302 ;; (also added to defaults in "lisp/utils/savehist.el")
303 ;; Other changes in main ChangeLog.
305 ;; Modified 1998-03-29 by Oscar Figueiredo
307 ;; Added automatic dir/localdir (re)building capability for directories that
308 ;; contain none or when it has become older than info files in the same
311 ;; Modified 1998-09-23 by Didier Verna <didier@xemacs.org>
313 ;; Use the new macro `with-search-caps-disable-folding'
317 (condition-case nil (require 'browse-url) (error nil)))
320 "The info package for Emacs."
324 (defgroup info-faces nil
325 "The faces used by info browser."
330 (defcustom Info-inhibit-toolbar nil
331 "*Non-nil means don't use the specialized Info toolbar."
335 (defcustom Info-novice nil
336 "*Non-nil means to ask for confirmation before switching Info files."
340 (defvar Info-history nil
341 "List of info nodes user has visited.
342 Each element of list is a list (\"(FILENAME)NODENAME\" BUFPOS WINSTART).")
344 (defvar Info-keeping-history t
345 "Non-nil if Info-find-node should modify Info-history.
346 This is for use only by certain internal Info routines.")
348 (defvar Info-minibuffer-history nil
349 "Minibuffer history for Info.")
351 (defcustom Info-enable-edit nil
352 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info
353 can edit the current node.
354 This is convenient if you want to write info files by hand.
355 However, we recommend that you not do this.
356 It is better to write a Texinfo file and generate the Info file from that,
357 because that gives you a printed manual as well."
361 (defcustom Info-enable-active-nodes t
362 "*Non-nil allows Info to execute Lisp code associated with nodes.
363 The Lisp code is executed when the node is selected."
367 (defcustom Info-restoring-point t
368 "*Non-nil means to restore the cursor position when re-entering a node."
372 (defcustom Info-auto-advance 'twice
373 "*Control what SPC and DEL do when they can't scroll any further.
374 If nil, they beep and remain in the current node.
375 If t, they move to the next node (like Info-global-next/prev).
376 If anything else, they must be pressed twice to move to the next node."
377 :type '(choice (const :tag "off" nil)
378 (const :tag "advance" t)
379 (const :tag "confirm" twice))
382 (defcustom Info-fontify t
383 "*Non-nil enables font features in XEmacs.
384 This variable is ignored unless running under XEmacs."
388 (defcustom Info-additional-search-directory-list nil
389 "*List of additional directories to search for Info documentation
390 files. These directories are not searched for merging the `dir'
391 file. An example might be something like:
392 \"/usr/local/lib/xemacs/packages/lisp/calc/\""
393 :type '(repeat directory)
396 (defcustom Info-auto-generate-directory 'if-outdated
397 "*When to auto generate an info directory listing.
399 nil or `never' never auto-generate a directory listing,
400 use any existing `dir' or `localdir' file and ignore info
401 directories containing none
402 `always' auto-generate a directory listing ignoring existing
403 `dir' and `localdir' files
404 `if-missing', the default, auto-generates a directory listing
405 if no `dir' or `localdir' file is present. Otherwise the
406 contents of any of these files is used instead.
407 `if-outdated' auto-generates a directory listing if the `dir'
408 and `localdir' are either inexistent or outdated (touched
409 less recently than an info file in the same directory)."
410 :type '(choice (const :tag "never" never)
411 (const :tag "always" always)
412 (const :tag "if-missing" if-missing)
413 (const :tag "if-outdated" if-outdated))
416 (defcustom Info-save-auto-generated-dir 'never
417 "*Whether an auto-generated info directory listing should be saved.
419 nil or `never', the default, auto-generated info directory
420 information will never be saved.
421 `always', auto-generated info directory information will be saved to
422 a `dir' file in the same directory overwriting it if it exists
423 `conservative', auto-generated info directory information will be saved
424 to a `dir' file in the same directory but the user is asked before
425 overwriting any existing file."
426 :type '(choice (const :tag "never" never)
427 (const :tag "always" always)
428 (const :tag "conservative" conservative))
431 (defconst Info-emacs-info-file-name "xemacs.info"
432 "The filename of the XEmacs info for `Info-goto-emacs-command-node'
433 (`\\<help-mode-map>\\[Info-goto-emacs-command-node]')")
436 (defvar Info-directory-list nil
437 "List of directories to search for Info documentation files.
439 The first directory in this list, the \"dir\" file there will become
440 the (dir)Top node of the Info documentation tree.
442 Note: DO NOT use the `customize' interface to change the value of this
443 variable. Its value is created dynamically on each startup, depending
444 on XEmacs packages installed on the system. If you want to change the
445 search path, make the needed modifications on the variable's value
446 from .emacs. For instance:
448 (setq Info-directory-list (cons \"~/info\" Info-directory-list))")
450 ;; This could as well be hard-coded since ${srcdir}/info/dir is in CVS --dv
451 (defconst Info-localdir-heading-regexp "^Local Packages:$"
452 "The menu part of localdir files will be inserted below this topic
455 (defface info-node '((t (:bold t :italic t)))
456 "Face used for node links in info."
459 (defface info-xref '((t (:bold t)))
460 "Face used for cross-references in info."
463 ;; This list is based on Karl Berry-s advice about extensions `info' itself
464 ;; might encounter. --dv
465 (defcustom Info-suffix-list '(("" . nil)
467 (".gz" . "gzip -dc %s")
468 (".info.gz" . "gzip -dc %s")
469 (".z" . "gzip -dc %s")
470 (".info.z" . "gzip -dc %s")
471 (".bz2" . "bzip2 -dc %s")
472 (".info.bz2" . "bzip2 -dc %s")
473 (".Z" . "uncompress -c %s")
474 (".info.Z" . "uncompress -c %s")
475 (".zip" . "unzip -c %s")
476 (".info.zip" . "unzip -c %s")
477 (".y" . "cat %s | unyabba")
478 ("info.y" . "cat %s | unyabba")
479 ;; These ones are for MS-DOS filenames.
481 (".igz" . "gzip -dc %s")
482 (".inz" . "gzip -c %s"))
483 "*List of file name suffixes and associated decoding commands.
484 Each entry should be (SUFFIX . STRING); if STRING contains %s, that is
485 changed to name of the file to decode, otherwise the file is given to
486 the command as standard input. If STRING is nil, no decoding is done."
487 :type '(repeat (cons (string :tag "suffix")
488 (choice :tag "command"
489 (const :tag "none" :value nil)
493 (defcustom Info-footnote-tag "Note"
494 "*Symbol that identifies a footnote or cross-reference.
495 All \"*Note\" references will be changed to use this word instead."
499 (defvar Info-current-file nil
500 "Info file that Info is now looking at, or nil.
501 This is the name that was specified in Info, not the actual file name.
502 It doesn't contain directory names or file name extensions added by Info.")
504 (defvar Info-current-subfile nil
505 "Info subfile that is actually in the *info* buffer now,
506 or nil if current info file is not split into subfiles.")
508 (defvar Info-current-node nil
509 "Name of node that Info is now looking at, or nil.")
511 (defvar Info-tag-table-marker nil
512 "Marker pointing at beginning of current Info file's tag table.
513 Marker points nowhere if file has no tag table.")
515 (defvar Info-tag-table-buffer nil)
517 (defvar Info-current-file-completions nil
518 "Cached completion list for current Info file.")
520 (defvar Info-current-annotation-completions nil
521 "Cached completion list for current annotation files.")
523 (defvar Info-index-alternatives nil
524 "List of possible matches for last Info-index command.")
526 (defvar Info-index-first-alternative nil)
528 (defcustom Info-annotations-path
530 (paths-construct-path (list user-init-directory "info.notes"))
531 (paths-construct-path '("~" ".infonotes"))
532 (paths-construct-path '("usr" "lib" "info.notes")
533 (char-to-string directory-sep-char)))
534 "*Names of files that contain annotations for different Info nodes.
535 By convention, the first one should reside in your personal directory.
536 The last should be a world-writable \"public\" annotations file."
540 (defcustom Info-button1-follows-hyperlink nil
541 "*Non-nil means mouse button1 click will follow hyperlink."
545 (defvar Info-standalone nil
546 "Non-nil if Emacs was started solely as an Info browser.")
548 (defvar Info-in-cross-reference nil)
549 (defvar Info-window-configuration nil)
551 (defvar Info-dir-prologue "-*- Text -*-
552 This is the file .../info/dir, which contains the topmost node of the
553 Info hierarchy. The first time you invoke Info you start off
554 looking at that node, which is (dir)Top.
556 File: dir Node: Top This is the top of the INFO tree
557 This (the Directory node) gives a menu of major topics.
559 * Menu: The list of major topics begins on the next line.
563 (defcustom Info-no-description-string "[No description available]"
564 "*Description string for info files that have none"
569 (defun info (&optional file)
570 "Enter Info, the documentation browser.
571 Optional argument FILE specifies the file to examine;
572 the default is the top-level directory of Info.
574 In interactive use, a prefix argument directs this command
575 to read a file name from the minibuffer."
576 (interactive (if current-prefix-arg
577 (list (read-file-name "Info file name: " nil nil t))))
578 (let ((p command-line-args))
580 (and (string-match "^-[fe]" (car p))
581 (equal (nth 1 p) "info")
582 (not Info-standalone)
583 (setq Info-standalone t)
585 (not (string-match "^-" (nth 2 p)))
586 (setq file (nth 2 p))
587 (setq command-line-args-left nil))
589 ; (Info-setup-x) ??? What was this going to be? Can anyone tell karlheg?
592 (Info-goto-node (concat "(" file ")"))
593 (and Info-standalone (info)))
594 (if (get-buffer "*info*")
595 (switch-to-buffer "*info*")
599 (defun Info-query (file)
600 "Enter Info, the documentation browser. Prompt for name of Info file."
601 (interactive "sInfo topic (default = menu): ")
604 (Info-goto-node "(dir)")
605 (Info-goto-node (concat "(" file ")"))))
607 (defun Info-setup-initial ()
608 (let ((f Info-annotations-path))
610 (if (and (file-exists-p (car f)) (not (get-file-buffer (car f))))
611 (bury-buffer (find-file-noselect (car f))))
615 (defun Info-find-node (filename &optional nodename no-going-back tryfile line)
616 "Go to an info node specified as separate FILENAME and NODENAME.
617 Look for a plausible filename, or if not found then look for URL's and
618 dispatch to the appropriate fn. NO-GOING-BACK is non-nil if
619 recovering from an error in this function; it says do not attempt
620 further (recursive) error recovery. TRYFILE is ??"
625 ;; empty filename is simple case
627 (Info-find-file-node nil nodename no-going-back tryfile line))
628 ;; Convert filename to lower case if not found as specified.
629 ;; Expand it, look harder...
630 ((let ((fname (substitute-in-file-name filename))
633 ;; If specified name starts with `./', then just try
634 ;; current directory. No point in searching for an absolute
636 ((string-match "^\\./" fname)
637 (list default-directory))
638 ((file-name-absolute-p fname)
640 (Info-additional-search-directory-list
641 (append Info-directory-list
642 Info-additional-search-directory-list))
643 (t Info-directory-list))))
644 ;; Search the directory list for file FNAME.
645 (while (and dirs (not found))
646 (setq temp (expand-file-name fname (car dirs)))
647 (setq found (Info-suffixed-file temp))
648 (setq dirs (cdr dirs)))
650 (progn (setq filename (expand-file-name found))
652 (Info-find-file-node filename nodename no-going-back tryfile line))
653 ;; Look for a URL. This pattern is stolen from w3.el to prevent
654 ;; loading it if we won't need it.
655 ((string-match (concat "^\\(wais\\|solo\\|x-exec\\|newspost\\|www\\|"
656 "mailto\\|news\\|tn3270\\|ftp\\|http\\|file\\|"
657 "telnet\\|gopher\\):")
659 (if (fboundp 'browse-url)
660 (browse-url filename)
661 (error "Cannot follow URLs in this XEmacs")))
663 (error "Info file %s does not exist" filename))))
665 (defun Info-find-file-node (filename nodename
666 &optional no-going-back tryfile line)
667 ;; This is the guts of what was Info-find-node. Whoever wrote this
668 ;; should be locked up where they can't do any more harm.
670 ;; Go into info buffer.
671 (or (eq major-mode 'Info-mode)
672 (switch-to-buffer "*info*"))
673 (buffer-disable-undo (current-buffer))
674 (run-hooks 'Info-startup-hook)
675 (or (eq major-mode 'Info-mode)
678 (equal Info-current-file filename)
680 (string= "dir" (file-name-nondirectory Info-current-file))
682 (format "Leave Info file `%s'? "
683 (file-name-nondirectory Info-current-file)))
686 ;; Record the node we are leaving.
687 (if (and Info-current-file (not no-going-back))
688 (Info-history-add Info-current-file Info-current-node (point)))
690 (setq Info-current-node nil
691 Info-in-cross-reference nil)
694 ;; Switch files if necessary
696 (equal Info-current-file filename)
697 (let ((buffer-read-only nil))
698 (setq Info-current-file nil
699 Info-current-subfile nil
700 Info-current-file-completions nil
701 Info-index-alternatives nil
703 buffer-file-truename nil)
705 (if (string= "dir" (file-name-nondirectory filename))
707 (Info-insert-file-contents filename t)
708 (setq default-directory (file-name-directory filename)))
709 (set-buffer-modified-p nil)
710 ;; See whether file has a tag table. Record the location if yes.
711 (set-marker Info-tag-table-marker nil)
712 (goto-char (point-max))
714 (or (equal nodename "*")
715 (not (search-forward "\^_\nEnd tag table\n" nil t))
717 ;; We have a tag table. Find its beginning.
718 ;; Is this an indirect file?
719 (search-backward "\nTag table:\n")
723 (looking-at "(Indirect)\n"))
724 ;; It is indirect. Copy it to another buffer
725 ;; and record that the tag table is in that buffer.
726 (let ((buf (current-buffer))
727 (m Info-tag-table-marker))
729 Info-tag-table-buffer
731 Info-tag-table-buffer
732 (generate-new-buffer " *info tag table*")))
734 (set-buffer Info-tag-table-buffer)
735 (buffer-disable-undo (current-buffer))
736 (setq case-fold-search t)
738 (insert-buffer-substring buf)
739 (set-marker m (match-end 0))))
740 (set-marker Info-tag-table-marker pos))))
741 (setq Info-current-file
742 (file-name-sans-versions buffer-file-name))))
743 (if (equal nodename "*")
744 (progn (setq Info-current-node nodename)
746 (goto-char (point-min)))
747 ;; Search file for a suitable node.
748 (let* ((qnode (regexp-quote nodename))
749 (regexp (concat "Node: *" qnode " *[,\t\n\177]"))
750 (guesspos (point-min))
752 ;; First get advice from tag table if file has one.
753 ;; Also, if this is an indirect info file,
754 ;; read the proper subfile into this buffer.
755 (if (marker-position Info-tag-table-marker)
756 (let (foun found-mode (m Info-tag-table-marker))
758 (set-buffer (marker-buffer Info-tag-table-marker))
760 (setq foun (re-search-forward regexp nil t))
762 (setq guesspos (read (current-buffer))))
763 (setq found-mode major-mode))
765 ;; If this is an indirect file,
766 ;; determine which file really holds this node
768 (if (not (eq major-mode found-mode))
770 (Info-read-subfile guesspos))))))
771 (goto-char (max (point-min) (- guesspos 1000)))
772 ;; Now search from our advised position (or from beg of buffer)
773 ;; to find the actual node.
775 (while (search-forward "\n\^_" nil t)
779 (if (re-search-backward regexp beg t)
782 (let ((bufs (delq nil (mapcar 'get-file-buffer
783 Info-annotations-path)))
784 (pattern (if (string-match "\\`<<.*>>\\'" qnode) qnode
785 (format "\"%s\"\\|<<%s>>" qnode qnode)))
786 (pat2 (concat "------ *File: *\\([^ ].*[^ ]\\) *Node: "
787 "*\\([^ ].*[^ ]\\) *Line: *\\([0-9]+\\)"))
788 (afile nil) anode aline)
789 (while (and bufs (not anode))
791 (set-buffer (car bufs))
792 (goto-char (point-min))
793 (if (re-search-forward pattern nil t)
794 (if (re-search-backward pat2 nil t)
795 (setq afile (buffer-substring (match-beginning 1)
797 anode (buffer-substring (match-beginning 2)
800 (buffer-substring (match-beginning 3)
802 (setq bufs (cdr bufs)))
804 (Info-find-node afile anode t nil aline)
807 (Info-find-node nodename "Top" t)
809 (or Info-current-node
810 (error "No such node: %s" nodename)))
814 (goto-char (point-min))
815 (if line (forward-line line)))))))
816 ;; If we did not finish finding the specified node,
817 ;; go back to the previous one.
818 (or Info-current-node no-going-back
819 (let ((hist (car Info-history)))
820 ;; The following is no longer safe with new Info-history system
821 ;; (setq Info-history (cdr Info-history))
822 (Info-goto-node (car hist) t)
823 (goto-char (+ (point-min) (nth 1 hist)))))))
825 ;; Cache the contents of the (virtual) dir file, once we have merged
826 ;; it for the first time, so we can save time subsequently.
827 (defvar Info-dir-contents nil)
829 ;; Cache for the directory we decided to use for the default-directory
830 ;; of the merged dir text.
831 (defvar Info-dir-contents-directory nil)
833 ;; Record the file attributes of all the files from which we
834 ;; constructed Info-dir-contents.
835 (defvar Info-dir-file-attributes nil)
837 (defun Info-insert-dir ()
838 "Construct the Info directory node by merging the files named
839 \"dir\" or \"localdir\" from the directories in `Info-directory-list'.
840 The \"dir\" files will take precedence in cases where both exist. It
841 sets the *info* buffer's `default-directory' to the first directory we
842 actually get any text from."
843 (if (and Info-dir-contents Info-dir-file-attributes
844 ;; Verify that none of the files we used has changed
847 (mapcar #'(lambda (elt)
848 (let ((curr (file-attributes (car elt))))
849 ;; Don't compare the access time.
850 (if curr (setcar (nthcdr 4 curr) 0))
851 (setcar (nthcdr 4 (cdr elt)) 0)
852 (equal (cdr elt) curr)))
853 Info-dir-file-attributes))))
854 (insert Info-dir-contents)
855 (let ((dirs (reverse Info-directory-list))
856 buffers lbuffers buffer others nodes dirs-done)
858 (setq Info-dir-file-attributes nil)
860 ;; Search the directory list for the directory file.
862 (let ((truename (file-truename (expand-file-name (car dirs)))))
863 (or (member truename dirs-done)
864 (member (directory-file-name truename) dirs-done)
865 ;; Karl Berry recently added the ability all possibilities for
866 ;; extension as for normal info files. This code however is
867 ;; still unsatisfactory: if one day, we find a compressed dir
868 ;; file (which looks possible), we should be able to handle it
869 ;; (which means decompress and read it, update it, save and
870 ;; recompress it). --dv
871 (let ((trials '("dir" "DIR"
872 "dir.info" "DIR.INFO"
874 "localdir" "LOCALDIR"
875 "localdir.info" "LOCALDIR.INFO"
876 "localdir.inf" "LOCALDIR.INF"))
879 (while (setq file (pop trials))
880 (setq file (expand-file-name file truename))
881 (and (setq attrs (file-attributes file))
884 (setq file (expand-file-name "dir" truename)))
887 (cons (directory-file-name truename)
889 (Info-maybe-update-dir file)
890 (setq attrs (file-attributes file))
891 (if (or (setq buf (find-buffer-visiting file))
895 (message "Composing main Info directory..."))
898 (if (string-match "localdir" file)
902 (insert-file-contents file))
903 (if (string-match "localdir" (buffer-name))
904 (setq lbuffers (cons (current-buffer) lbuffers))
905 (setq buffers (cons (current-buffer) buffers)))
907 (setq Info-dir-file-attributes
908 (cons (cons file attrs)
909 Info-dir-file-attributes)))))))
910 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs)))
911 (setq dirs (cdr dirs))))
913 ;; ensure that the localdir files are inserted last, and reverse
914 ;; the list of them so that when they get pushed in, they appear
915 ;; in the same order they got specified in the path, from top to
917 (nconc buffers (reverse lbuffers))
920 (error "Can't find the Info directory node"))
921 ;; Distinguish the dir file that comes with Emacs from all the
922 ;; others. Yes, that is really what this is supposed to do.
923 ;; If it doesn't work, fix it.
924 (setq buffer (car buffers)
925 ;; reverse it since they are pushed down from the top. the
926 ;; `Info-directory-list can be specified in natural order
928 others (reverse (cdr buffers)))
930 ;; Insert the entire original dir file as a start; note that we've
931 ;; already saved its default directory to use as the default
932 ;; directory for the whole concatenation.
933 (insert-buffer buffer)
935 ;; Look at each of the other buffers one by one.
937 (let ((other (car others))
938 (info-buffer (current-buffer)))
939 (if (string-match "localdir" (buffer-name other))
941 (set-buffer info-buffer)
942 (goto-char (point-max))
944 ((re-search-backward "^ *\\* *Locals *: *$" nil t)
945 (delete-region (match-beginning 0) (match-end 0)))
946 ;; look for a line like |Local XEmacs packages:
947 ;; or mismatch on some text ...
948 ((re-search-backward Info-localdir-heading-regexp nil t)
949 ;; This is for people who underline topic headings with
950 ;; equal signs or dashes.
951 (when (save-excursion
954 (looking-at "^[ \t]*[-=*]+"))
958 (t (search-backward "\^L" nil t)))
959 ;; Insert menu part of the file
961 (len (length (buffer-string nil nil other))))
962 (insert (buffer-string nil nil other))
963 (goto-char (+ pt len))
966 (if (search-forward "* Menu:" (+ pt len) t)
969 (delete-region pt (point)))))))
970 ;; In each, find all the menus.
973 (goto-char (point-min))
974 ;; Find each menu, and add an elt to NODES for it.
975 (while (re-search-forward "^\\* Menu:" nil t)
976 (let (beg nodename end)
979 (search-backward "\n\^_")
980 (search-forward "Node: ")
981 (setq nodename (Info-following-node-name))
982 (search-forward "\n\^_" nil 'move)
985 (setq nodes (cons (list nodename other beg end) nodes))))))
986 (setq others (cdr others))))
988 ;; Add to the main menu a menu item for each other node.
989 (re-search-forward "^\\* Menu:" nil t)
991 (let ((menu-items '("top"))
994 (end (save-excursion (search-forward "\^_" nil t) (point))))
996 (let ((nodename (car (car nodes))))
998 (or (member (downcase nodename) menu-items)
999 (re-search-forward (concat "^\\* "
1000 (regexp-quote nodename)
1004 (insert "* " nodename "::" "\n")
1005 (setq menu-items (cons nodename menu-items))))))
1006 (setq nodes (cdr nodes))))
1007 ;; Now take each node of each of the other buffers
1008 ;; and merge it into the main buffer.
1010 (let ((nodename (car (car nodes))))
1011 (goto-char (point-min))
1012 ;; Find the like-named node in the main buffer.
1013 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
1014 (regexp-quote nodename)
1018 (search-forward "\n\^_" nil 'move)
1021 ;; If none exists, add one.
1022 (goto-char (point-max))
1023 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
1024 ;; Merge the text from the other buffer's menu
1025 ;; into the menu in the like-named node in the main buffer.
1026 (apply 'insert-buffer-substring (cdr (car nodes))))
1027 (setq nodes (cdr nodes)))
1028 ;; Kill all the buffers we just made.
1030 (kill-buffer (car buffers))
1031 (setq buffers (cdr buffers)))
1033 (kill-buffer (car lbuffers))
1034 (setq lbuffers (cdr lbuffers)))
1035 (message "Composing main Info directory...done"))
1036 (setq Info-dir-contents (buffer-string)))
1037 (setq default-directory (file-name-as-directory Info-dir-contents-directory))
1038 (setq buffer-file-name (caar Info-dir-file-attributes)
1039 buffer-file-truename (file-truename buffer-file-name)))
1041 (defmacro Info-directory-files (dir-file &optional all full nosort files-only)
1042 "Return a list of Info files living in the same directory as DIR-FILE.
1043 This list actually contains the files living in this directory, except for
1044 the dir file itself and the secondary info files (foo-1 foo-2 etc).
1046 If the optional argument ALL is non nil, the secondary info files are also
1047 included in the list.
1049 Please refer to the function `directory-files' for the meaning of the other
1050 optional arguments."
1051 `(let* ((dir (file-name-directory ,dir-file))
1052 (all-files (remove ,dir-file (directory-files dir ',full nil ',nosort
1056 (remove (concat dir ".")
1057 (remove (concat dir "..") all-files))
1059 (remove ".." all-files))))
1063 (concat "-[0-9]+\\("
1064 ;; Extract all known compression suffixes from
1065 ;; Info-suffix-list. These suffixes can typically be
1066 ;; found in entries of the form `.info.something'.
1067 (let ((suff-list Info-suffix-list)
1069 (while (setq suff (pop suff-list))
1070 (and (string-match "^\\.info" (car suff))
1071 (setq regexp (concat regexp
1075 (and suff-list "\\|")))))
1079 (while (setq file (pop all-files))
1080 (or (string-match suff-match file)
1081 (push file info-files)))
1082 (reverse info-files)
1086 (defun Info-maybe-update-dir (file)
1087 "Rebuild dir or localdir according to `Info-auto-generate-directory'."
1088 (unless (or (not (file-exists-p (file-name-directory file)))
1089 (null (Info-directory-files file 'all)))
1090 (if (not (find-buffer-visiting file))
1091 (if (not (file-exists-p file))
1092 (if (or (memq Info-auto-generate-directory
1093 '(always if-missing if-outdated)))
1094 (Info-build-dir-anew (file-name-directory file)))
1095 (if (or (eq Info-auto-generate-directory 'always)
1096 (and (eq Info-auto-generate-directory 'if-outdated)
1097 (Info-dir-outdated-p file)))
1098 (Info-rebuild-dir file))))))
1100 ;; Record which *.info files are newer than the dir file
1101 (defvar Info-dir-newer-info-files nil)
1103 (defun Info-dir-outdated-p (file)
1104 "Return non-nil if dir or localdir is outdated.
1105 dir or localdir are outdated when an info file in the same
1106 directory has been modified more recently."
1107 (let ((dir-mod-time (nth 5 (file-attributes file)))
1109 (setq Info-dir-newer-info-files nil)
1113 (setq f-mod-time (nth 5 (file-attributes f)))
1114 (setq newer (or (> (car f-mod-time) (car dir-mod-time))
1115 (and (= (car f-mod-time) (car dir-mod-time))
1116 (> (car (cdr f-mod-time))
1117 (car (cdr dir-mod-time))))))
1118 (if (and (file-readable-p f) newer)
1119 (setq Info-dir-newer-info-files
1120 (cons f Info-dir-newer-info-files)))))
1121 (Info-directory-files file nil 'fullname 'nosort t))
1122 Info-dir-newer-info-files))
1124 (defun Info-extract-dir-entry-from (file)
1125 "Extract the dir entry from the info FILE.
1126 The dir entry is delimited by the markers `START-INFO-DIR-ENTRY'
1127 and `END-INFO-DIR-ENTRY'."
1129 (set-buffer (get-buffer-create " *Info-tmp*"))
1130 (when (file-readable-p file)
1131 (insert-file-contents file nil nil nil t)
1132 (goto-char (point-min))
1134 (unless (null (re-search-forward "^START-INFO-DIR-ENTRY" nil t))
1137 (unless (null (re-search-forward "^END-INFO-DIR-ENTRY" nil t))
1138 (goto-char (match-beginning 0))
1139 (car (Info-parse-dir-entries beg (point)))))))))
1141 ;; Parse dir entries contained between START and END into a list of the form
1142 ;; (filename topic node (description-line-1 description-line-2 ...))
1143 (defun Info-parse-dir-entries (start end)
1144 (let (entry entries)
1147 (narrow-to-region start end)
1149 (while (re-search-forward
1150 "^\\* \\([^:]+\\):\\([ \t]*(\\([^)]*\\))\\w*\\.\\|:\\)" nil t)
1151 (setq entry (list (match-string 2)
1153 (downcase (or (match-string 3)
1154 (match-string 1)))))
1161 (re-search-forward "[ \t]*" nil t)
1162 (or (and (re-search-forward "^[^ \t]" nil t)
1163 (goto-char (match-beginning 0)))
1165 "[ \t]*\n[ \t]*"))))
1167 (setq entries (cons (nreverse entry) entries)))))
1168 (nreverse entries)))
1170 (defun Info-dump-dir-entries (entries)
1174 (mapcar #'(lambda (e)
1175 (setq e (cdr e)) ; Drop filename
1176 (setq len (length (concat (car e)
1178 (if (> len description-col)
1179 (setq description-col len)))
1181 (setq description-col (+ 5 description-col))
1182 (mapcar #'(lambda (e)
1183 (setq e (cdr e)) ; Drop filename
1184 (insert "* " (car e) ":" (car (cdr e)))
1185 (setq e (car (cdr (cdr e))))
1187 (indent-to-column description-col)
1188 (insert (car e) "\n")
1194 (defun Info-build-dir-anew (directory)
1195 "Build info directory information for DIRECTORY.
1196 The generated directory listing may be saved to a `dir' according
1197 to the value of `Info-save-auto-generated-dir'."
1199 (let* ((dirfile (expand-file-name "dir" directory))
1200 (to-temp (or (null Info-save-auto-generated-dir)
1201 (eq Info-save-auto-generated-dir 'never)
1202 (and (not (file-writable-p dirfile))
1203 (message "File not writable %s. Using temporary."
1205 (info-files (Info-directory-files dirfile nil 'fullname nil t)))
1207 (message "Creating temporary dir in %s..." directory)
1208 (message "Creating %s..." dirfile))
1209 (set-buffer (find-file-noselect dirfile t))
1210 (setq buffer-read-only nil)
1212 (insert Info-dir-prologue "Info files in " directory ":\n\n")
1213 (Info-dump-dir-entries
1216 (or (Info-extract-dir-entry-from f)
1218 (progn (string-match "\\([^.]*\\)\\(\\..*\\)?$"
1219 (file-name-nondirectory f))
1221 (match-string 1 (file-name-nondirectory f))))
1223 (list Info-no-description-string))))
1226 (set-buffer-modified-p nil)
1229 (message "Creating temporary dir in %s...done" directory)
1230 (message "Creating %s...done" dirfile)))))
1233 (defun Info-rebuild-dir (file)
1234 "Build info directory information in the directory of dir FILE.
1235 Description of info files are merged from the info files in the
1236 directory and the contents of FILE with the description in info files
1237 taking precedence over descriptions in FILE.
1238 The generated directory listing may be saved to a `dir' according to
1239 the value of `Info-save-auto-generated-dir'."
1242 (let (dir-section-contents dir-full-contents
1248 (or (null Info-save-auto-generated-dir)
1249 (eq Info-save-auto-generated-dir 'never)
1250 (and (eq Info-save-auto-generated-dir 'always)
1251 (not (file-writable-p file))
1252 (message "File not writable %s. Using temporary." file))
1253 (and (eq Info-save-auto-generated-dir 'conservative)
1254 (or (and (not (file-writable-p file))
1256 "File not writable %s. Using temporary." file))
1258 (message "%s is outdated. Overwrite ? "
1260 (set-buffer (find-file-noselect file t))
1261 (setq buffer-read-only nil)
1263 (message "Rebuilding temporary %s..." file)
1264 (message "Rebuilding %s..." file))
1266 (setq buffer-read-only nil)
1267 (goto-char (point-min))
1268 (unless (and (search-forward "\^_")
1269 (re-search-forward "^\\* Menu:.*$" nil t)
1270 (setq mark (and (re-search-forward "^\\* " nil t)
1271 (match-beginning 0))))
1273 (setq dir-full-contents (Info-parse-dir-entries mark (point-max)))
1274 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$"
1276 (match-beginning 0))
1279 (narrow-to-region mark next-section)
1280 (setq dir-section-contents (nreverse (Info-parse-dir-entries
1281 (point-min) (point-max))))
1284 (setq dir-entry (assoc (downcase
1285 (file-name-sans-extension
1286 (file-name-nondirectory file)))
1287 dir-section-contents)
1288 file-dir-entry (Info-extract-dir-entry-from file))
1291 ;; A dir entry in the info file takes precedence over
1292 ;; an existing entry in the dir file
1293 (setcdr dir-entry (cdr file-dir-entry)))
1294 (unless (or not-first-section
1296 (file-name-sans-extension
1297 (file-name-nondirectory file)))
1300 (setq dir-section-contents
1301 (cons file-dir-entry dir-section-contents))
1302 (setq dir-section-contents
1304 (capitalize (file-name-sans-extension
1305 (file-name-nondirectory
1308 (list Info-no-description-string))
1309 dir-section-contents))))))
1310 Info-dir-newer-info-files)
1311 (delete-region (point-min) (point-max))
1312 (Info-dump-dir-entries (nreverse dir-section-contents))
1314 (if (= next-section (point-max))
1315 (setq next-section nil)
1316 (or (setq mark (and (re-search-forward "^\\* " nil t)
1317 (match-beginning 0)))
1319 (setq next-section (or (and (re-search-forward
1320 "^[^* \t].*:[ \t]*$" nil t)
1321 (match-beginning 0))
1323 (setq not-first-section t)))
1326 (set-buffer-modified-p nil)
1327 (message "Rebuilding temporary %s...done" file))
1329 (message "Rebuilding %s...done" file))))))
1332 (defun Info-batch-rebuild-dir ()
1333 "(Re)build `dir' files in the directories remaining on the command line.
1334 Use this from the command line, with `-batch', it won't work in an
1337 Each file is processed even if an error occurred previously. For example,
1338 invoke \"xemacs -batch -f Info-batch-rebuild-dir /usr/local/info\"."
1339 ;; command-line-args-left is what is left of the command line (from
1341 (defvar command-line-args-left) ; Avoid 'free variable' warning
1342 (if (not noninteractive)
1343 (error "`Info-batch-rebuild-dir' is to be used only with -batch"))
1344 (let ((Info-save-auto-generated-dir 'always)
1346 (while command-line-args-left
1347 (if (not (file-directory-p (car command-line-args-left)))
1348 (message "Warning: Skipped %s. Not a directory."
1349 (car command-line-args-left))
1350 (setq dir (expand-file-name "dir" (car command-line-args-left)))
1351 (setq localdir (expand-file-name "localdir"
1352 (car command-line-args-left)))
1354 ((file-exists-p dir)
1355 (Info-rebuild-dir dir))
1356 ((file-exists-p localdir)
1357 (Info-rebuild-dir localdir))
1359 (Info-build-dir-anew (car command-line-args-left)))))
1360 (setq command-line-args-left (cdr command-line-args-left)))
1364 (defun Info-history-add (file node point)
1365 (if Info-keeping-history
1366 (let* ((name (format "(%s)%s" (Info-file-name-only file) node))
1367 (found (assoc name Info-history)))
1369 (setq Info-history (delq found Info-history)))
1370 (setq Info-history (cons (list name (- point (point-min))
1371 (and (eq (window-buffer)
1373 (- (window-start) (point-min))))
1376 (defun Info-file-name-only (file)
1377 (let ((dir (file-name-directory file))
1378 (p Info-directory-list))
1379 (while (and p (not (equal (car p) dir)))
1381 (if p (file-name-nondirectory file) file)))
1383 (defun Info-read-subfile (nodepos)
1387 (set-buffer (marker-buffer Info-tag-table-marker))
1388 (goto-char (point-min))
1389 (search-forward "\n\^_")
1392 (while (not (looking-at "\^_"))
1394 (let ((start (point))
1395 thisfilepos thisfilename)
1396 (search-forward ": ")
1397 (setq thisfilename (buffer-substring start (- (point) 2)))
1398 (setq thisfilepos (read (current-buffer)))
1399 ;; read in version 19 stops at the end of number.
1400 ;; Advance to the next line.
1403 (if (> thisfilepos nodepos)
1405 (setq lastfilename thisfilename)
1406 (setq lastfilepos thisfilepos))
1408 (or (equal Info-current-subfile lastfilename)
1409 (let ((buffer-read-only nil))
1410 (setq buffer-file-name nil
1411 buffer-file-truename nil)
1414 (Info-insert-file-contents (Info-suffixed-file
1415 (expand-file-name lastfilename
1416 (file-name-directory
1420 (set-buffer-modified-p nil)
1421 (setq Info-current-subfile lastfilename)))
1422 (goto-char (point-min))
1423 (search-forward "\n\^_")
1424 (+ (- nodepos lastfilepos) (point))))
1426 (defun Info-all-case-regexp (str)
1432 (setq c (aref str i))
1433 (cond ((or (and (>= c ?A) (<= c ?Z))
1434 (and (>= c ?a) (<= c ?z)))
1435 (setq regexp (concat regexp
1437 (char-to-string (downcase c))
1439 (char-to-string (upcase c))
1442 (setq regexp (concat regexp (char-to-string c)))))
1446 (defun Info-suffixed-file (name &optional exact)
1447 "Look for an info file named NAME. This function tries to be smart in
1448 finding the file corresponding to NAME: if it doesn't exist, several
1449 variants are looked for, notably by appending suffixes from
1450 `Info-suffix-list' and by trying to change the characters case in NAME.
1452 The optional argument EXACT prevents this function from trying different case
1453 versions of NAME. Only the suffixes are tried."
1455 ;; First, try NAME alone:
1456 (and (file-regular-p name) (throw 'found name))
1457 ;; Then, try different variants
1458 (let ((suff-match (concat "\\("
1459 (let ((suff-list Info-suffix-list)
1461 (while (setq suff (pop suff-list))
1464 (regexp-quote (car suff))
1465 (and suff-list "\\|"))))
1468 (dir (file-name-directory name))
1470 (setq name (file-name-nondirectory name))
1472 (condition-case data ;; protect against invalid directory
1473 ;; First, try NAME[.<suffix>]
1475 (directory-files dir 'fullname
1476 (concat "^" (regexp-quote name) suff-match)
1480 ;; Then, try to match the name independantly of the
1482 (directory-files dir 'fullname
1483 (Info-all-case-regexp
1489 (display-warning 'info
1490 (format "directory `%s' error: %s" dir data))
1492 (while (setq file (pop files))
1493 (and (file-regular-p file)
1494 (throw 'found file)))
1497 (defun Info-insert-file-contents (file &optional visit)
1498 (setq file (expand-file-name file default-directory))
1499 (let ((suff Info-suffix-list)
1502 (setq len (length (car (car suff))))
1503 (or (<= (length file) len)
1505 (equal (substring file (- len))
1507 (equal (substring file (- len))
1508 (upcase (car (car suff)))))
1510 (setq suff (cdr suff)))
1511 (if (stringp (cdr (car suff)))
1512 (let ((command (if (string-match "%s" (cdr (car suff)))
1513 (format (cdr (car suff)) file)
1514 (concat (cdr (car suff)) " < " file))))
1515 (message "%s..." command)
1516 (call-process shell-file-name nil t nil shell-command-switch command)
1519 (setq buffer-file-name file
1520 buffer-file-truename (file-truename buffer-file-name))
1521 (set-buffer-modified-p nil)
1522 (clear-visited-file-modtime)))
1523 (insert-file-contents file visit))))
1525 (defun Info-select-node ()
1526 "Select the node that point is in, after using `g *' to select whole file."
1530 ;; Find beginning of node.
1531 (search-backward "\n\^_")
1533 ;; Get nodename spelled as it is in the node.
1534 (re-search-forward "Node:[ \t]*")
1535 (setq Info-current-node
1536 (buffer-substring (point)
1538 (skip-chars-forward "^,\t\n")
1540 (Info-set-mode-line)
1541 ;; Find the end of it, and narrow.
1543 (let (active-expression)
1544 (narrow-to-region (point)
1545 (if (re-search-forward "\n[\^_\f]" nil t)
1548 (if (looking-at "[\n\^_\f]*execute: ")
1550 (goto-char (match-end 0))
1551 (setq active-expression
1552 (read (current-buffer))))))
1554 (or (equal Info-footnote-tag "Note")
1556 (goto-char (point-min))
1557 (let ((buffer-read-only nil)
1558 (bufmod (buffer-modified-p))
1559 (case-fold-search t))
1560 (while (re-search-forward "\\*[Nn]ote\\([ \n]\\)" nil t)
1561 (replace-match (concat "*" Info-footnote-tag "\ ")))
1562 (set-buffer-modified-p bufmod))))
1563 (Info-reannotate-node)
1564 ;; XEmacs: remove v19 test
1566 (Info-fontify-node))
1567 (run-hooks 'Info-select-hook)
1568 (if Info-enable-active-nodes (eval active-expression)))))
1570 (defun Info-set-mode-line ()
1571 (setq modeline-buffer-identification
1572 (list (cons modeline-buffer-id-left-extent "Info: ")
1573 (cons modeline-buffer-id-right-extent
1576 (if Info-current-file
1577 (let ((name (file-name-nondirectory
1578 Info-current-file)))
1579 (if (string-match "^\\([^.]*\\)\\..*$" name)
1580 (match-string 1 name)
1584 (or Info-current-node ""))))))
1586 ;; Go to an info node specified with a filename-and-nodename string
1587 ;; of the sort that is found in pointers in nodes.
1590 (defun Info-goto-node (nodename &optional no-going-back tryfile)
1591 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME.
1592 Actually, the following interpretations of NAME are tried in order:
1594 (FILENAME) (using Top node)
1595 NODENAME (in current file)
1597 FILENAME (using Top node)
1598 where TAGNAME is a string that appears in quotes: \"TAGNAME\", in an
1599 annotation for any node of any file. (See `a' and `x' commands.)"
1600 (interactive (list (Info-read-node-name "Goto node, file or tag: ")
1603 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1605 (setq filename (if (= (match-beginning 1) (match-end 1))
1607 (substring nodename (match-beginning 2) (match-end 2)))
1608 nodename (substring nodename (match-beginning 3) (match-end 3)))
1609 (let ((trim (string-match "\\s *\\'" filename)))
1610 (if trim (setq filename (substring filename 0 trim))))
1611 (let ((trim (string-match "\\s *\\'" nodename)))
1612 (if trim (setq nodename (substring nodename 0 trim))))
1613 (Info-find-node (if (equal filename "") nil filename)
1614 (if (equal nodename "") "Top" nodename)
1615 no-going-back (and tryfile (equal filename "")))))
1617 (defun Info-goto-bookmark ()
1619 (let ((completion-ignore-case nil)
1620 (tag (completing-read "Goto tag: "
1621 (Info-build-annotation-completions)
1623 'Info-minibuffer-history)))
1624 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
1627 (defun Info-visit-file (file)
1628 "Directly visit an info file."
1629 (interactive "fVisit Info file: ")
1630 (Info-find-node (expand-file-name file) "Top"))
1632 (defun Info-restore-point (&optional always)
1633 "Restore point to same location it had last time we were in this node."
1635 (if (or Info-restoring-point always)
1636 (let* ((name (format "(%s)%s"
1637 (Info-file-name-only Info-current-file)
1639 (p (assoc name Info-history)))
1640 (if p (Info-restore-history-entry p)))))
1642 (defun Info-restore-history-entry (entry)
1643 (goto-char (+ (nth 1 entry) (point-min)))
1645 (get-buffer-window (current-buffer))
1646 (set-window-start (get-buffer-window (current-buffer))
1647 (+ (nth 2 entry) (point-min)))))
1649 (defvar Info-read-node-completion-table)
1651 ;; This function is used as the "completion table" while reading a node name.
1652 ;; It does completion using the alist in Info-read-node-completion-table
1653 ;; unless STRING starts with an open-paren.
1654 (defun Info-read-node-name-1 (string predicate code)
1655 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
1656 (cond ((eq code nil)
1659 (try-completion string Info-read-node-completion-table
1664 (all-completions string Info-read-node-completion-table
1669 (assoc string Info-read-node-completion-table))))))
1671 (defun Info-read-node-name (prompt &optional default)
1672 (Info-setup-initial)
1673 (let* ((completion-ignore-case t)
1674 (Info-read-node-completion-table (Info-build-node-completions))
1675 (nodename (completing-read prompt 'Info-read-node-name-1
1676 nil t nil 'Info-minibuffer-history
1678 (if (equal nodename "")
1680 (Info-read-node-name prompt))
1683 (defun Info-build-annotation-completions ()
1684 (or Info-current-annotation-completions
1686 (let ((bufs (delq nil (mapcar 'get-file-buffer
1687 Info-annotations-path)))
1690 (set-buffer (car bufs))
1691 (goto-char (point-min))
1692 (while (re-search-forward "<<\\(.*\\)>>" nil t)
1693 (setq compl (cons (list (buffer-substring (match-beginning 1)
1696 (setq bufs (cdr bufs)))
1697 (setq Info-current-annotation-completions compl)))))
1699 (defun Info-build-node-completions ()
1700 (or Info-current-file-completions
1701 (let ((m Info-tag-table-marker)
1702 (compl (Info-build-annotation-completions)))
1706 (if (marker-buffer Info-tag-table-marker)
1708 (set-buffer (marker-buffer Info-tag-table-marker))
1710 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
1712 (cons (list (buffer-substring (match-beginning 1)
1715 (goto-char (point-min))
1716 (while (search-forward "\n\^_" nil t)
1718 (let ((start (point)))
1720 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
1723 (cons (list (buffer-substring (match-beginning 1)
1726 (setq Info-current-file-completions compl))))
1728 (defvar Info-last-search nil
1729 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
1733 (defun Info-search (regexp)
1734 "Search for REGEXP, starting from point, and select node it's found in."
1736 (read-from-minibuffer
1737 (if Info-last-search
1738 (format "Search (regexp, default %s): "
1740 "Search (regexp): ")
1741 nil nil nil nil nil Info-last-search)))
1742 (setq Info-last-search regexp)
1743 (with-search-caps-disable-folding regexp t
1745 (onode Info-current-node)
1746 (ofile Info-current-file)
1748 (osubfile Info-current-subfile))
1752 (if (null Info-current-subfile)
1753 (progn (re-search-forward regexp) (setq found (point)))
1755 (progn (re-search-forward regexp) (setq found (point)))
1756 (search-failed nil)))))
1758 ;; can only happen in subfile case -- else would have erred
1762 (set-buffer (marker-buffer Info-tag-table-marker))
1763 (goto-char (point-min))
1764 (search-forward "\n\^_\nIndirect:")
1766 (narrow-to-region (point)
1767 (progn (search-forward "\n\^_")
1769 (goto-char (point-min))
1770 (search-forward (concat "\n" osubfile ": "))
1773 (re-search-forward "\\(^.*\\): [0-9]+$")
1774 (goto-char (+ (match-end 1) 2))
1775 (setq list (cons (cons (read (current-buffer))
1780 (goto-char (1+ (match-end 0))))
1781 (setq list (nreverse list)
1784 (message "Searching subfile %s..." (cdr (car list)))
1785 (Info-read-subfile (car (car list)))
1786 (setq list (cdr list))
1787 (goto-char (point-min))
1788 (if (re-search-forward regexp nil t)
1789 (setq found (point) list ())))
1792 (signal 'search-failed (list regexp))))
1794 (progn (Info-read-subfile opoint)
1796 (Info-select-node)))))
1800 (or (and (equal onode Info-current-node)
1801 (equal ofile Info-current-file))
1802 (Info-history-add ofile onode opoint)))))
1804 ;; Extract the value of the node-pointer named NAME.
1805 ;; If there is none, use ERRORNAME in the error message;
1806 ;; if ERRORNAME is nil, just return nil.
1807 (defun Info-extract-pointer (name &optional errorname)
1809 (goto-char (point-min))
1811 (let ((case-fold-search t))
1812 (if (re-search-backward (concat name ":") nil t)
1814 (goto-char (match-end 0))
1815 (Info-following-node-name))
1816 (if (eq errorname t)
1818 (error (concat "Node has no " (capitalize (or errorname name)))))))))
1820 ;; Return the node name in the buffer following point.
1821 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1822 ;; saying which chars may appear in the node name.
1823 (defun Info-following-node-name (&optional allowedchars)
1824 (skip-chars-forward " \t")
1828 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
1829 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
1830 (if (looking-at "(")
1831 (skip-chars-forward "^)")))
1832 (skip-chars-backward " .")
1835 (defun Info-next (&optional n)
1836 "Go to the next node of this node.
1837 A positive or negative prefix argument moves by multiple nodes."
1842 (while (>= (setq n (1- n)) 0)
1843 (Info-goto-node (Info-extract-pointer "next")))))
1845 (defun Info-prev (&optional n)
1846 "Go to the previous node of this node.
1847 A positive or negative prefix argument moves by multiple nodes."
1852 (while (>= (setq n (1- n)) 0)
1853 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))))
1855 (defun Info-up (&optional n)
1856 "Go to the superior node of this node.
1857 A positive prefix argument moves up several times."
1860 (while (>= (setq n (1- n)) 0)
1861 (Info-goto-node (Info-extract-pointer "up")))
1862 (if (interactive-p) (Info-restore-point)))
1864 (defun Info-last (&optional n)
1865 "Go back to the last node visited.
1866 With a prefix argument, go to Nth most recently visited node. History is
1867 circular; after oldest node, history comes back around to most recent one.
1868 Argument can be negative to go through the circle in the other direction.
1869 \(In other words, `l' is like \"undo\" and `C-u - l' is like \"redo\".)"
1873 (error "This is the first Info node you looked at"))
1874 (let ((len (1+ (length Info-history))))
1875 (setq n (% (+ n (* len 100)) len)))
1877 (let ((entry (nth (1- n) Info-history)))
1878 (Info-history-add Info-current-file Info-current-node (point))
1879 (while (>= (setq n (1- n)) 0)
1880 (setq Info-history (nconc (cdr Info-history)
1881 (list (car Info-history)))))
1882 (setq Info-history (cdr Info-history))
1883 (let ((Info-keeping-history nil))
1884 (Info-goto-node (car entry)))
1885 (Info-restore-history-entry entry))))
1887 (defun Info-directory ()
1888 "Go to the Info directory node."
1890 (Info-find-node "dir" "top"))
1892 (defun Info-follow-reference (footnotename)
1893 "Follow cross reference named NAME to the node it refers to.
1894 NAME may be an abbreviation of the reference name."
1896 (let ((completion-ignore-case t)
1897 completions default (start-point (point)) str i)
1899 (goto-char (point-min))
1900 (while (re-search-forward (format "\\*%s[ \n\t]*\\([^:]*\\):"
1903 (setq str (buffer-substring
1906 ;; See if this one should be the default.
1908 (< (match-beginning 0) start-point)
1909 (<= start-point (point))
1912 (while (setq i (string-match "[ \n\t]+" str i))
1913 (setq str (concat (substring str 0 i) " "
1914 (substring str (match-end 0))))
1916 ;; Record as a completion and perhaps as default.
1917 (if (eq default t) (setq default str))
1919 (cons (cons str nil)
1922 (let ((item (completing-read (if default
1923 (concat "Follow reference named: ("
1925 "Follow reference named: ")
1926 completions nil t nil
1927 'Info-minibuffer-history
1929 (if (and (string= item "") default)
1932 (error "No cross-references in this node"))))
1933 (let (target i (str (concat "\\*" Info-footnote-tag " "
1934 (regexp-quote footnotename))))
1935 (while (setq i (string-match " " str i))
1936 (setq str (concat (substring str 0 i) "\\([ \t\n]+\\)"
1937 (substring str (1+ i))))
1940 (goto-char (point-min))
1941 (or (re-search-forward str nil t)
1942 (error "No cross-reference named %s" footnotename))
1943 (goto-char (match-end 1))
1945 (Info-extract-menu-node-name "Bad format cross reference" t)))
1946 (while (setq i (string-match "[ \t\n]+" target i))
1947 (setq target (concat (substring target 0 i) " "
1948 (substring target (match-end 0))))
1950 (Info-goto-node target)
1951 (setq Info-in-cross-reference t)))
1953 (defun Info-next-reference (n)
1955 (let ((pat (format "\\*%s[ \n\t]*\\([^:]*\\):\\|^\\* .*:\\|<<.*>>"
1958 wrapped found-nomenu)
1960 (unless (re-search-backward pat nil t)
1961 ;; Don't wrap more than once in a buffer where only the
1962 ;; menu references are found.
1963 (when (and wrapped (not found-nomenu))
1965 (error "No cross references in this node"))
1967 (goto-char (point-max))
1968 (unless (re-search-backward pat nil t)
1970 (error "No cross references in this node")))
1971 (unless (save-excursion
1972 (goto-char (match-beginning 0))
1973 (when (looking-at "\\* Menu:")
1975 (setq found-nomenu t))
1978 (or (eobp) (forward-char 1))
1979 (unless (re-search-forward pat nil t)
1980 (when (and wrapped (not found-nomenu))
1982 (error "No cross references in this node"))
1984 (goto-char (point-min))
1985 (unless (re-search-forward pat nil t)
1987 (error "No cross references in this node")))
1988 (unless (save-excursion
1989 (goto-char (match-beginning 0))
1990 (when (looking-at "\\* Menu:")
1992 (setq found-nomenu t))
1994 (when (looking-at "\\* Menu:")
1995 (error "No cross references in this node"))
1996 (goto-char (match-beginning 0))))
1998 (defun Info-prev-reference (n)
2000 (Info-next-reference (- n)))
2002 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
2003 (skip-chars-forward " \t\n")
2004 (let ((start (point))
2006 (skip-chars-forward "^:")
2009 (if (looking-at ":")
2010 (buffer-substring start (1- (point)))
2011 (skip-chars-forward " \t\n")
2013 ;; Allow dots in node name not followed by whitespace.
2015 (concat "\\(([^)]+)[^.,"
2016 (if multi-line "" "\n")
2018 (if multi-line "" "\n")
2019 ;; We consider dots followed by newline as
2020 ;; end of nodename even if multil-line.
2021 ;; Also stops at .). It is generated by @pxref.
2022 ;; Skips sequential dots.
2023 "]\\|\\.+[^ \t\n)]\\)+\\)"))
2025 (while (setq i (string-match "\n" str i))
2029 (defun Info-menu (menu-item)
2030 "Go to node for menu item named (or abbreviated) NAME.
2031 Completion is allowed, and the menu item point is on is the default."
2033 (let ((completions '())
2034 ;; If point is within a menu item, use that item as the default
2039 (goto-char (point-min))
2040 (let ((case-fold-search t))
2041 (if (not (search-forward "\n* menu:" nil t))
2042 (error "No menu in this node")))
2043 (while (re-search-forward
2044 "\n\\* \\([^:\t\n]*\\):" nil t)
2045 (if (and (null default)
2046 (prog1 (if last (< last p) nil)
2047 (setq last (match-beginning 0)))
2049 (setq default (car (car completions))))
2050 (setq completions (cons (cons (buffer-substring
2053 (match-beginning 1))
2055 (if (and (null default) last
2057 (<= p (progn (end-of-line) (point))))
2058 (setq default (car (car completions)))))
2061 (setq item (let ((completion-ignore-case t))
2062 (completing-read (if default
2063 (format "Menu item (default %s): "
2066 completions nil t nil
2067 'Info-minibuffer-history
2069 ;; we rely on the fact that completing-read accepts an input
2070 ;; of "" even when the require-match argument is true and ""
2071 ;; is not a valid possibility
2072 (if (string= item "")
2078 ;; there is a problem here in that if several menu items have the same
2079 ;; name you can only go to the node of the first with this command.
2080 (Info-goto-node (Info-extract-menu-item menu-item) nil t))
2082 (defun Info-extract-menu-item (menu-item &optional noerror)
2084 (goto-char (point-min))
2085 (if (let ((case-fold-search t))
2086 (search-forward "\n* menu:" nil t))
2087 (if (or (search-forward (concat "\n* " menu-item ":") nil t)
2088 (search-forward (concat "\n* " menu-item) nil t))
2092 (Info-extract-menu-node-name))
2093 (and (not noerror) (error "No such item in menu")))
2094 (and (not noerror) (error "No menu in this node")))))
2096 ;; If COUNT is nil, use the last item in the menu.
2097 (defun Info-extract-menu-counting (count &optional noerror noindex)
2099 (goto-char (point-min))
2100 (if (let ((case-fold-search t))
2101 (and (search-forward "\n* menu:" nil t)
2103 (not (string-match "\\<Index\\>" Info-current-node)))))
2104 (if (search-forward "\n* " nil t count)
2107 (while (search-forward "\n* " nil t)))
2108 (Info-extract-menu-node-name))
2109 (and (not noerror) (error "Too few items in menu")))
2110 (and (not noerror) (error "No menu in this node")))))
2112 (defun Info-nth-menu-item (n)
2113 "Go to the node of the Nth menu item."
2115 (or n (setq n (- last-command-char ?0)))
2116 (if (< n 1) (error "Index must be at least 1"))
2117 (Info-goto-node (Info-extract-menu-counting n) nil t))
2119 (defun Info-last-menu-item ()
2120 "Go to the node of the tenth menu item."
2122 (Info-goto-node (Info-extract-menu-counting nil) nil t))
2125 "Go to the Top node of this file."
2127 (Info-goto-node "Top"))
2130 "Go to the final node in this file."
2133 (let ((Info-keeping-history nil)
2135 (Info-last-menu-item)
2136 (while (setq node (or (Info-extract-pointer "next" t)
2137 (Info-extract-menu-counting nil t t)))
2138 (Info-goto-node node))
2139 (or (equal (Info-extract-pointer "up" t) "Top")
2140 (let ((executing-kbd-macro "")) ; suppress messages
2142 (Info-global-next 10000)
2145 (defun Info-global-next (&optional n)
2146 "Go to the next node in this file, traversing node structure as necessary.
2147 This works only if the Info file is structured as a hierarchy of nodes.
2148 A positive or negative prefix argument moves by multiple nodes."
2152 (Info-global-prev (- n))
2153 (while (>= (setq n (1- n)) 0)
2155 (cond ((and (string-match "^Top$" Info-current-node)
2156 (setq node (Info-extract-pointer "next" t))
2157 (Info-extract-menu-item node t))
2158 (Info-goto-node node))
2159 ((setq node (Info-extract-menu-counting 1 t t))
2160 (message "Going down...")
2161 (Info-goto-node node))
2163 (let ((Info-keeping-history Info-keeping-history)
2164 (orignode Info-current-node)
2166 (while (not (Info-extract-pointer "next" t))
2167 (if (and (setq node (Info-extract-pointer "up" t))
2168 (not (equal node "Top")))
2170 (message "Going%s..." (setq ups (concat ups " up")))
2171 (Info-goto-node node)
2172 (setq Info-keeping-history nil))
2174 (let ((Info-keeping-history nil))
2175 (Info-goto-node orignode)))
2176 (error "Last node in file")))
2179 (defun Info-page-next (&optional n)
2180 "Scroll forward one screenful, or go to next global node.
2181 A positive or negative prefix argument moves by multiple screenfuls."
2185 (Info-page-prev (- n))
2186 (while (>= (setq n (1- n)) 0)
2187 (if (pos-visible-in-window-p (point-max))
2190 (message "Node: %s" Info-current-node))
2193 (defun Info-scroll-next (arg)
2195 (if Info-auto-advance
2196 (if (and (pos-visible-in-window-p (point-max))
2197 (not (eq Info-auto-advance t))
2198 (not (eq last-command this-command)))
2199 (message "Hit %s again to go to next node"
2200 (if (= last-command-char 0)
2202 (key-description (char-to-string last-command-char))))
2204 (setq this-command 'Info))
2207 (defun Info-global-prev (&optional n)
2208 "Go to the previous node in this file, traversing structure as necessary.
2209 This works only if the Info file is structured as a hierarchy of nodes.
2210 A positive or negative prefix argument moves by multiple nodes."
2214 (Info-global-next (- n))
2215 (while (>= (setq n (1- n)) 0)
2216 (let ((upnode (Info-extract-pointer "up" t))
2217 (prevnode (Info-extract-pointer "prev[ious]*" t)))
2218 (if (or (not prevnode)
2219 (equal prevnode upnode))
2220 (if (string-match "^Top$" Info-current-node)
2221 (error "First node in file")
2222 (message "Going up...")
2224 (Info-goto-node prevnode)
2226 (Info-keeping-history nil)
2228 (while (setq node (Info-extract-menu-counting nil t t))
2229 (message "Going%s..." (setq downs (concat downs " down")))
2230 (Info-goto-node node))))))))
2232 (defun Info-page-prev (&optional n)
2233 "Scroll backward one screenful, or go to previous global node.
2234 A positive or negative prefix argument moves by multiple screenfuls."
2238 (Info-page-next (- n))
2239 (while (>= (setq n (1- n)) 0)
2240 (if (pos-visible-in-window-p (point-min))
2243 (message "Node: %s" Info-current-node)
2244 (goto-char (point-max))
2246 (move-to-window-line 0))
2249 (defun Info-scroll-prev (arg)
2251 (if Info-auto-advance
2252 (if (and (pos-visible-in-window-p (point-min))
2253 (not (eq Info-auto-advance t))
2254 (not (eq last-command this-command)))
2255 (message "Hit %s again to go to previous node"
2256 (if (mouse-event-p last-command-event)
2258 (key-description (event-key last-command-event))))
2260 (setq this-command 'Info))
2263 (defun Info-index (topic)
2264 "Look up a string in the index for this file.
2265 The index is defined as the first node in the top-level menu whose
2266 name contains the word \"Index\", plus any immediately following
2267 nodes whose names also contain the word \"Index\".
2268 If there are no exact matches to the specified topic, this chooses
2269 the first match which is a case-insensitive substring of a topic.
2270 Use the `,' command to see the other matches.
2271 Give a blank topic name to go to the Index node itself."
2272 (interactive "sIndex topic: ")
2273 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
2274 (regexp-quote topic)
2275 "\\(.*\\)\\.[ \t]*\\([0-9]*\\)$"))
2277 (message "Searching index for `%s'..." topic)
2278 (Info-goto-node "Top")
2279 (let ((case-fold-search t))
2280 (or (search-forward "\n* menu:" nil t)
2282 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
2283 (error "No index")))
2284 (goto-char (match-beginning 1))
2285 (let ((Info-keeping-history nil)
2286 (Info-fontify (and Info-fontify (equal topic ""))))
2287 (Info-goto-node (Info-extract-menu-node-name)))
2288 (or (equal topic "")
2291 (Info-keeping-history nil)
2295 (goto-char (point-min))
2296 (while (re-search-forward pattern nil t)
2298 (cons (list (buffer-substring (match-beginning 1)
2300 (buffer-substring (match-beginning 2)
2303 (string-to-int (concat "0"
2308 (and (setq node (Info-extract-pointer "next" t))
2309 (string-match "\\<Index\\>" node)))
2310 (let ((Info-fontify nil))
2311 (Info-goto-node node)))
2315 (error "No \"%s\" in index" topic)))
2316 ;; Here it is a feature that assoc is case-sensitive.
2317 (while (setq found (assoc topic matches))
2318 (setq exact (cons found exact)
2319 matches (delq found matches)))
2320 (setq Info-index-alternatives (nconc exact (nreverse matches))
2321 Info-index-first-alternative (car Info-index-alternatives))
2322 (Info-index-next 0)))))
2324 (defun Info-index-next (num)
2325 "Go to the next matching index item from the last `i' command."
2327 (or Info-index-alternatives
2328 (error "No previous `i' command in this file"))
2330 (setq num (+ num (length Info-index-alternatives))))
2332 (setq Info-index-alternatives
2333 (nconc (cdr Info-index-alternatives)
2334 (list (car Info-index-alternatives)))
2336 (Info-goto-node (nth 1 (car Info-index-alternatives)))
2337 (if (> (nth 3 (car Info-index-alternatives)) 0)
2338 (forward-line (nth 3 (car Info-index-alternatives)))
2339 (forward-line 3) ; don't search in headers
2340 (let ((name (car (car Info-index-alternatives))))
2341 (if (or (re-search-forward (format
2342 "\\(Function\\|Command\\): %s\\( \\|$\\)"
2343 (regexp-quote name)) nil t)
2344 (re-search-forward (format "^`%s[ ']" (regexp-quote name)) nil t)
2345 (search-forward (format "`%s'" name) nil t)
2346 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
2348 (format "`%s'" (substring name 0 (match-beginning 1)))
2350 (search-forward name nil t))
2352 (goto-char (point-min)))))
2353 (message "Found \"%s\" in %s. %s"
2354 (car (car Info-index-alternatives))
2355 (nth 2 (car Info-index-alternatives))
2356 (if (cdr Info-index-alternatives)
2357 (if (eq (car (cdr Info-index-alternatives))
2358 Info-index-first-alternative)
2359 "(Press `,' to repeat)"
2360 (format "(Press `,' for %d more)"
2361 (- (1- (length Info-index-alternatives))
2362 (length (memq Info-index-first-alternative
2363 (cdr Info-index-alternatives))))))
2368 (defun Info-emacs-command (command)
2369 "Look up an Emacs command in the Emacs manual in the Info system.
2370 This command is designed to be used whether you are already in Info or not."
2371 (interactive "CLook up command in Emacs manual: ")
2372 (save-window-excursion
2374 (Info-find-node Info-emacs-info-file-name "Top")
2375 (Info-index (symbol-name command)))
2376 (pop-to-buffer "*info*"))
2380 (defun Info-goto-emacs-command-node (key)
2381 "Look up an Emacs command in the Emacs manual in the Info system.
2382 This command is designed to be used whether you are already in Info or not."
2383 (interactive "CLook up command in Emacs manual: ")
2384 (Info-emacs-command key))
2387 (defun Info-goto-emacs-key-command-node (key)
2388 "Look up an Emacs key sequence in the Emacs manual in the Info system.
2389 This command is designed to be used whether you are already in Info or not."
2390 (interactive "kLook up key in Emacs manual: ")
2391 (let ((command (key-binding key)))
2392 (cond ((eq command 'keyboard-quit)
2395 (error "%s is undefined" (key-description key)))
2396 ((and (interactive-p) (eq command 'execute-extended-command))
2397 (call-interactively 'Info-goto-emacs-command-node))
2399 (Info-goto-emacs-command-node command)))))
2402 (defun Info-emacs-key (key)
2403 "Look up an Emacs key sequence in the Emacs manual in the Info system.
2404 This command is designed to be used whether you are already in Info or not."
2405 (interactive "kLook up key in Emacs manual: ")
2406 (cond ((eq (key-binding key) 'keyboard-quit)
2408 ((and (interactive-p) (eq (key-binding key) 'execute-extended-command))
2409 (call-interactively 'Info-goto-emacs-command-node))
2411 (save-window-excursion
2413 (Info-find-node Info-emacs-info-file-name "Top")
2414 (setq key (key-description key))
2416 (if (setq p (string-match "[@{}]" key))
2417 (setq key (concat (substring key 0 p) "@" (substring key p))))
2418 (if (string-match "^ESC " key)
2419 (setq key (concat "M-" (substring key 4))))
2420 (if (string-match "^M-C-" key)
2421 (setq key (concat "C-M-" (substring key 4)))))
2423 (pop-to-buffer "*info*"))))
2426 (defun Info-elisp-ref (func)
2427 "Look up an Emacs Lisp function in the Elisp manual in the Info system.
2428 This command is designed to be used whether you are already in Info or not."
2429 (interactive (let ((fn (function-at-point))
2430 (enable-recursive-minibuffers t)
2432 (setq val (completing-read
2433 (format "Look up Emacs Lisp function%s: "
2435 (format " (default %s)" fn)
2438 nil nil (and fn (symbol-name fn))))
2439 (list (if (equal val "")
2441 (save-window-excursion
2444 (Info-find-node "lispref" "Top")
2445 (error (Info-find-node "elisp" "Top")))
2446 (Info-index (symbol-name func)))
2447 (pop-to-buffer "*info*"))
2449 (defun Info-reannotate-node ()
2450 (let ((bufs (delq nil (mapcar 'get-file-buffer Info-annotations-path))))
2452 (let ((ibuf (current-buffer))
2453 (file (concat "\\(" (regexp-quote
2454 (file-name-nondirectory Info-current-file))
2455 "\\|" (regexp-quote Info-current-file) "\\)"))
2456 (node (regexp-quote Info-current-node))
2458 (goto-char (point-min))
2459 (if (search-forward "\n------ NOTE:\n" nil t)
2460 (let ((buffer-read-only nil)
2461 (bufmod (buffer-modified-p))
2463 (setq savept (copy-marker savept))
2464 (goto-char (point-min))
2465 (while (search-forward "\n------ NOTE:" nil t)
2466 (setq top (1+ (match-beginning 0)))
2467 (if (search-forward "\n------\n" nil t)
2468 (delete-region top (point)))
2470 (set-buffer-modified-p bufmod)))
2473 (set-buffer (car bufs))
2474 (goto-char (point-min))
2475 (while (re-search-forward
2477 "------ *File: *%s *Node: *%s *Line: *\\([0-9]+\\) *\n"
2480 (let ((line (string-to-int
2481 (buffer-substring (match-beginning 2)
2485 (search-forward "\n------\n" nil t)
2489 (if (integerp savept) (setq savept (copy-marker savept)))
2491 (goto-char (point-max))
2492 (goto-char (point-min))
2493 (forward-line line))
2494 (let ((buffer-read-only nil)
2495 (bufmod (buffer-modified-p)))
2496 (insert "------ NOTE:\n")
2497 (insert-buffer-substring (car bufs) top bot)
2498 (set-buffer-modified-p bufmod)))))
2499 (setq bufs (cdr bufs))))
2500 (goto-char savept)))))
2502 (defvar Info-annotate-map nil
2503 "Local keymap used within `a' command of Info.")
2505 (if Info-annotate-map
2507 ;; (setq Info-annotate-map (nconc (make-sparse-keymap) text-mode-map))
2508 (setq Info-annotate-map (copy-keymap text-mode-map))
2509 (define-key Info-annotate-map "\C-c\C-c" 'Info-cease-annotate))
2511 (defun Info-annotate-mode ()
2512 "Major mode for adding an annotation to an Info node.
2513 Like text mode with the addition of Info-cease-annotate
2514 which returns to Info mode for browsing.
2515 \\{Info-annotate-map}")
2517 (defun Info-annotate (arg)
2518 "Add a personal annotation to the current Info node.
2519 Only you will be able to see this annotation. Annotations are stored
2520 in the file \"~/.xemacs/info.notes\" by default. If point is inside
2521 an existing annotation, edit that annotation. A prefix argument
2522 specifies which annotations file (from `Info-annotations-path') is to
2523 be edited; default is 1."
2526 (if (or (< arg 0) (not (nth arg Info-annotations-path)))
2528 (setq Info-annotations-path
2529 (list (read-file-name
2530 "Annotations file: " "~/" "~/.infonotes")))
2531 (error "File number must be in the range from 1 to %d"
2532 (length Info-annotations-path))))
2534 (file (file-name-nondirectory Info-current-file))
2535 (d Info-directory-list)
2537 (while (and d (not (equal (expand-file-name file (car d))
2538 Info-current-file)))
2540 (or d (setq file Info-current-file))
2541 (if (and (save-excursion
2542 (goto-char (min (point-max) (+ (point) 13)))
2543 (and (search-backward "------ NOTE:\n" nil t)
2544 (setq pt (match-end 0))
2545 (search-forward "\n------\n" nil t)))
2546 (< (point) (match-end 0)))
2547 (setq which (format "File: *%s *Node: *%s *Line:.*\n%s"
2549 (regexp-quote Info-current-node)
2551 (buffer-substring pt (match-beginning 0))))
2552 where (max (- (point) pt) 0)))
2553 (let ((node Info-current-node)
2554 (line (if (looking-at "[ \n]*\\'") 0
2555 (count-lines (point-min) (point)))))
2557 (let ((buffer-read-only nil)
2558 (bufmod (buffer-modified-p)))
2560 (if (bobp) (goto-char (point-max)))
2561 (insert "------ NOTE:\n------\n")
2563 (set-buffer-modified-p bufmod)))
2564 ;; (setq Info-window-start (window-start))
2565 (setq Info-window-configuration (current-window-configuration))
2566 (pop-to-buffer (find-file-noselect (nth arg Info-annotations-path)))
2567 (use-local-map Info-annotate-map)
2568 (setq major-mode 'Info-annotate-mode)
2569 (setq mode-name "Info Annotate")
2572 (goto-char (point-min))
2573 (re-search-forward which nil t))
2575 (goto-char (match-beginning 0))
2577 (forward-char where)))
2578 (let ((bufmod (buffer-modified-p)))
2579 (goto-char (point-max))
2580 (insert (format "\n------ File: %s Node: %s Line: %d\n"
2583 (insert "\n------\n"
2584 "\nPress C-c C-c to save and return to Info.\n")
2586 (set-buffer-modified-p bufmod))))))
2588 (defun Info-cease-annotate ()
2590 (let ((bufmod (buffer-modified-p)))
2591 (while (save-excursion
2592 (goto-char (point-min))
2593 (re-search-forward "\n\n?Press .* to save and return to Info.\n"
2595 (delete-region (1+ (match-beginning 0)) (match-end 0)))
2596 (while (save-excursion
2597 (goto-char (point-min))
2598 (re-search-forward "\n------ File:.*Node:.*Line:.*\n+------\n"
2600 (delete-region (match-beginning 0) (match-end 0)))
2601 (set-buffer-modified-p bufmod))
2605 (or (one-window-p) (delete-window))
2607 (setq Info-current-annotation-completions nil)
2608 (set-window-configuration Info-window-configuration)
2609 (Info-reannotate-node))
2611 (defun Info-bookmark (arg tag)
2612 (interactive "p\nsBookmark name: ")
2614 (if (or (string-match "^\"\\(.*\\)\"$" tag)
2615 (string-match "^<<\\(.*\\)>>$" tag))
2616 (setq tag (substring tag (match-beginning 1) (match-end 1))))
2618 (search-forward "\n------\n")
2619 (let ((end (- (point) 8)))
2621 (if (re-search-forward "<<[^>\n]*>>" nil t)
2622 (delete-region (match-beginning 0) (match-end 0))
2625 (insert "<<" tag ">>"))))
2626 (Info-cease-annotate))
2629 "Exit Info by selecting some other buffer."
2632 (save-buffers-kill-emacs)
2633 (bury-buffer (current-buffer))
2634 (if (and (featurep 'toolbar)
2635 (boundp 'toolbar-info-frame)
2636 (eq toolbar-info-frame (selected-frame)))
2638 (delete-frame toolbar-info-frame)
2639 (error (bury-buffer)))
2640 (switch-to-buffer (other-buffer (current-buffer))))))
2642 (defun Info-undefined ()
2643 "Make command be undefined in Info."
2648 "Enter the Info tutorial."
2650 (delete-other-windows)
2651 (Info-find-node "info"
2652 (if (< (window-height) 23)
2656 (defun Info-summary ()
2657 "Display a brief summary of all Info commands."
2659 (save-window-excursion
2660 (switch-to-buffer "*Help*")
2662 (insert (documentation 'Info-mode))
2663 (goto-char (point-min))
2665 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
2666 (message (if flag "Type Space to see more"
2667 "Type Space to return to Info"))
2668 (let ((e (next-command-event)))
2669 (if (/= ?\ (event-to-character e))
2670 (progn (setq unread-command-event e) nil)
2674 (bury-buffer "*Help*")))
2676 (defun Info-get-token (pos start all &optional errorstring)
2677 "Return the token around POS,
2678 POS must be somewhere inside the token
2679 START is a regular expression which will match the
2680 beginning of the tokens delimited string
2681 ALL is a regular expression with a single
2682 parenthized subpattern which is the token to be
2683 returned. E.g. '{\(.*\)}' would return any string
2684 enclosed in braces around POS.
2685 SIG optional fourth argument, controls action on no match
2688 a string: signal an error, using that string."
2690 (goto-char (point-min))
2691 (re-search-backward "\\`") ; Bug fix due to Nicholas J. Foskett.
2693 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
2695 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
2696 (not (setq found (and (<= (match-beginning 0) pos)
2697 (> (match-end 0) pos))))))
2698 (if (and found (<= (match-beginning 0) pos)
2699 (> (match-end 0) pos))
2700 (buffer-substring (match-beginning 1) (match-end 1))
2701 (cond ((null errorstring)
2707 (error "No %s around position %d" errorstring pos)))))))
2709 (defun Info-follow-clicked-node (event)
2710 "Follow a node reference near clicked point. Like M, F, N, P or U command.
2711 At end of the node's text, moves to the next node."
2713 (or (and (event-point event)
2714 (Info-follow-nearest-node
2716 (select-window (event-window event))
2717 (event-point event))
2719 (error "click on a cross-reference to follow")))
2721 (defun Info-maybe-follow-clicked-node (event &optional click-count)
2722 "Follow a node reference (if any) near clicked point.
2723 Like M, F, N, P or U command. At end of the node's text, moves to the
2724 next node. No error is given if there is no node to follow."
2726 (and Info-button1-follows-hyperlink
2728 (Info-follow-nearest-node
2730 (select-window (event-window event))
2731 (event-point event))
2732 (1+ (point-min))))))
2734 (defun Info-find-nearest-node (point)
2737 ((= point (point-min)) nil) ; don't trigger on accidental RET.
2738 ((setq node (Info-get-token point
2739 (format "\\*%s[ \n]" Info-footnote-tag)
2740 (format "\\*%s[ \n]\\([^:]*\\):"
2741 Info-footnote-tag)))
2742 (list "Following cross-reference %s..."
2743 (list 'Info-follow-reference node)))
2744 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\)::"))
2745 (list "Selecting menu item %s..."
2746 (list 'Info-goto-node node nil t)))
2747 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\):"))
2748 (list "Selecting menu item %s..."
2749 (list 'Info-menu node)))
2750 ((setq node (Info-get-token point "Up: " "Up: \\([^,\n\t]*\\)"))
2752 (list 'Info-goto-node node)))
2753 ((setq node (Info-get-token point "Next: " "Next: \\([^,\n\t]*\\)"))
2754 (list "Next node..."
2755 (list 'Info-goto-node node)))
2756 ((setq node (Info-get-token point "File: " "File: \\([^,\n\t]*\\)"))
2758 (list 'Info-goto-node "Top")))
2759 ((setq node (Info-get-token point "Prev[ious]*: "
2760 "Prev[ious]*: \\([^,\n\t]*\\)"))
2761 (list "Previous node..."
2762 (list 'Info-goto-node node)))
2763 ((setq node (Info-get-token point "Node: " "Node: \\([^,\n\t]*\\)"))
2764 (list "Reselecting %s..."
2765 (list 'Info-goto-node node)))
2766 ((save-excursion (goto-char point) (looking-at "[ \n]*\\'"))
2767 (if Info-in-cross-reference
2768 (list "Back to last node..."
2770 (list "Next node..."
2771 '(Info-global-next)))))
2774 (defun Info-follow-nearest-node (point)
2775 "Follow a node reference near point. Like M, F, N, P or U command.
2776 At end of the node's text, moves to the next node."
2778 (let ((data (Info-find-nearest-node point)))
2781 (let ((msg (format (car data) (nth 1 (nth 1 data)))))
2784 (message "%sdone" msg))
2787 (defun Info-indicated-node (event)
2790 (cond ((eventp event)
2791 (set-buffer (event-buffer event))
2792 (setq event (event-point event))))
2793 (let* ((data (Info-find-nearest-node event))
2794 (name (nth 1 (nth 1 data))))
2795 (and name (nth 1 data))))
2798 (defun Info-mouse-track-double-click-hook (event click-count)
2799 "Handle double-clicks by turning pages, like the `gv' ghostscript viewer"
2800 (if (/= click-count 2)
2801 ;; Return nil so any other hooks are performed.
2803 (let* ((fw (face-width 'default))
2804 (fh (face-height 'default))
2805 (x (/ (event-x-pixel event) fw))
2806 (y (/ (event-y-pixel event) fw))
2807 (w (/ (window-pixel-width (event-window event)) fw))
2808 (h (/ (window-pixel-height (event-window event)) fh))
2812 ((<= y by) (Info-up) t)
2813 ((>= y (- h by)) (Info-nth-menu-item 1) t)
2814 ((<= x bx) (Info-prev) t)
2815 ((>= x (- w bx)) (Info-next) t)
2818 (defvar Info-mode-map nil
2819 "Keymap containing Info commands.")
2823 (setq Info-mode-map (make-sparse-keymap))
2824 (suppress-keymap Info-mode-map)
2825 (define-key Info-mode-map "." 'beginning-of-buffer)
2826 (define-key Info-mode-map " " 'Info-scroll-next)
2827 (define-key Info-mode-map "1" 'Info-nth-menu-item)
2828 (define-key Info-mode-map "2" 'Info-nth-menu-item)
2829 (define-key Info-mode-map "3" 'Info-nth-menu-item)
2830 (define-key Info-mode-map "4" 'Info-nth-menu-item)
2831 (define-key Info-mode-map "5" 'Info-nth-menu-item)
2832 (define-key Info-mode-map "6" 'Info-nth-menu-item)
2833 (define-key Info-mode-map "7" 'Info-nth-menu-item)
2834 (define-key Info-mode-map "8" 'Info-nth-menu-item)
2835 (define-key Info-mode-map "9" 'Info-nth-menu-item)
2836 (define-key Info-mode-map "0" 'Info-last-menu-item)
2837 (define-key Info-mode-map "?" 'Info-summary)
2838 (define-key Info-mode-map "a" 'Info-annotate)
2839 (define-key Info-mode-map "b" 'beginning-of-buffer)
2840 (define-key Info-mode-map "d" 'Info-directory)
2841 (define-key Info-mode-map "e" 'Info-edit)
2842 (define-key Info-mode-map "f" 'Info-follow-reference)
2843 (define-key Info-mode-map "g" 'Info-goto-node)
2844 (define-key Info-mode-map "h" 'Info-help)
2845 (define-key Info-mode-map "i" 'Info-index)
2846 (define-key Info-mode-map "j" 'Info-goto-bookmark)
2847 (define-key Info-mode-map "k" 'Info-emacs-key)
2848 (define-key Info-mode-map "l" 'Info-last)
2849 (define-key Info-mode-map "m" 'Info-menu)
2850 (define-key Info-mode-map "n" 'Info-next)
2851 (define-key Info-mode-map "p" 'Info-prev)
2852 (define-key Info-mode-map "q" 'Info-exit)
2853 (define-key Info-mode-map "r" 'Info-follow-reference)
2854 (define-key Info-mode-map "s" 'Info-search)
2855 (define-key Info-mode-map "t" 'Info-top)
2856 (define-key Info-mode-map "u" 'Info-up)
2857 (define-key Info-mode-map "v" 'Info-visit-file)
2858 (define-key Info-mode-map "x" 'Info-bookmark)
2859 (define-key Info-mode-map "<" 'Info-top)
2860 (define-key Info-mode-map ">" 'Info-end)
2861 (define-key Info-mode-map "[" 'Info-global-prev)
2862 (define-key Info-mode-map "]" 'Info-global-next)
2863 (define-key Info-mode-map "{" 'Info-page-prev)
2864 (define-key Info-mode-map "}" 'Info-page-next)
2865 (define-key Info-mode-map "=" 'Info-restore-point)
2866 (define-key Info-mode-map "!" 'Info-select-node)
2867 (define-key Info-mode-map "@" 'Info-follow-nearest-node)
2868 (define-key Info-mode-map "," 'Info-index-next)
2869 (define-key Info-mode-map "*" 'Info-elisp-ref)
2870 (define-key Info-mode-map [tab] 'Info-next-reference)
2871 (define-key Info-mode-map [(meta tab)] 'Info-prev-reference)
2872 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference)
2873 (define-key Info-mode-map "\r" 'Info-follow-nearest-node)
2875 (define-key Info-mode-map 'backspace 'Info-scroll-prev)
2876 (define-key Info-mode-map 'delete 'Info-scroll-prev)
2877 (define-key Info-mode-map 'button2 'Info-follow-clicked-node)
2878 (define-key Info-mode-map 'button3 'Info-select-node-menu))
2881 ;; Info mode is suitable only for specially formatted data.
2882 (put 'info-mode 'mode-class 'special)
2885 "Info mode is for browsing through the Info documentation tree.
2886 Documentation in Info is divided into \"nodes\", each of which
2887 discusses one topic and contains references to other nodes
2888 which discuss related topics. Info has commands to follow
2889 the references and show you other nodes.
2891 h Invoke the Info tutorial.
2892 q Quit Info: return to the previously selected file or buffer.
2894 Selecting other nodes:
2895 n Move to the \"next\" node of this node.
2896 p Move to the \"previous\" node of this node.
2897 m Pick menu item specified by name (or abbreviation).
2898 1-9, 0 Pick first..ninth, last item in node's menu.
2899 Menu items select nodes that are \"subsections\" of this node.
2900 u Move \"up\" from this node (i.e., from a subsection to a section).
2901 f or r Follow a cross reference by name (or abbrev). Type `l' to get back.
2902 RET Follow cross reference or menu item indicated by cursor.
2903 i Look up a topic in this file's Index and move to that node.
2904 , (comma) Move to the next match from a previous `i' command.
2905 l (letter L) Move back to the last node you were in.
2907 Moving within a node:
2908 Space Scroll forward a full screen. DEL Scroll backward.
2909 b Go to beginning of node. Meta-> Go to end of node.
2910 TAB Go to next cross-reference. Meta-TAB Go to previous ref.
2913 Left Button Set point (usual text-mode functionality)
2914 Middle Button Click on a highlighted node reference to go to it.
2915 Right Button Pop up a menu of applicable Info commands.
2917 Left Button Double Click in window edges:
2918 Top edge: Go up to the parent node, like `u'.
2919 Left edge: Go to the previous node, like `p'.
2920 Right edge: Go to the next node, like `n'.
2921 Bottom edge: Follow first menu item, like `1'.
2924 g Move to node, file, or annotation tag specified by name.
2925 Examples: `g Rectangles' `g (Emacs)Rectangles' `g Emacs'.
2926 v Move to file, with filename completion.
2927 k Look up a key sequence in Emacs manual (also C-h C-k at any time).
2928 * Look up a function name in Emacs Lisp manual (also C-h C-f).
2929 d Go to the main directory of Info files.
2930 < or t Go to Top (first) node of this file.
2931 > Go to last node in this file.
2932 \[ Go to previous node, treating file as one linear document.
2933 \] Go to next node, treating file as one linear document.
2934 { Scroll backward, or go to previous node if at top.
2935 } Scroll forward, or go to next node if at bottom.
2936 = Restore cursor position from last time in this node.
2937 a Add a private note (annotation) to the current node.
2938 x, j Add, jump to a bookmark (annotation tag).
2939 s Search this Info file for a node containing the specified regexp.
2940 e Edit the contents of the current node."
2941 (kill-all-local-variables)
2942 (setq major-mode 'Info-mode)
2943 (setq mode-name "Info")
2944 (use-local-map Info-mode-map)
2945 (set-syntax-table text-mode-syntax-table)
2946 (setq local-abbrev-table text-mode-abbrev-table)
2947 (setq case-fold-search t)
2948 (setq buffer-read-only t)
2949 ; (setq buffer-mouse-map Info-mode-mouse-map)
2950 (make-local-variable 'Info-current-file)
2951 (make-local-variable 'Info-current-subfile)
2952 (make-local-variable 'Info-current-node)
2953 (make-local-variable 'Info-tag-table-marker)
2954 (setq Info-tag-table-marker (make-marker))
2955 (make-local-variable 'Info-tag-table-buffer)
2956 (setq Info-tag-table-buffer nil)
2957 (make-local-variable 'Info-current-file-completions)
2958 (make-local-variable 'Info-current-annotation-completions)
2959 (make-local-variable 'Info-index-alternatives)
2960 (make-local-variable 'Info-history)
2961 ;; Faces are now defined by `defface'...
2962 (make-local-variable 'mouse-track-click-hook)
2963 (add-hook 'mouse-track-click-hook 'Info-maybe-follow-clicked-node)
2964 (add-hook 'mouse-track-click-hook 'Info-mouse-track-double-click-hook)
2965 ;; #### The console-on-window-system-p check is to allow this to
2966 ;; work on tty's. The real problem here is that featurep really
2967 ;; needs to have some device/console domain knowledge added to it.
2968 (defvar info::toolbar)
2969 (if (and (featurep 'toolbar)
2970 (console-on-window-system-p)
2971 (not Info-inhibit-toolbar))
2972 (set-specifier default-toolbar (cons (current-buffer) info::toolbar)))
2973 (if (featurep 'menubar)
2975 ;; make a local copy of the menubar, so our modes don't
2976 ;; change the global menubar
2977 (easy-menu-add '("Info" :filter Info-menu-filter))))
2978 (run-hooks 'Info-mode-hook)
2979 (Info-set-mode-line))
2981 (defvar Info-edit-map nil
2982 "Local keymap used within `e' command of Info.")
2986 ;; XEmacs: remove FSF stuff
2987 (setq Info-edit-map (make-sparse-keymap))
2988 (set-keymap-name Info-edit-map 'Info-edit-map)
2989 (set-keymap-parents Info-edit-map (list text-mode-map))
2990 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
2992 ;; Info-edit mode is suitable only for specially formatted data.
2993 (put 'info-edit-mode 'mode-class 'special)
2995 (defun Info-edit-mode ()
2996 "Major mode for editing the contents of an Info node.
2997 Like text mode with the addition of `Info-cease-edit'
2998 which returns to Info mode for browsing.
3003 "Edit the contents of this Info node.
3004 Allowed only if variable `Info-enable-edit' is non-nil."
3006 (or Info-enable-edit
3007 (error "Editing info nodes is not enabled"))
3008 (use-local-map Info-edit-map)
3009 (setq major-mode 'Info-edit-mode)
3010 (setq mode-name "Info Edit")
3011 (kill-local-variable 'modeline-buffer-identification)
3012 (setq buffer-read-only nil)
3013 ;; Make mode line update.
3014 (set-buffer-modified-p (buffer-modified-p))
3015 (message (substitute-command-keys
3016 "Editing: Type \\[Info-cease-edit] to return to info")))
3018 (defun Info-cease-edit ()
3019 "Finish editing Info node; switch back to Info proper."
3021 ;; Do this first, so nothing has changed if user C-g's at query.
3022 (and (buffer-modified-p)
3023 (y-or-n-p "Save the file? ")
3025 (use-local-map Info-mode-map)
3026 (setq major-mode 'Info-mode)
3027 (setq mode-name "Info")
3028 (Info-set-mode-line)
3029 (setq buffer-read-only t)
3030 ;; Make mode line update.
3031 (set-buffer-modified-p (buffer-modified-p))
3032 (and (marker-position Info-tag-table-marker)
3034 (message "Tags may have changed. Use Info-tagify if necessary")))
3036 (defun Info-find-emacs-command-nodes (command)
3037 "Return a list of locations documenting COMMAND in the XEmacs Info manual.
3038 The locations are of the format used in Info-history, i.e.
3039 \(FILENAME NODENAME BUFFERPOS\)."
3041 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
3042 ":\\s *\\(.*\\)\\.")))
3044 (Info-find-node "XEmacs" "Command Index")
3045 ;; Take the index node off the Info history.
3046 ;; ??? says this isn't safe someplace else... hmmm.
3047 (setq Info-history (cdr Info-history))
3048 (goto-char (point-max))
3049 (while (re-search-backward cmd-desc nil t)
3050 (setq where (cons (list Info-current-file
3058 ;;; fontification and mousability for info
3060 (defun Info-highlight-region (start end face)
3062 (splitp (string-match "\n[ \t]+" (buffer-substring start end))))
3065 (setq extent (make-extent start (progn (goto-char start)
3068 (set-extent-face extent face)
3069 (set-extent-property extent 'info t)
3070 (set-extent-property extent 'highlight t)
3071 (skip-chars-forward "\n\t ")
3072 (setq extent (make-extent (point) end)))
3073 (setq extent (make-extent start end)))
3074 (set-extent-face extent face)
3075 (set-extent-property extent 'info t)
3076 (set-extent-property extent 'highlight t)))
3078 (defun Info-fontify-node ()
3080 (let ((case-fold-search t)
3081 (xref-regexp (concat "\\*"
3082 (regexp-quote Info-footnote-tag)
3083 "[ \n\t]*\\([^:]*\\):")))
3084 ;; Clear the old extents
3085 (map-extents #'(lambda (x y) (delete-extent x))
3086 (current-buffer) (point-min) (point-max) nil)
3087 ;; Break the top line iff it is > 79 characters. Some info nodes
3088 ;; have top lines that span 3 lines because of long node titles.
3089 ;; eg: (Info-find-node "lispref.info" "Window-Level Event Position Info")
3090 (toggle-read-only -1)
3095 (goto-char (point-min))
3096 (re-search-forward "Node: *[^,]+, " nil t)
3097 (setq len (- (point) (point-min))
3098 extent (make-extent (point-min) (point)))
3099 (set-extent-property extent 'invisible t)
3103 (if (< (current-column) (+ 78 len))
3106 (forward-char (+ 79 len))
3107 (re-search-backward "," nil t)
3111 (delete-backward-char 1)
3114 (toggle-read-only 1)
3115 ;; Highlight xrefs in the top few lines of the node
3116 (goto-char (point-min))
3117 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
3119 (goto-char (match-end 0))
3121 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?\n?")
3122 (goto-char (match-end 0))
3123 (Info-highlight-region (match-beginning 1) (match-end 1)
3125 ;; Now get the xrefs in the body
3126 (goto-char (point-min))
3127 (while (re-search-forward xref-regexp nil t)
3128 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
3130 (Info-highlight-region (match-beginning 1) (match-end 1)
3132 ;; then highlight the nodes in the menu.
3133 (goto-char (point-min))
3134 (if (and (search-forward "\n* menu:" nil t))
3135 (while (re-search-forward
3136 "^\\* \\([^:\t\n]*\\):?:[ \t\n]" nil t)
3137 (Info-highlight-region (match-beginning 1) (match-end 1)
3139 (set-buffer-modified-p nil))))
3141 (defun Info-construct-menu (&optional event)
3142 "Construct a menu of Info commands.
3143 Adds an entry for the node at EVENT, or under point if EVENT is omitted.
3144 Used to construct the menubar submenu and popup menu."
3145 (or event (setq event (point)))
3146 (let ((case-fold-search t)
3147 (xref-regexp (concat "\\*"
3148 (regexp-quote Info-footnote-tag)
3149 "[ \n\t]*\\([^:]*\\):"))
3150 up-p prev-p next-p menu xrefs subnodes in)
3152 ;; `one-space' fixes "Notes:" xrefs that are split across lines.
3156 (while (setq i (string-match "[ \n\t]+" text i))
3157 (setq text (concat (substring text 0 i) " "
3158 (substring text (match-end 0))))
3161 (goto-char (point-min))
3162 (if (looking-at ".*\\bNext:") (setq next-p t))
3163 (if (looking-at ".*\\bPrev:") (setq prev-p t))
3164 (if (looking-at ".*Up:") (setq up-p t))
3166 (if (setq in (Info-indicated-node event))
3167 (list (vector (one-space (cadr in)) in t)
3168 "--:shadowEtchedIn"))
3170 ["Goto Info Top-level" Info-directory]
3171 (vector "Next Node" 'Info-next :active next-p)
3172 (vector "Previous Node" 'Info-prev :active prev-p)
3173 (vector "Parent Node (Up)" 'Info-up :active up-p)
3174 ["Goto Node..." Info-goto-node]
3175 ["Goto Last Visited Node " Info-last])))
3176 ;; Find the xrefs and make a list
3177 (while (re-search-forward xref-regexp nil t)
3178 (setq xrefs (cons (one-space (buffer-substring (match-beginning 1)
3181 (setq xrefs (nreverse xrefs))
3182 (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more)))
3183 ;; Find the subnodes and make a list
3184 (goto-char (point-min))
3185 (if (search-forward "\n* menu:" nil t)
3186 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
3187 (setq subnodes (cons (buffer-substring (match-beginning 1)
3190 (setq subnodes (nreverse subnodes))
3191 (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more))))
3193 (nconc menu (list "--:shadowDoubleEtchedIn"
3196 (mapcar #'(lambda (xref)
3200 (list 'Info-follow-reference xref))))
3203 (nconc menu (list "--:shadowDoubleEtchedIn"
3206 (mapcar #'(lambda (node)
3209 (vector node (list 'Info-menu node))))
3213 (defun Info-menu-filter (menu)
3214 "This is the menu filter for the \"Info\" submenu."
3215 (Info-construct-menu))
3217 (defun Info-select-node-menu (event)
3218 "Pops up a menu of applicable Info commands."
3220 (select-window (event-window event))
3221 (let ((menu (Info-construct-menu event)))
3222 (setq menu (nconc (list "Info" ; title: not displayed
3224 "--:shadowDoubleEtchedOut")
3226 (let ((popup-menu-titles nil))
3227 (popup-menu menu))))
3229 ;;; Info toolbar support
3231 ;; exit icon taken from GNUS
3232 (defvar info::toolbar-exit-icon
3233 (if (featurep 'toolbar)
3234 (toolbar-make-button-list
3235 (expand-file-name (if (featurep 'xpm) "info-exit.xpm" "info-exit.xbm")
3236 toolbar-icon-directory)))
3239 (defvar info::toolbar-up-icon
3240 (if (featurep 'toolbar)
3241 (toolbar-make-button-list
3242 (expand-file-name (if (featurep 'xpm) "info-up.xpm" "info-up.xbm")
3243 toolbar-icon-directory)))
3246 (defvar info::toolbar-next-icon
3247 (if (featurep 'toolbar)
3248 (toolbar-make-button-list
3249 (expand-file-name (if (featurep 'xpm) "info-next.xpm" "info-next.xbm")
3250 toolbar-icon-directory)))
3253 (defvar info::toolbar-prev-icon
3254 (if (featurep 'toolbar)
3255 (toolbar-make-button-list
3256 (expand-file-name (if (featurep 'xpm) "info-prev.xpm" "info-prev.xbm")
3257 toolbar-icon-directory)))
3260 (defvar info::toolbar
3261 (if (featurep 'toolbar)
3262 ; disabled until we get the next/prev-win icons working again.
3263 ; (cons (first initial-toolbar-spec)
3264 ; (cons (second initial-toolbar-spec)
3265 '([info::toolbar-exit-icon
3269 [info::toolbar-next-icon
3272 "Next entry in same section"]
3273 [info::toolbar-prev-icon
3276 "Prev entry in same section"]
3277 [info::toolbar-up-icon
3280 "Up entry to enclosing section"]
3286 (run-hooks 'Info-load-hook)
3288 ;;; info.el ends here