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-missing
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 (defvar Info-emacs-info-file-name "xemacs.info"
432 "The filename of the XEmacs info for
433 `Info-goto-emacs-command-node' (`\\<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 (defcustom Info-localdir-heading-regexp
451 "^Locally installed XEmacs Packages:?"
452 "The menu part of localdir files will be inserted below this topic
457 (defface info-node '((t (:bold t :italic t)))
458 "Face used for node links in info."
461 (defface info-xref '((t (:bold t)))
462 "Face used for cross-references in info."
465 ;; Is this right for NT? .zip, with -c for to stdout, right?
466 (defvar Info-suffix-list '( ("" . nil)
468 (".info.bz2" . "bzip2 -dc %s")
469 (".info.gz" . "gzip -dc %s")
470 (".info-z" . "gzip -dc %s")
471 (".info.Z" . "uncompress -c %s")
472 (".bz2" . "bzip2 -dc %s")
473 (".gz" . "gzip -dc %s")
474 (".Z" . "uncompress -c %s")
475 (".zip" . "unzip -c %s") )
476 "List of file name suffixes and associated decoding commands.
477 Each entry should be (SUFFIX . STRING); if STRING contains %s, that is
478 changed to name of the file to decode, otherwise the file is given to
479 the command as standard input. If STRING is nil, no decoding is done.")
481 (defvar Info-footnote-tag "Note"
482 "*Symbol that identifies a footnote or cross-reference.
483 All \"*Note\" references will be changed to use this word instead.")
485 (defvar Info-current-file nil
486 "Info file that Info is now looking at, or nil.
487 This is the name that was specified in Info, not the actual file name.
488 It doesn't contain directory names or file name extensions added by Info.")
490 (defvar Info-current-subfile nil
491 "Info subfile that is actually in the *info* buffer now,
492 or nil if current info file is not split into subfiles.")
494 (defvar Info-current-node nil
495 "Name of node that Info is now looking at, or nil.")
497 (defvar Info-tag-table-marker nil
498 "Marker pointing at beginning of current Info file's tag table.
499 Marker points nowhere if file has no tag table.")
501 (defvar Info-tag-table-buffer nil)
503 (defvar Info-current-file-completions nil
504 "Cached completion list for current Info file.")
506 (defvar Info-current-annotation-completions nil
507 "Cached completion list for current annotation files.")
509 (defvar Info-index-alternatives nil
510 "List of possible matches for last Info-index command.")
511 (defvar Info-index-first-alternative nil)
513 (defcustom Info-annotations-path
515 (paths-construct-path (list user-init-directory "info.notes"))
516 (paths-construct-path '("~" ".infonotes"))
517 (paths-construct-path '("usr" "lib" "info.notes")
518 (char-to-string directory-sep-char)))
519 "*Names of files that contain annotations for different Info nodes.
520 By convention, the first one should reside in your personal directory.
521 The last should be a world-writable \"public\" annotations file."
525 (defcustom Info-button1-follows-hyperlink nil
526 "*Non-nil means mouse button1 click will follow hyperlink."
530 (defvar Info-standalone nil
531 "Non-nil if Emacs was started solely as an Info browser.")
533 (defvar Info-in-cross-reference nil)
534 (defvar Info-window-configuration nil)
536 (defvar Info-dir-prologue "-*- Text -*-
537 This is the file .../info/dir, which contains the topmost node of the
538 Info hierarchy. The first time you invoke Info you start off
539 looking at that node, which is (dir)Top.
541 File: dir Node: Top This is the top of the INFO tree
542 This (the Directory node) gives a menu of major topics.
544 * Menu: The list of major topics begins on the next line.
548 (defvar Info-no-description-string "[No description available]"
549 "Description string for info files that have none")
552 (defun info (&optional file)
553 "Enter Info, the documentation browser.
554 Optional argument FILE specifies the file to examine;
555 the default is the top-level directory of Info.
557 In interactive use, a prefix argument directs this command
558 to read a file name from the minibuffer."
559 (interactive (if current-prefix-arg
560 (list (read-file-name "Info file name: " nil nil t))))
561 (let ((p command-line-args))
563 (and (string-match "^-[fe]" (car p))
564 (equal (nth 1 p) "info")
565 (not Info-standalone)
566 (setq Info-standalone t)
568 (not (string-match "^-" (nth 2 p)))
569 (setq file (nth 2 p))
570 (setq command-line-args-left nil))
572 ; (Info-setup-x) ??? What was this going to be? Can anyone tell karlheg?
575 (Info-goto-node (concat "(" file ")"))
576 (and Info-standalone (info)))
577 (if (get-buffer "*info*")
578 (switch-to-buffer "*info*")
582 (defun Info-query (file)
583 "Enter Info, the documentation browser. Prompt for name of Info file."
584 (interactive "sInfo topic (default = menu): ")
587 (Info-goto-node "(dir)")
588 (Info-goto-node (concat "(" file ")"))))
590 (defun Info-setup-initial ()
591 (let ((f Info-annotations-path))
593 (if (and (file-exists-p (car f)) (not (get-file-buffer (car f))))
594 (bury-buffer (find-file-noselect (car f))))
598 (defun Info-find-node (filename &optional nodename no-going-back tryfile line)
599 "Go to an info node specified as separate FILENAME and NODENAME.
600 Look for a plausible filename, or if not found then look for URL's and
601 dispatch to the appropriate fn. NO-GOING-BACK is non-nil if
602 recovering from an error in this function; it says do not attempt
603 further (recursive) error recovery. TRYFILE is ??"
608 ;; empty filename is simple case
610 (Info-find-file-node nil nodename no-going-back tryfile line))
611 ;; Convert filename to lower case if not found as specified.
612 ;; Expand it, look harder...
613 ((let (temp temp-downcase found
614 (fname (substitute-in-file-name filename)))
616 ((string-match "^\\./" fname) ; If specified name starts with `./'
617 (list default-directory)) ; then just try current directory.
618 ((file-name-absolute-p fname)
619 '(nil)) ; No point in searching for an absolute file name
620 (Info-additional-search-directory-list
621 (append Info-directory-list
622 Info-additional-search-directory-list))
623 (t Info-directory-list))))
624 ;; Search the directory list for file FNAME.
625 (while (and dirs (not found))
626 (setq temp (expand-file-name fname (car dirs)))
628 (expand-file-name (downcase fname) (car dirs)))
629 (if (equal temp-downcase temp) (setq temp-downcase nil))
630 ;; Try several variants of specified name.
631 ;; Try downcasing, appending a suffix, or both.
632 (setq found (Info-suffixed-file temp temp-downcase))
633 (setq dirs (cdr dirs)))
635 (progn (setq filename (expand-file-name found))
637 (Info-find-file-node filename nodename no-going-back tryfile line))
638 ;; Look for a URL. This pattern is stolen from w3.el to prevent
639 ;; loading it if we won't need it.
640 ((string-match (concat "^\\(wais\\|solo\\|x-exec\\|newspost\\|www\\|"
641 "mailto\\|news\\|tn3270\\|ftp\\|http\\|file\\|"
642 "telnet\\|gopher\\):")
644 (if (fboundp 'browse-url)
645 (browse-url filename)
646 (error "Cannot follow URLs in this XEmacs")))
648 (error "Info file %s does not exist" filename))))
650 (defun Info-find-file-node (filename nodename
651 &optional no-going-back tryfile line)
652 ;; This is the guts of what was Info-find-node. Whoever wrote this
653 ;; should be locked up where they can't do any more harm.
655 ;; Go into info buffer.
656 (or (eq major-mode 'Info-mode)
657 (switch-to-buffer "*info*"))
658 (buffer-disable-undo (current-buffer))
659 (run-hooks 'Info-startup-hook)
660 (or (eq major-mode 'Info-mode)
663 (equal Info-current-file filename)
665 (string= "dir" (file-name-nondirectory Info-current-file))
667 (format "Leave Info file `%s'? "
668 (file-name-nondirectory Info-current-file)))
671 ;; Record the node we are leaving.
672 (if (and Info-current-file (not no-going-back))
673 (Info-history-add Info-current-file Info-current-node (point)))
675 (setq Info-current-node nil
676 Info-in-cross-reference nil)
679 ;; Switch files if necessary
681 (equal Info-current-file filename)
682 (let ((buffer-read-only nil))
683 (setq Info-current-file nil
684 Info-current-subfile nil
685 Info-current-file-completions nil
686 Info-index-alternatives nil
687 buffer-file-name nil)
689 (if (string= "dir" (file-name-nondirectory filename))
691 (Info-insert-file-contents filename t)
692 (setq default-directory (file-name-directory filename)))
693 (set-buffer-modified-p nil)
694 ;; See whether file has a tag table. Record the location if yes.
695 (set-marker Info-tag-table-marker nil)
696 (goto-char (point-max))
698 (or (equal nodename "*")
699 (not (search-forward "\^_\nEnd tag table\n" nil t))
701 ;; We have a tag table. Find its beginning.
702 ;; Is this an indirect file?
703 (search-backward "\nTag table:\n")
707 (looking-at "(Indirect)\n"))
708 ;; It is indirect. Copy it to another buffer
709 ;; and record that the tag table is in that buffer.
710 (let ((buf (current-buffer))
711 (m Info-tag-table-marker))
713 Info-tag-table-buffer
715 Info-tag-table-buffer
716 (generate-new-buffer " *info tag table*")))
718 (set-buffer Info-tag-table-buffer)
719 (buffer-disable-undo (current-buffer))
720 (setq case-fold-search t)
722 (insert-buffer-substring buf)
723 (set-marker m (match-end 0))))
724 (set-marker Info-tag-table-marker pos))))
725 (setq Info-current-file
726 (file-name-sans-versions buffer-file-name))))
727 (if (equal nodename "*")
728 (progn (setq Info-current-node nodename)
730 (goto-char (point-min)))
731 ;; Search file for a suitable node.
732 (let* ((qnode (regexp-quote nodename))
733 (regexp (concat "Node: *" qnode " *[,\t\n\177]"))
734 (guesspos (point-min))
736 ;; First get advice from tag table if file has one.
737 ;; Also, if this is an indirect info file,
738 ;; read the proper subfile into this buffer.
739 (if (marker-position Info-tag-table-marker)
740 (let (foun found-mode (m Info-tag-table-marker))
742 (set-buffer (marker-buffer Info-tag-table-marker))
744 (setq foun (re-search-forward regexp nil t))
746 (setq guesspos (read (current-buffer))))
747 (setq found-mode major-mode))
749 ;; If this is an indirect file,
750 ;; determine which file really holds this node
752 (if (not (eq major-mode found-mode))
754 (Info-read-subfile guesspos))))))
755 (goto-char (max (point-min) (- guesspos 1000)))
756 ;; Now search from our advised position (or from beg of buffer)
757 ;; to find the actual node.
759 (while (search-forward "\n\^_" nil t)
763 (if (re-search-backward regexp beg t)
766 (let ((bufs (delq nil (mapcar 'get-file-buffer
767 Info-annotations-path)))
768 (pattern (if (string-match "\\`<<.*>>\\'" qnode) qnode
769 (format "\"%s\"\\|<<%s>>" qnode qnode)))
770 (pat2 (concat "------ *File: *\\([^ ].*[^ ]\\) *Node: "
771 "*\\([^ ].*[^ ]\\) *Line: *\\([0-9]+\\)"))
772 (afile nil) anode aline)
773 (while (and bufs (not anode))
775 (set-buffer (car bufs))
776 (goto-char (point-min))
777 (if (re-search-forward pattern nil t)
778 (if (re-search-backward pat2 nil t)
779 (setq afile (buffer-substring (match-beginning 1)
781 anode (buffer-substring (match-beginning 2)
784 (buffer-substring (match-beginning 3)
786 (setq bufs (cdr bufs)))
788 (Info-find-node afile anode t nil aline)
791 (Info-find-node nodename "Top" t)
793 (or Info-current-node
794 (error "No such node: %s" nodename)))
798 (goto-char (point-min))
799 (if line (forward-line line)))))))
800 ;; If we did not finish finding the specified node,
801 ;; go back to the previous one.
802 (or Info-current-node no-going-back
803 (let ((hist (car Info-history)))
804 ;; The following is no longer safe with new Info-history system
805 ;; (setq Info-history (cdr Info-history))
806 (Info-goto-node (car hist) t)
807 (goto-char (+ (point-min) (nth 1 hist)))))))
809 ;; Cache the contents of the (virtual) dir file, once we have merged
810 ;; it for the first time, so we can save time subsequently.
811 (defvar Info-dir-contents nil)
813 ;; Cache for the directory we decided to use for the default-directory
814 ;; of the merged dir text.
815 (defvar Info-dir-contents-directory nil)
817 ;; Record the file attributes of all the files from which we
818 ;; constructed Info-dir-contents.
819 (defvar Info-dir-file-attributes nil)
821 (defun Info-insert-dir ()
822 "Construct the Info directory node by merging the files named
823 \"dir\" or \"localdir\" from the directories in `Info-directory-list'
824 The \"dir\" files will take precedence in cases where both exist. It
825 sets the *info* buffer's `default-directory' to the first directory we
826 actually get any text from."
827 (if (and Info-dir-contents Info-dir-file-attributes
828 ;; Verify that none of the files we used has changed
831 (mapcar #'(lambda (elt)
832 (let ((curr (file-attributes (car elt))))
833 ;; Don't compare the access time.
834 (if curr (setcar (nthcdr 4 curr) 0))
835 (setcar (nthcdr 4 (cdr elt)) 0)
836 (equal (cdr elt) curr)))
837 Info-dir-file-attributes))))
838 (insert Info-dir-contents)
839 (let ((dirs (reverse Info-directory-list))
840 buffers lbuffers buffer others nodes dirs-done)
842 (setq Info-dir-file-attributes nil)
844 ;; Search the directory list for the directory file.
846 (let ((truename (file-truename (expand-file-name (car dirs)))))
847 (or (member truename dirs-done)
848 (member (directory-file-name truename) dirs-done)
849 ;; Try several variants of specified name.
850 ;; Try upcasing, appending `.info', or both.
855 (progn (setq file (expand-file-name "dir" truename))
856 (file-attributes file))
857 (progn (setq file (expand-file-name "DIR" truename))
858 (file-attributes file))
859 (progn (setq file (expand-file-name "dir.info" truename))
860 (file-attributes file))
861 (progn (setq file (expand-file-name "DIR.INFO" truename))
862 (file-attributes file))
863 (progn (setq file (expand-file-name "localdir" truename))
864 (file-attributes file))
865 (progn (setq file (expand-file-name "dir" truename))
870 (cons (directory-file-name truename)
872 (Info-maybe-update-dir file)
873 (setq attrs (file-attributes file))
874 (if (or (setq buf (find-buffer-visiting file))
878 (message "Composing main Info directory..."))
881 (if (string-match "localdir" file)
885 (insert-file-contents file))
886 (if (string-match "localdir" (buffer-name))
887 (setq lbuffers (cons (current-buffer) lbuffers))
888 (setq buffers (cons (current-buffer) buffers)))
890 (setq Info-dir-file-attributes
891 (cons (cons file attrs)
892 Info-dir-file-attributes)))))))
893 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs)))
894 (setq dirs (cdr dirs))))
896 ;; ensure that the localdir files are inserted last, and reverse
897 ;; the list of them so that when they get pushed in, they appear
898 ;; in the same order they got specified in the path, from top to
900 (nconc buffers (reverse lbuffers))
903 (error "Can't find the Info directory node"))
904 ;; Distinguish the dir file that comes with Emacs from all the
905 ;; others. Yes, that is really what this is supposed to do.
906 ;; If it doesn't work, fix it.
907 (setq buffer (car buffers)
908 ;; reverse it since they are pushed down from the top. the
909 ;; `Info-directory-list can be specified in natural order
911 others (reverse (cdr buffers)))
913 ;; Insert the entire original dir file as a start; note that we've
914 ;; already saved its default directory to use as the default
915 ;; directory for the whole concatenation.
916 (insert-buffer buffer)
918 ;; Look at each of the other buffers one by one.
920 (let ((other (car others))
921 (info-buffer (current-buffer)))
922 (if (string-match "localdir" (buffer-name other))
924 (set-buffer info-buffer)
925 (goto-char (point-max))
927 ((re-search-backward "^ *\\* *Locals *: *$" nil t)
928 (delete-region (match-beginning 0) (match-end 0)))
929 ;; look for a line like |Local XEmacs packages:
930 ;; or mismatch on some text ...
931 ((re-search-backward Info-localdir-heading-regexp nil t)
932 ;; This is for people who underline topic headings with
933 ;; equal signs or dashes.
934 (when (save-excursion
937 (looking-at "^[ \t]*[-=*]+"))
941 (t (search-backward "\^L" nil t)))
942 ;; Insert menu part of the file
944 (len (length (buffer-string nil nil other))))
945 (insert (buffer-string nil nil other))
946 (goto-char (+ pt len))
949 (if (search-forward "* Menu:" (+ pt len) t)
952 (delete-region pt (point)))))))
953 ;; In each, find all the menus.
956 (goto-char (point-min))
957 ;; Find each menu, and add an elt to NODES for it.
958 (while (re-search-forward "^\\* Menu:" nil t)
959 (let (beg nodename end)
962 (search-backward "\n\^_")
963 (search-forward "Node: ")
964 (setq nodename (Info-following-node-name))
965 (search-forward "\n\^_" nil 'move)
968 (setq nodes (cons (list nodename other beg end) nodes))))))
969 (setq others (cdr others))))
971 ;; Add to the main menu a menu item for each other node.
972 (re-search-forward "^\\* Menu:" nil t)
974 (let ((menu-items '("top"))
977 (end (save-excursion (search-forward "\^_" nil t) (point))))
979 (let ((nodename (car (car nodes))))
981 (or (member (downcase nodename) menu-items)
982 (re-search-forward (concat "^\\* "
983 (regexp-quote nodename)
987 (insert "* " nodename "::" "\n")
988 (setq menu-items (cons nodename menu-items))))))
989 (setq nodes (cdr nodes))))
990 ;; Now take each node of each of the other buffers
991 ;; and merge it into the main buffer.
993 (let ((nodename (car (car nodes))))
994 (goto-char (point-min))
995 ;; Find the like-named node in the main buffer.
996 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
997 (regexp-quote nodename)
1001 (search-forward "\n\^_" nil 'move)
1004 ;; If none exists, add one.
1005 (goto-char (point-max))
1006 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
1007 ;; Merge the text from the other buffer's menu
1008 ;; into the menu in the like-named node in the main buffer.
1009 (apply 'insert-buffer-substring (cdr (car nodes))))
1010 (setq nodes (cdr nodes)))
1011 ;; Kill all the buffers we just made.
1013 (kill-buffer (car buffers))
1014 (setq buffers (cdr buffers)))
1016 (kill-buffer (car lbuffers))
1017 (setq lbuffers (cdr lbuffers)))
1018 (message "Composing main Info directory...done"))
1019 (setq Info-dir-contents (buffer-string)))
1020 (setq default-directory Info-dir-contents-directory)
1021 (setq buffer-file-name (caar Info-dir-file-attributes)))
1023 (defun Info-maybe-update-dir (file)
1024 "Rebuild dir or localdir according to `Info-auto-generate-directory'."
1025 (unless (or (not (file-exists-p (file-name-directory file)))
1026 (null (directory-files (file-name-directory file) nil "\\.info")))
1027 (if (not (find-buffer-visiting file))
1028 (if (not (file-exists-p file))
1029 (if (or (eq Info-auto-generate-directory 'always)
1030 (eq Info-auto-generate-directory 'if-missing))
1031 (Info-build-dir-anew (file-name-directory file)))
1032 (if (or (eq Info-auto-generate-directory 'always)
1033 (and (eq Info-auto-generate-directory 'if-outdated)
1034 (Info-dir-outdated-p file)))
1035 (Info-rebuild-dir file))))))
1037 ;; Record which *.info files are newer than the dir file
1038 (defvar Info-dir-newer-info-files nil)
1040 (defun Info-dir-outdated-p (file)
1041 "Return non-nil if dir or localdir is outdated.
1042 dir or localdir are outdated when an info file in the same
1043 directory has been modified more recently."
1044 (let ((dir-mod-time (nth 5 (file-attributes file)))
1047 (setq Info-dir-newer-info-files nil)
1051 (setq f-mod-time (nth 5 (file-attributes f)))
1052 (setq newer (or (> (car f-mod-time) (car dir-mod-time))
1053 (and (= (car f-mod-time) (car dir-mod-time))
1054 (> (car (cdr f-mod-time)) (car (cdr dir-mod-time))))))
1055 (if (and (file-readable-p f)
1057 (setq Info-dir-newer-info-files
1058 (cons f Info-dir-newer-info-files)))))
1059 (directory-files (file-name-directory file)
1061 ".*\\.info\\(\\.gz\\|\\.bz2\\|\\.Z\\|-z\\|\\.zip\\)?$"
1064 Info-dir-newer-info-files))
1066 (defun Info-extract-dir-entry-from (file)
1067 "Extract the dir entry from the info FILE.
1068 The dir entry is delimited by the markers `START-INFO-DIR-ENTRY'
1069 and `END-INFO-DIR-ENTRY'"
1071 (set-buffer (get-buffer-create " *Info-tmp*"))
1072 (when (file-readable-p file)
1073 (insert-file-contents file nil nil nil t)
1074 (goto-char (point-min))
1076 (unless (null (re-search-forward "^START-INFO-DIR-ENTRY" nil t))
1079 (unless (null (re-search-forward "^END-INFO-DIR-ENTRY" nil t))
1080 (goto-char (match-beginning 0))
1081 (car (Info-parse-dir-entries beg (point)))))))))
1083 ;; Parse dir entries contained between BEG and END into a list of the form
1084 ;; (filename topic node (description-line-1 description-line-2 ...))
1085 (defun Info-parse-dir-entries (beg end)
1086 (let (entry entries)
1089 (narrow-to-region beg end)
1091 (while (re-search-forward "^\\* \\([^:]+\\):\\([ \t]*(\\([^)]*\\))\\w*\\.\\|:\\)" nil t)
1092 (setq entry (list (match-string 2)
1094 (downcase (or (match-string 3)
1095 (match-string 1)))))
1102 (re-search-forward "[ \t]*" nil t)
1103 (or (and (re-search-forward "^[^ \t]" nil t)
1104 (goto-char (match-beginning 0)))
1106 "[ \t]*\n[ \t]*"))))
1108 (setq entries (cons (nreverse entry) entries)))))
1109 (nreverse entries)))
1111 (defun Info-dump-dir-entries (entries)
1115 (mapcar #'(lambda (e)
1116 (setq e (cdr e)) ; Drop filename
1117 (setq len (length (concat (car e)
1119 (if (> len description-col)
1120 (setq description-col len)))
1122 (setq description-col (+ 5 description-col))
1123 (mapcar #'(lambda (e)
1124 (setq e (cdr e)) ; Drop filename
1125 (insert "* " (car e) ":" (car (cdr e)))
1126 (setq e (car (cdr (cdr e))))
1128 (indent-to-column description-col)
1129 (insert (car e) "\n")
1135 (defun Info-build-dir-anew (directory)
1136 "Build info directory information for DIRECTORY.
1137 The generated directory listing may be saved to a `dir' according
1138 to the value of `Info-save-auto-generated-dir'"
1140 (let* ((dirfile (expand-file-name "dir" directory))
1141 (to-temp (or (null Info-save-auto-generated-dir)
1142 (eq Info-save-auto-generated-dir 'never)
1143 (and (not (file-writable-p dirfile))
1144 (message "File not writable %s. Using temporary." dirfile))))
1146 (directory-files directory
1148 ".*\\.info\\(.gz\\|.Z\\|-z\\|.zip\\)?$"
1152 (message "Creating temporary dir in %s..." directory)
1153 (message "Creating %s..." dirfile))
1154 (set-buffer (find-file-noselect dirfile t))
1155 (setq buffer-read-only nil)
1157 (insert Info-dir-prologue
1158 "Info files in " directory ":\n\n")
1159 (Info-dump-dir-entries
1162 (or (Info-extract-dir-entry-from f)
1165 (string-match "\\(.*\\)\\.info\\(.gz\\|.Z\\|-z\\|.zip\\)?$"
1166 (file-name-nondirectory f))
1167 (capitalize (match-string 1 (file-name-nondirectory f))))
1169 (list Info-no-description-string))))
1172 (set-buffer-modified-p nil)
1175 (message "Creating temporary dir in %s...done" directory)
1176 (message "Creating %s...done" dirfile)))))
1179 (defun Info-rebuild-dir (file)
1180 "Build info directory information in the directory of dir FILE.
1181 Description of info files are merged from the info files in the
1182 directory and the contents of FILE with the description in info files
1183 taking precedence over descriptions in FILE.
1184 The generated directory listing may be saved to a `dir' according to
1185 the value of `Info-save-auto-generated-dir' "
1188 (let (dir-section-contents dir-full-contents
1194 (or (null Info-save-auto-generated-dir)
1195 (eq Info-save-auto-generated-dir 'never)
1196 (and (eq Info-save-auto-generated-dir 'always)
1197 (not (file-writable-p file))
1198 (message "File not writable %s. Using temporary." file))
1199 (and (eq Info-save-auto-generated-dir 'conservative)
1200 (or (and (not (file-writable-p file))
1201 (message "File not writable %s. Using temporary." file))
1203 (message "%s is outdated. Overwrite ? "
1205 (set-buffer (find-file-noselect file t))
1206 (setq buffer-read-only nil)
1208 (message "Rebuilding temporary %s..." file)
1209 (message "Rebuilding %s..." file))
1211 (setq buffer-read-only nil)
1212 (goto-char (point-min))
1213 (unless (and (search-forward "\^_")
1214 (re-search-forward "^\\* Menu:.*$" nil t)
1215 (setq mark (and (re-search-forward "^\\* " nil t)
1216 (match-beginning 0))))
1218 (setq dir-full-contents (Info-parse-dir-entries mark (point-max)))
1219 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$" nil t)
1220 (match-beginning 0))
1223 (narrow-to-region mark next-section)
1224 (setq dir-section-contents (nreverse (Info-parse-dir-entries (point-min)
1228 (setq dir-entry (assoc (downcase
1229 (file-name-sans-extension
1230 (file-name-nondirectory file)))
1231 dir-section-contents)
1232 file-dir-entry (Info-extract-dir-entry-from file))
1235 ;; A dir entry in the info file takes precedence over an
1236 ;; existing entry in the dir file
1237 (setcdr dir-entry (cdr file-dir-entry)))
1238 (unless (or not-first-section
1240 (file-name-sans-extension
1241 (file-name-nondirectory file)))
1244 (setq dir-section-contents (cons file-dir-entry
1245 dir-section-contents))
1246 (setq dir-section-contents
1248 (capitalize (file-name-sans-extension
1249 (file-name-nondirectory file)))
1251 (list Info-no-description-string))
1252 dir-section-contents))))))
1253 Info-dir-newer-info-files)
1254 (delete-region (point-min) (point-max))
1255 (Info-dump-dir-entries (nreverse dir-section-contents))
1257 (if (= next-section (point-max))
1258 (setq next-section nil)
1259 (or (setq mark (and (re-search-forward "^\\* " nil t)
1260 (match-beginning 0)))
1262 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$" nil t)
1263 (match-beginning 0))
1265 (setq not-first-section t)))
1268 (set-buffer-modified-p nil)
1269 (message "Rebuilding temporary %s...done" file))
1271 (message "Rebuilding %s...done" file))))))
1274 (defun Info-batch-rebuild-dir ()
1275 "(Re)build info `dir' files in the directories remaining on the command line.
1276 Use this from the command line, with `-batch';
1277 it won't work in an interactive Emacs.
1278 Each file is processed even if an error occurred previously.
1279 For example, invoke \"xemacs -batch -f Info-batch-rebuild-dir /usr/local/info\""
1280 ;; command-line-args-left is what is left of the command line (from
1282 (defvar command-line-args-left) ; Avoid 'free variable' warning
1283 (if (not noninteractive)
1284 (error "`Info-batch-rebuild-dir' is to be used only with -batch"))
1285 (let ((Info-save-auto-generated-dir 'always)
1287 (while command-line-args-left
1288 (if (not (file-directory-p (car command-line-args-left)))
1289 (message "Warning: Skipped %s. Not a directory."
1290 (car command-line-args-left))
1291 (setq dir (expand-file-name "dir" (car command-line-args-left)))
1292 (setq localdir (expand-file-name "localdir" (car command-line-args-left)))
1294 ((file-exists-p dir)
1295 (Info-rebuild-dir dir))
1296 ((file-exists-p localdir)
1297 (Info-rebuild-dir localdir))
1299 (Info-build-dir-anew (car command-line-args-left)))))
1300 (setq command-line-args-left (cdr command-line-args-left)))
1304 (defun Info-history-add (file node point)
1305 (if Info-keeping-history
1306 (let* ((name (format "(%s)%s" (Info-file-name-only file) node))
1307 (found (assoc name Info-history)))
1309 (setq Info-history (delq found Info-history)))
1310 (setq Info-history (cons (list name (- point (point-min))
1311 (and (eq (window-buffer)
1313 (- (window-start) (point-min))))
1316 (defun Info-file-name-only (file)
1317 (let ((dir (file-name-directory file))
1318 (p Info-directory-list))
1319 (while (and p (not (equal (car p) dir)))
1321 (if p (file-name-nondirectory file) file)))
1323 (defun Info-read-subfile (nodepos)
1327 (set-buffer (marker-buffer Info-tag-table-marker))
1328 (goto-char (point-min))
1329 (search-forward "\n\^_")
1332 (while (not (looking-at "\^_"))
1335 thisfilepos thisfilename)
1336 (search-forward ": ")
1337 (setq thisfilename (buffer-substring beg (- (point) 2)))
1338 (setq thisfilepos (read (current-buffer)))
1339 ;; read in version 19 stops at the end of number.
1340 ;; Advance to the next line.
1343 (if (> thisfilepos nodepos)
1345 (setq lastfilename thisfilename)
1346 (setq lastfilepos thisfilepos))
1348 (or (equal Info-current-subfile lastfilename)
1349 (let ((buffer-read-only nil))
1350 (setq buffer-file-name nil)
1353 (Info-insert-file-contents (Info-suffixed-file
1354 (expand-file-name lastfilename
1355 (file-name-directory
1356 Info-current-file)))
1358 (set-buffer-modified-p nil)
1359 (setq Info-current-subfile lastfilename)))
1360 (goto-char (point-min))
1361 (search-forward "\n\^_")
1362 (+ (- nodepos lastfilepos) (point))))
1364 (defun Info-suffixed-file (name &optional name2)
1365 "Look for NAME with each of the `Info-suffix-list' extensions in
1366 turn. Optional NAME2 is the name of a fallback info file to check
1367 for; usually a downcased version of NAME."
1368 (let ((suff Info-suffix-list)
1371 (while (and suff (not found))
1372 (setq file (concat name (caar suff))
1373 file2 (and name2 (concat name2 (caar suff))))
1375 ((file-regular-p file)
1377 ((and file2 (file-regular-p file2))
1380 (setq suff (cdr suff)))))
1382 (and name (when (file-regular-p name)
1384 (and name2 (when (file-regular-p name2)
1387 (defun Info-insert-file-contents (file &optional visit)
1388 (setq file (expand-file-name file default-directory))
1389 (let ((suff Info-suffix-list))
1390 (while (and suff (or (<= (length file) (length (car (car suff))))
1391 (not (equal (substring file
1392 (- (length (car (car suff)))))
1393 (car (car suff))))))
1394 (setq suff (cdr suff)))
1395 (if (stringp (cdr (car suff)))
1396 (let ((command (if (string-match "%s" (cdr (car suff)))
1397 (format (cdr (car suff)) file)
1398 (concat (cdr (car suff)) " < " file))))
1399 (message "%s..." command)
1400 (call-process shell-file-name nil t nil "-c" command)
1403 (setq buffer-file-name file)
1404 (set-buffer-modified-p nil)
1405 (clear-visited-file-modtime)))
1406 (insert-file-contents file visit))))
1408 (defun Info-select-node ()
1409 "Select the node that point is in, after using `g *' to select whole file."
1413 ;; Find beginning of node.
1414 (search-backward "\n\^_")
1416 ;; Get nodename spelled as it is in the node.
1417 (re-search-forward "Node:[ \t]*")
1418 (setq Info-current-node
1419 (buffer-substring (point)
1421 (skip-chars-forward "^,\t\n")
1423 (Info-set-mode-line)
1424 ;; Find the end of it, and narrow.
1426 (let (active-expression)
1427 (narrow-to-region (point)
1428 (if (re-search-forward "\n[\^_\f]" nil t)
1431 (if (looking-at "[\n\^_\f]*execute: ")
1433 (goto-char (match-end 0))
1434 (setq active-expression
1435 (read (current-buffer))))))
1437 (or (equal Info-footnote-tag "Note")
1439 (goto-char (point-min))
1440 (let ((buffer-read-only nil)
1441 (bufmod (buffer-modified-p))
1442 (case-fold-search t))
1443 (while (re-search-forward "\\*[Nn]ote\\([ \n]\\)" nil t)
1444 (replace-match (concat "*" Info-footnote-tag "\ ")))
1445 (set-buffer-modified-p bufmod))))
1446 (Info-reannotate-node)
1447 ;; XEmacs: remove v19 test
1449 (Info-fontify-node))
1450 (run-hooks 'Info-select-hook)
1451 (if Info-enable-active-nodes (eval active-expression)))))
1453 (defun Info-set-mode-line ()
1454 (setq modeline-buffer-identification
1455 (list (cons modeline-buffer-id-left-extent "Info: ")
1456 (cons modeline-buffer-id-right-extent
1459 (if Info-current-file
1460 (let ((name (file-name-nondirectory Info-current-file)))
1461 (if (string-match "\\.info$" name)
1462 (substring name 0 -5)
1466 (or Info-current-node ""))))))
1468 ;; Go to an info node specified with a filename-and-nodename string
1469 ;; of the sort that is found in pointers in nodes.
1472 (defun Info-goto-node (nodename &optional no-going-back tryfile)
1473 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME.
1474 Actually, the following interpretations of NAME are tried in order:
1476 (FILENAME) (using Top node)
1477 NODENAME (in current file)
1479 FILENAME (using Top node)
1480 where TAGNAME is a string that appears in quotes: \"TAGNAME\", in an
1481 annotation for any node of any file. (See `a' and `x' commands.)"
1482 (interactive (list (Info-read-node-name "Goto node, file or tag: ")
1485 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1487 (setq filename (if (= (match-beginning 1) (match-end 1))
1489 (substring nodename (match-beginning 2) (match-end 2)))
1490 nodename (substring nodename (match-beginning 3) (match-end 3)))
1491 (let ((trim (string-match "\\s *\\'" filename)))
1492 (if trim (setq filename (substring filename 0 trim))))
1493 (let ((trim (string-match "\\s *\\'" nodename)))
1494 (if trim (setq nodename (substring nodename 0 trim))))
1495 (Info-find-node (if (equal filename "") nil filename)
1496 (if (equal nodename "") "Top" nodename)
1497 no-going-back (and tryfile (equal filename "")))))
1499 (defun Info-goto-bookmark ()
1501 (let ((completion-ignore-case nil)
1502 (tag (completing-read "Goto tag: "
1503 (Info-build-annotation-completions)
1505 'Info-minibuffer-history)))
1506 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
1509 (defun Info-visit-file (file)
1510 "Directly visit an info file."
1511 (interactive "fVisit Info file: ")
1512 (Info-find-node (expand-file-name file) "Top"))
1514 (defun Info-restore-point (&optional always)
1515 "Restore point to same location it had last time we were in this node."
1517 (if (or Info-restoring-point always)
1518 (let* ((name (format "(%s)%s"
1519 (Info-file-name-only Info-current-file)
1521 (p (assoc name Info-history)))
1522 (if p (Info-restore-history-entry p)))))
1524 (defun Info-restore-history-entry (entry)
1525 (goto-char (+ (nth 1 entry) (point-min)))
1527 (get-buffer-window (current-buffer))
1528 (set-window-start (get-buffer-window (current-buffer))
1529 (+ (nth 2 entry) (point-min)))))
1531 (defvar Info-read-node-completion-table)
1533 ;; This function is used as the "completion table" while reading a node name.
1534 ;; It does completion using the alist in Info-read-node-completion-table
1535 ;; unless STRING starts with an open-paren.
1536 (defun Info-read-node-name-1 (string predicate code)
1537 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
1538 (cond ((eq code nil)
1541 (try-completion string Info-read-node-completion-table predicate)))
1545 (all-completions string Info-read-node-completion-table predicate)))
1549 (assoc string Info-read-node-completion-table))))))
1551 (defun Info-read-node-name (prompt &optional default)
1552 (Info-setup-initial)
1553 (let* ((completion-ignore-case t)
1554 (Info-read-node-completion-table (Info-build-node-completions))
1555 (nodename (completing-read prompt 'Info-read-node-name-1
1556 nil t nil 'Info-minibuffer-history
1558 (if (equal nodename "")
1560 (Info-read-node-name prompt))
1563 (defun Info-build-annotation-completions ()
1564 (or Info-current-annotation-completions
1566 (let ((bufs (delq nil (mapcar 'get-file-buffer
1567 Info-annotations-path)))
1570 (set-buffer (car bufs))
1571 (goto-char (point-min))
1572 (while (re-search-forward "<<\\(.*\\)>>" nil t)
1573 (setq compl (cons (list (buffer-substring (match-beginning 1)
1576 (setq bufs (cdr bufs)))
1577 (setq Info-current-annotation-completions compl)))))
1579 (defun Info-build-node-completions ()
1580 (or Info-current-file-completions
1581 (let ((m Info-tag-table-marker)
1582 (compl (Info-build-annotation-completions)))
1586 (if (marker-buffer Info-tag-table-marker)
1588 (set-buffer (marker-buffer Info-tag-table-marker))
1590 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
1592 (cons (list (buffer-substring (match-beginning 1)
1595 (goto-char (point-min))
1596 (while (search-forward "\n\^_" nil t)
1598 (let ((beg (point)))
1600 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
1603 (cons (list (buffer-substring (match-beginning 1)
1606 (setq Info-current-file-completions compl))))
1608 (defvar Info-last-search nil
1609 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
1613 (defun Info-search (regexp)
1614 "Search for REGEXP, starting from point, and select node it's found in."
1616 (read-from-minibuffer
1617 (if Info-last-search
1618 (format "Search (regexp, default %s): "
1620 "Search (regexp): ")
1621 nil nil nil nil nil Info-last-search)))
1622 (setq Info-last-search regexp)
1623 (with-search-caps-disable-folding regexp t
1625 (onode Info-current-node)
1626 (ofile Info-current-file)
1628 (osubfile Info-current-subfile))
1632 (if (null Info-current-subfile)
1633 (progn (re-search-forward regexp) (setq found (point)))
1635 (progn (re-search-forward regexp) (setq found (point)))
1636 (search-failed nil)))))
1637 (if (not found) ;can only happen in subfile case -- else would have erred
1641 (set-buffer (marker-buffer Info-tag-table-marker))
1642 (goto-char (point-min))
1643 (search-forward "\n\^_\nIndirect:")
1645 (narrow-to-region (point)
1646 (progn (search-forward "\n\^_")
1648 (goto-char (point-min))
1649 (search-forward (concat "\n" osubfile ": "))
1652 (re-search-forward "\\(^.*\\): [0-9]+$")
1653 (goto-char (+ (match-end 1) 2))
1654 (setq list (cons (cons (read (current-buffer))
1655 (buffer-substring (match-beginning 1)
1658 (goto-char (1+ (match-end 0))))
1659 (setq list (nreverse list)
1662 (message "Searching subfile %s..." (cdr (car list)))
1663 (Info-read-subfile (car (car list)))
1664 (setq list (cdr list))
1665 (goto-char (point-min))
1666 (if (re-search-forward regexp nil t)
1667 (setq found (point) list ())))
1670 (signal 'search-failed (list regexp))))
1672 (progn (Info-read-subfile opoint)
1674 (Info-select-node)))))
1678 (or (and (equal onode Info-current-node)
1679 (equal ofile Info-current-file))
1680 (Info-history-add ofile onode opoint)))))
1682 ;; Extract the value of the node-pointer named NAME.
1683 ;; If there is none, use ERRORNAME in the error message;
1684 ;; if ERRORNAME is nil, just return nil.
1685 (defun Info-extract-pointer (name &optional errorname)
1687 (goto-char (point-min))
1689 (let ((case-fold-search t))
1690 (if (re-search-backward (concat name ":") nil t)
1692 (goto-char (match-end 0))
1693 (Info-following-node-name))
1694 (if (eq errorname t)
1696 (error (concat "Node has no " (capitalize (or errorname name)))))))))
1698 ;; Return the node name in the buffer following point.
1699 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1700 ;; saying which chars may appear in the node name.
1701 (defun Info-following-node-name (&optional allowedchars)
1702 (skip-chars-forward " \t")
1706 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
1707 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
1708 (if (looking-at "(")
1709 (skip-chars-forward "^)")))
1710 (skip-chars-backward " .")
1713 (defun Info-next (&optional n)
1714 "Go to the next node of this node.
1715 A positive or negative prefix argument moves by multiple nodes."
1720 (while (>= (setq n (1- n)) 0)
1721 (Info-goto-node (Info-extract-pointer "next")))))
1723 (defun Info-prev (&optional n)
1724 "Go to the previous node of this node.
1725 A positive or negative prefix argument moves by multiple nodes."
1730 (while (>= (setq n (1- n)) 0)
1731 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))))
1733 (defun Info-up (&optional n)
1734 "Go to the superior node of this node.
1735 A positive prefix argument moves up several times."
1738 (while (>= (setq n (1- n)) 0)
1739 (Info-goto-node (Info-extract-pointer "up")))
1740 (if (interactive-p) (Info-restore-point)))
1742 (defun Info-last (&optional n)
1743 "Go back to the last node visited.
1744 With a prefix argument, go to Nth most recently visited node. History is
1745 circular; after oldest node, history comes back around to most recent one.
1746 Argument can be negative to go through the circle in the other direction.
1747 \(In other words, `l' is like \"undo\" and `C-u - l' is like \"redo\".)"
1751 (error "This is the first Info node you looked at"))
1752 (let ((len (1+ (length Info-history))))
1753 (setq n (% (+ n (* len 100)) len)))
1755 (let ((entry (nth (1- n) Info-history)))
1756 (Info-history-add Info-current-file Info-current-node (point))
1757 (while (>= (setq n (1- n)) 0)
1758 (setq Info-history (nconc (cdr Info-history)
1759 (list (car Info-history)))))
1760 (setq Info-history (cdr Info-history))
1761 (let ((Info-keeping-history nil))
1762 (Info-goto-node (car entry)))
1763 (Info-restore-history-entry entry))))
1765 (defun Info-directory ()
1766 "Go to the Info directory node."
1768 (Info-find-node "dir" "top"))
1770 (defun Info-follow-reference (footnotename)
1771 "Follow cross reference named NAME to the node it refers to.
1772 NAME may be an abbreviation of the reference name."
1774 (let ((completion-ignore-case t)
1775 completions default (start-point (point)) str i)
1777 (goto-char (point-min))
1778 (while (re-search-forward (format "\\*%s[ \n\t]*\\([^:]*\\):"
1781 (setq str (buffer-substring
1784 ;; See if this one should be the default.
1786 (< (match-beginning 0) start-point)
1787 (<= start-point (point))
1790 (while (setq i (string-match "[ \n\t]+" str i))
1791 (setq str (concat (substring str 0 i) " "
1792 (substring str (match-end 0))))
1794 ;; Record as a completion and perhaps as default.
1795 (if (eq default t) (setq default str))
1797 (cons (cons str nil)
1800 (let ((item (completing-read (if default
1801 (concat "Follow reference named: ("
1803 "Follow reference named: ")
1804 completions nil t nil
1805 'Info-minibuffer-history
1807 (if (and (string= item "") default)
1810 (error "No cross-references in this node"))))
1811 (let (target i (str (concat "\\*" Info-footnote-tag " "
1812 (regexp-quote footnotename))))
1813 (while (setq i (string-match " " str i))
1814 (setq str (concat (substring str 0 i) "\\([ \t\n]+\\)"
1815 (substring str (1+ i))))
1818 (goto-char (point-min))
1819 (or (re-search-forward str nil t)
1820 (error "No cross-reference named %s" footnotename))
1821 (goto-char (match-end 1))
1823 (Info-extract-menu-node-name "Bad format cross reference" t)))
1824 (while (setq i (string-match "[ \t\n]+" target i))
1825 (setq target (concat (substring target 0 i) " "
1826 (substring target (match-end 0))))
1828 (Info-goto-node target)
1829 (setq Info-in-cross-reference t)))
1831 (defun Info-next-reference (n)
1833 (let ((pat (format "\\*%s[ \n\t]*\\([^:]*\\):\\|^\\* .*:\\|<<.*>>"
1836 wrapped found-nomenu)
1838 (unless (re-search-backward pat nil t)
1839 ;; Don't wrap more than once in a buffer where only the
1840 ;; menu references are found.
1841 (when (and wrapped (not found-nomenu))
1843 (error "No cross references in this node"))
1845 (goto-char (point-max))
1846 (unless (re-search-backward pat nil t)
1848 (error "No cross references in this node")))
1849 (unless (save-excursion
1850 (goto-char (match-beginning 0))
1851 (when (looking-at "\\* Menu:")
1853 (setq found-nomenu t))
1856 (or (eobp) (forward-char 1))
1857 (unless (re-search-forward pat nil t)
1858 (when (and wrapped (not found-nomenu))
1860 (error "No cross references in this node"))
1862 (goto-char (point-min))
1863 (unless (re-search-forward pat nil t)
1865 (error "No cross references in this node")))
1866 (unless (save-excursion
1867 (goto-char (match-beginning 0))
1868 (when (looking-at "\\* Menu:")
1870 (setq found-nomenu t))
1872 (when (looking-at "\\* Menu:")
1873 (error "No cross references in this node"))
1874 (goto-char (match-beginning 0))))
1876 (defun Info-prev-reference (n)
1878 (Info-next-reference (- n)))
1880 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
1881 (skip-chars-forward " \t\n")
1884 (skip-chars-forward "^:")
1887 (if (looking-at ":")
1888 (buffer-substring beg (1- (point)))
1889 (skip-chars-forward " \t\n")
1891 ;; Allow dots in node name not followed by whitespace.
1893 (concat "\\(([^)]+)[^."
1894 (if multi-line "" "\n")
1896 (if multi-line "" "\n")
1897 ;; We consider dots followed by newline as
1898 ;; end of nodename even if multil-line.
1899 ;; Also stops at .). It is generated by @pxref.
1900 ;; Skips sequential dots.
1901 "]\\|\\.+[^ \t\n)]\\)+\\)"))
1903 (while (setq i (string-match "\n" str i))
1907 (defun Info-menu (menu-item)
1908 "Go to node for menu item named (or abbreviated) NAME.
1909 Completion is allowed, and the menu item point is on is the default."
1911 (let ((completions '())
1912 ;; If point is within a menu item, use that item as the default
1917 (goto-char (point-min))
1918 (let ((case-fold-search t))
1919 (if (not (search-forward "\n* menu:" nil t))
1920 (error "No menu in this node")))
1921 (while (re-search-forward
1922 "\n\\* \\([^:\t\n]*\\):" nil t)
1923 (if (and (null default)
1924 (prog1 (if last (< last p) nil)
1925 (setq last (match-beginning 0)))
1927 (setq default (car (car completions))))
1928 (setq completions (cons (cons (buffer-substring
1931 (match-beginning 1))
1933 (if (and (null default) last
1935 (<= p (progn (end-of-line) (point))))
1936 (setq default (car (car completions)))))
1939 (setq item (let ((completion-ignore-case t))
1940 (completing-read (if default
1941 (format "Menu item (default %s): "
1944 completions nil t nil
1945 'Info-minibuffer-history
1947 ;; we rely on the fact that completing-read accepts an input
1948 ;; of "" even when the require-match argument is true and ""
1949 ;; is not a valid possibility
1950 (if (string= item "")
1956 ;; there is a problem here in that if several menu items have the same
1957 ;; name you can only go to the node of the first with this command.
1958 (Info-goto-node (Info-extract-menu-item menu-item) nil t))
1960 (defun Info-extract-menu-item (menu-item &optional noerror)
1962 (goto-char (point-min))
1963 (if (let ((case-fold-search t))
1964 (search-forward "\n* menu:" nil t))
1965 (if (or (search-forward (concat "\n* " menu-item ":") nil t)
1966 (search-forward (concat "\n* " menu-item) nil t))
1970 (Info-extract-menu-node-name))
1971 (and (not noerror) (error "No such item in menu")))
1972 (and (not noerror) (error "No menu in this node")))))
1974 ;; If COUNT is nil, use the last item in the menu.
1975 (defun Info-extract-menu-counting (count &optional noerror noindex)
1977 (goto-char (point-min))
1978 (if (let ((case-fold-search t))
1979 (and (search-forward "\n* menu:" nil t)
1981 (not (string-match "\\<Index\\>" Info-current-node)))))
1982 (if (search-forward "\n* " nil t count)
1985 (while (search-forward "\n* " nil t)))
1986 (Info-extract-menu-node-name))
1987 (and (not noerror) (error "Too few items in menu")))
1988 (and (not noerror) (error "No menu in this node")))))
1990 (defun Info-nth-menu-item (n)
1991 "Go to the node of the Nth menu item."
1993 (or n (setq n (- last-command-char ?0)))
1994 (if (< n 1) (error "Index must be at least 1"))
1995 (Info-goto-node (Info-extract-menu-counting n) nil t))
1997 (defun Info-last-menu-item ()
1998 "Go to the node of the tenth menu item."
2000 (Info-goto-node (Info-extract-menu-counting nil) nil t))
2003 "Go to the Top node of this file."
2005 (Info-goto-node "Top"))
2008 "Go to the final node in this file."
2011 (let ((Info-keeping-history nil)
2013 (Info-last-menu-item)
2014 (while (setq node (or (Info-extract-pointer "next" t)
2015 (Info-extract-menu-counting nil t t)))
2016 (Info-goto-node node))
2017 (or (equal (Info-extract-pointer "up" t) "Top")
2018 (let ((executing-kbd-macro "")) ; suppress messages
2020 (Info-global-next 10000)
2023 (defun Info-global-next (&optional n)
2024 "Go to the next node in this file, traversing node structure as necessary.
2025 This works only if the Info file is structured as a hierarchy of nodes.
2026 A positive or negative prefix argument moves by multiple nodes."
2030 (Info-global-prev (- n))
2031 (while (>= (setq n (1- n)) 0)
2033 (cond ((and (string-match "^Top$" Info-current-node)
2034 (setq node (Info-extract-pointer "next" t))
2035 (Info-extract-menu-item node t))
2036 (Info-goto-node node))
2037 ((setq node (Info-extract-menu-counting 1 t t))
2038 (message "Going down...")
2039 (Info-goto-node node))
2041 (let ((Info-keeping-history Info-keeping-history)
2042 (orignode Info-current-node)
2044 (while (not (Info-extract-pointer "next" t))
2045 (if (and (setq node (Info-extract-pointer "up" t))
2046 (not (equal node "Top")))
2048 (message "Going%s..." (setq ups (concat ups " up")))
2049 (Info-goto-node node)
2050 (setq Info-keeping-history nil))
2052 (let ((Info-keeping-history nil))
2053 (Info-goto-node orignode)))
2054 (error "Last node in file")))
2057 (defun Info-page-next (&optional n)
2058 "Scroll forward one screenful, or go to next global node.
2059 A positive or negative prefix argument moves by multiple screenfuls."
2063 (Info-page-prev (- n))
2064 (while (>= (setq n (1- n)) 0)
2065 (if (pos-visible-in-window-p (point-max))
2068 (message "Node: %s" Info-current-node))
2071 (defun Info-scroll-next (arg)
2073 (if Info-auto-advance
2074 (if (and (pos-visible-in-window-p (point-max))
2075 (not (eq Info-auto-advance t))
2076 (not (eq last-command this-command)))
2077 (message "Hit %s again to go to next node"
2078 (if (= last-command-char 0)
2080 (key-description (char-to-string last-command-char))))
2082 (setq this-command 'Info))
2085 (defun Info-global-prev (&optional n)
2086 "Go to the previous node in this file, traversing structure as necessary.
2087 This works only if the Info file is structured as a hierarchy of nodes.
2088 A positive or negative prefix argument moves by multiple nodes."
2092 (Info-global-next (- n))
2093 (while (>= (setq n (1- n)) 0)
2094 (let ((upnode (Info-extract-pointer "up" t))
2095 (prevnode (Info-extract-pointer "prev[ious]*" t)))
2096 (if (or (not prevnode)
2097 (equal prevnode upnode))
2098 (if (string-match "^Top$" Info-current-node)
2099 (error "First node in file")
2100 (message "Going up...")
2102 (Info-goto-node prevnode)
2104 (Info-keeping-history nil)
2106 (while (setq node (Info-extract-menu-counting nil t t))
2107 (message "Going%s..." (setq downs (concat downs " down")))
2108 (Info-goto-node node))))))))
2110 (defun Info-page-prev (&optional n)
2111 "Scroll backward one screenful, or go to previous global node.
2112 A positive or negative prefix argument moves by multiple screenfuls."
2116 (Info-page-next (- n))
2117 (while (>= (setq n (1- n)) 0)
2118 (if (pos-visible-in-window-p (point-min))
2121 (message "Node: %s" Info-current-node)
2122 (goto-char (point-max))
2124 (move-to-window-line 0))
2127 (defun Info-scroll-prev (arg)
2129 (if Info-auto-advance
2130 (if (and (pos-visible-in-window-p (point-min))
2131 (not (eq Info-auto-advance t))
2132 (not (eq last-command this-command)))
2133 (message "Hit %s again to go to previous node"
2134 (if (mouse-event-p last-command-event)
2136 (key-description (event-key last-command-event))))
2138 (setq this-command 'Info))
2141 (defun Info-index (topic)
2142 "Look up a string in the index for this file.
2143 The index is defined as the first node in the top-level menu whose
2144 name contains the word \"Index\", plus any immediately following
2145 nodes whose names also contain the word \"Index\".
2146 If there are no exact matches to the specified topic, this chooses
2147 the first match which is a case-insensitive substring of a topic.
2148 Use the `,' command to see the other matches.
2149 Give a blank topic name to go to the Index node itself."
2150 (interactive "sIndex topic: ")
2151 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
2152 (regexp-quote topic)
2153 "\\(.*\\)\\.[ t]*\\([0-9]*\\)$"))
2155 (message "Searching index for `%s'..." topic)
2156 (Info-goto-node "Top")
2157 (let ((case-fold-search t))
2158 (or (search-forward "\n* menu:" nil t)
2160 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
2161 (error "No index")))
2162 (goto-char (match-beginning 1))
2163 (let ((Info-keeping-history nil)
2164 (Info-fontify (and Info-fontify (equal topic ""))))
2165 (Info-goto-node (Info-extract-menu-node-name)))
2166 (or (equal topic "")
2169 (Info-keeping-history nil)
2173 (goto-char (point-min))
2174 (while (re-search-forward pattern nil t)
2176 (cons (list (buffer-substring (match-beginning 1)
2178 (buffer-substring (match-beginning 2)
2181 (string-to-int (concat "0"
2186 (and (setq node (Info-extract-pointer "next" t))
2187 (string-match "\\<Index\\>" node)))
2188 (let ((Info-fontify nil))
2189 (Info-goto-node node)))
2193 (error "No \"%s\" in index" topic)))
2194 ;; Here it is a feature that assoc is case-sensitive.
2195 (while (setq found (assoc topic matches))
2196 (setq exact (cons found exact)
2197 matches (delq found matches)))
2198 (setq Info-index-alternatives (nconc exact (nreverse matches))
2199 Info-index-first-alternative (car Info-index-alternatives))
2200 (Info-index-next 0)))))
2202 (defun Info-index-next (num)
2203 "Go to the next matching index item from the last `i' command."
2205 (or Info-index-alternatives
2206 (error "No previous `i' command in this file"))
2208 (setq num (+ num (length Info-index-alternatives))))
2210 (setq Info-index-alternatives
2211 (nconc (cdr Info-index-alternatives)
2212 (list (car Info-index-alternatives)))
2214 (Info-goto-node (nth 1 (car Info-index-alternatives)))
2215 (if (> (nth 3 (car Info-index-alternatives)) 0)
2216 (forward-line (nth 3 (car Info-index-alternatives)))
2217 (forward-line 3) ; don't search in headers
2218 (let ((name (car (car Info-index-alternatives))))
2219 (if (or (re-search-forward (format
2220 "\\(Function\\|Command\\): %s\\( \\|$\\)"
2221 (regexp-quote name)) nil t)
2222 (re-search-forward (format "^`%s[ ']" (regexp-quote name)) nil t)
2223 (search-forward (format "`%s'" name) nil t)
2224 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
2226 (format "`%s'" (substring name 0 (match-beginning 1)))
2228 (search-forward name nil t))
2230 (goto-char (point-min)))))
2231 (message "Found \"%s\" in %s. %s"
2232 (car (car Info-index-alternatives))
2233 (nth 2 (car Info-index-alternatives))
2234 (if (cdr Info-index-alternatives)
2235 (if (eq (car (cdr Info-index-alternatives))
2236 Info-index-first-alternative)
2237 "(Press `,' to repeat)"
2238 (format "(Press `,' for %d more)"
2239 (- (1- (length Info-index-alternatives))
2240 (length (memq Info-index-first-alternative
2241 (cdr Info-index-alternatives))))))
2246 (defun Info-emacs-command (command)
2247 "Look up an Emacs command in the Emacs manual in the Info system.
2248 This command is designed to be used whether you are already in Info or not."
2249 (interactive "CLook up command in Emacs manual: ")
2250 (save-window-excursion
2252 (Info-find-node Info-emacs-info-file-name "Top")
2253 (Info-index (symbol-name command)))
2254 (pop-to-buffer "*info*"))
2258 (defun Info-goto-emacs-command-node (key)
2259 "Look up an Emacs command in the Emacs manual in the Info system.
2260 This command is designed to be used whether you are already in Info or not."
2261 (interactive "CLook up command in Emacs manual: ")
2262 (Info-emacs-command key))
2265 (defun Info-goto-emacs-key-command-node (key)
2266 "Look up an Emacs key sequence in the Emacs manual in the Info system.
2267 This command is designed to be used whether you are already in Info or not."
2268 (interactive "kLook up key in Emacs manual: ")
2269 (let ((command (key-binding key)))
2270 (cond ((eq command 'keyboard-quit)
2273 (error "%s is undefined" (key-description key)))
2274 ((and (interactive-p) (eq command 'execute-extended-command))
2275 (call-interactively 'Info-goto-emacs-command-node))
2277 (Info-goto-emacs-command-node command)))))
2280 (defun Info-emacs-key (key)
2281 "Look up an Emacs key sequence in the Emacs manual in the Info system.
2282 This command is designed to be used whether you are already in Info or not."
2283 (interactive "kLook up key in Emacs manual: ")
2284 (cond ((eq (key-binding key) 'keyboard-quit)
2286 ((and (interactive-p) (eq (key-binding key) 'execute-extended-command))
2287 (call-interactively 'Info-goto-emacs-command-node))
2289 (save-window-excursion
2291 (Info-find-node Info-emacs-info-file-name "Top")
2292 (setq key (key-description key))
2294 (if (setq p (string-match "[@{}]" key))
2295 (setq key (concat (substring key 0 p) "@" (substring key p))))
2296 (if (string-match "^ESC " key)
2297 (setq key (concat "M-" (substring key 4))))
2298 (if (string-match "^M-C-" key)
2299 (setq key (concat "C-M-" (substring key 4)))))
2301 (pop-to-buffer "*info*"))))
2304 (defun Info-elisp-ref (func)
2305 "Look up an Emacs Lisp function in the Elisp manual in the Info system.
2306 This command is designed to be used whether you are already in Info or not."
2307 (interactive (let ((fn (function-at-point))
2308 (enable-recursive-minibuffers t)
2310 (setq val (completing-read
2311 (format "Look up Emacs Lisp function%s: "
2313 (format " (default %s)" fn)
2315 obarray 'fboundp t))
2316 (list (if (equal val "")
2318 (save-window-excursion
2321 (Info-find-node "lispref" "Top")
2322 (error (Info-find-node "elisp" "Top")))
2323 (Info-index (symbol-name func)))
2324 (pop-to-buffer "*info*"))
2326 (defun Info-reannotate-node ()
2327 (let ((bufs (delq nil (mapcar 'get-file-buffer Info-annotations-path))))
2329 (let ((ibuf (current-buffer))
2330 (file (concat "\\(" (regexp-quote
2331 (file-name-nondirectory Info-current-file))
2332 "\\|" (regexp-quote Info-current-file) "\\)"))
2333 (node (regexp-quote Info-current-node))
2335 (goto-char (point-min))
2336 (if (search-forward "\n------ NOTE:\n" nil t)
2337 (let ((buffer-read-only nil)
2338 (bufmod (buffer-modified-p))
2340 (setq savept (copy-marker savept))
2341 (goto-char (point-min))
2342 (while (search-forward "\n------ NOTE:" nil t)
2343 (setq top (1+ (match-beginning 0)))
2344 (if (search-forward "\n------\n" nil t)
2345 (delete-region top (point)))
2347 (set-buffer-modified-p bufmod)))
2350 (set-buffer (car bufs))
2351 (goto-char (point-min))
2352 (while (re-search-forward
2354 "------ *File: *%s *Node: *%s *Line: *\\([0-9]+\\) *\n"
2357 (let ((line (string-to-int
2358 (buffer-substring (match-beginning 2)
2362 (search-forward "\n------\n" nil t)
2366 (if (integerp savept) (setq savept (copy-marker savept)))
2368 (goto-char (point-max))
2369 (goto-char (point-min))
2370 (forward-line line))
2371 (let ((buffer-read-only nil)
2372 (bufmod (buffer-modified-p)))
2373 (insert "------ NOTE:\n")
2374 (insert-buffer-substring (car bufs) top bot)
2375 (set-buffer-modified-p bufmod)))))
2376 (setq bufs (cdr bufs))))
2377 (goto-char savept)))))
2379 (defvar Info-annotate-map nil
2380 "Local keymap used within `a' command of Info.")
2381 (if Info-annotate-map
2383 ;; (setq Info-annotate-map (nconc (make-sparse-keymap) text-mode-map))
2384 (setq Info-annotate-map (copy-keymap text-mode-map))
2385 (define-key Info-annotate-map "\C-c\C-c" 'Info-cease-annotate))
2387 (defun Info-annotate-mode ()
2388 "Major mode for adding an annotation to an Info node.
2389 Like text mode with the addition of Info-cease-annotate
2390 which returns to Info mode for browsing.
2391 \\{Info-annotate-map}")
2393 (defun Info-annotate (arg)
2394 "Add a personal annotation to the current Info node.
2395 Only you will be able to see this annotation. Annotations are stored
2396 in the file \"~/.xemacs/info.notes\" by default. If point is inside
2397 an existing annotation, edit that annotation. A prefix argument
2398 specifies which annotations file (from `Info-annotations-path') is to
2399 be edited; default is 1."
2402 (if (or (< arg 0) (not (nth arg Info-annotations-path)))
2404 (setq Info-annotations-path
2405 (list (read-file-name
2406 "Annotations file: " "~/" "~/.infonotes")))
2407 (error "File number must be in the range from 1 to %d"
2408 (length Info-annotations-path))))
2410 (file (file-name-nondirectory Info-current-file))
2411 (d Info-directory-list)
2413 (while (and d (not (equal (expand-file-name file (car d))
2414 Info-current-file)))
2416 (or d (setq file Info-current-file))
2417 (if (and (save-excursion
2418 (goto-char (min (point-max) (+ (point) 13)))
2419 (and (search-backward "------ NOTE:\n" nil t)
2420 (setq pt (match-end 0))
2421 (search-forward "\n------\n" nil t)))
2422 (< (point) (match-end 0)))
2423 (setq which (format "File: *%s *Node: *%s *Line:.*\n%s"
2425 (regexp-quote Info-current-node)
2427 (buffer-substring pt (match-beginning 0))))
2428 where (max (- (point) pt) 0)))
2429 (let ((node Info-current-node)
2430 (line (if (looking-at "[ \n]*\\'") 0
2431 (count-lines (point-min) (point)))))
2433 (let ((buffer-read-only nil)
2434 (bufmod (buffer-modified-p)))
2436 (if (bobp) (goto-char (point-max)))
2437 (insert "------ NOTE:\n------\n")
2439 (set-buffer-modified-p bufmod)))
2440 ;; (setq Info-window-start (window-start))
2441 (setq Info-window-configuration (current-window-configuration))
2442 (pop-to-buffer (find-file-noselect (nth arg Info-annotations-path)))
2443 (use-local-map Info-annotate-map)
2444 (setq major-mode 'Info-annotate-mode)
2445 (setq mode-name "Info Annotate")
2448 (goto-char (point-min))
2449 (re-search-forward which nil t))
2451 (goto-char (match-beginning 0))
2453 (forward-char where)))
2454 (let ((bufmod (buffer-modified-p)))
2455 (goto-char (point-max))
2456 (insert (format "\n------ File: %s Node: %s Line: %d\n"
2459 (insert "\n------\n"
2460 "\nPress C-c C-c to save and return to Info.\n")
2462 (set-buffer-modified-p bufmod))))))
2464 (defun Info-cease-annotate ()
2466 (let ((bufmod (buffer-modified-p)))
2467 (while (save-excursion
2468 (goto-char (point-min))
2469 (re-search-forward "\n\n?Press .* to save and return to Info.\n"
2471 (delete-region (1+ (match-beginning 0)) (match-end 0)))
2472 (while (save-excursion
2473 (goto-char (point-min))
2474 (re-search-forward "\n------ File:.*Node:.*Line:.*\n+------\n"
2476 (delete-region (match-beginning 0) (match-end 0)))
2477 (set-buffer-modified-p bufmod))
2481 (or (one-window-p) (delete-window))
2483 (setq Info-current-annotation-completions nil)
2484 (set-window-configuration Info-window-configuration)
2485 (Info-reannotate-node))
2487 (defun Info-bookmark (arg tag)
2488 (interactive "p\nsBookmark name: ")
2490 (if (or (string-match "^\"\\(.*\\)\"$" tag)
2491 (string-match "^<<\\(.*\\)>>$" tag))
2492 (setq tag (substring tag (match-beginning 1) (match-end 1))))
2494 (search-forward "\n------\n")
2495 (let ((end (- (point) 8)))
2497 (if (re-search-forward "<<[^>\n]*>>" nil t)
2498 (delete-region (match-beginning 0) (match-end 0))
2501 (insert "<<" tag ">>"))))
2502 (Info-cease-annotate))
2505 "Exit Info by selecting some other buffer."
2508 (save-buffers-kill-emacs)
2509 (bury-buffer (current-buffer))
2510 (if (and (featurep 'toolbar)
2511 (boundp 'toolbar-info-frame)
2512 (eq toolbar-info-frame (selected-frame)))
2514 (delete-frame toolbar-info-frame)
2515 (error (bury-buffer)))
2516 (switch-to-buffer (other-buffer (current-buffer))))))
2518 (defun Info-undefined ()
2519 "Make command be undefined in Info."
2524 "Enter the Info tutorial."
2526 (delete-other-windows)
2527 (Info-find-node "info"
2528 (if (< (window-height) 23)
2532 (defun Info-summary ()
2533 "Display a brief summary of all Info commands."
2535 (save-window-excursion
2536 (switch-to-buffer "*Help*")
2538 (insert (documentation 'Info-mode))
2539 (goto-char (point-min))
2541 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
2542 (message (if flag "Type Space to see more"
2543 "Type Space to return to Info"))
2544 (let ((e (next-command-event)))
2545 (if (/= ?\ (event-to-character e))
2546 (progn (setq unread-command-event e) nil)
2550 (bury-buffer "*Help*")))
2552 (defun Info-get-token (pos start all &optional errorstring)
2553 "Return the token around POS,
2554 POS must be somewhere inside the token
2555 START is a regular expression which will match the
2556 beginning of the tokens delimited string
2557 ALL is a regular expression with a single
2558 parenthized subpattern which is the token to be
2559 returned. E.g. '{\(.*\)}' would return any string
2560 enclosed in braces around POS.
2561 SIG optional fourth argument, controls action on no match
2564 a string: signal an error, using that string."
2566 (goto-char (point-min))
2567 (re-search-backward "\\`") ; Bug fix due to Nicholas J. Foskett.
2569 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
2571 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
2572 (not (setq found (and (<= (match-beginning 0) pos)
2573 (> (match-end 0) pos))))))
2574 (if (and found (<= (match-beginning 0) pos)
2575 (> (match-end 0) pos))
2576 (buffer-substring (match-beginning 1) (match-end 1))
2577 (cond ((null errorstring)
2583 (error "No %s around position %d" errorstring pos)))))))
2585 (defun Info-follow-clicked-node (event)
2586 "Follow a node reference near clicked point. Like M, F, N, P or U command.
2587 At end of the node's text, moves to the next node."
2589 (or (and (event-point event)
2590 (Info-follow-nearest-node
2592 (select-window (event-window event))
2593 (event-point event))
2595 (error "click on a cross-reference to follow")))
2597 (defun Info-maybe-follow-clicked-node (event &optional click-count)
2598 "Follow a node reference (if any) near clicked point.
2599 Like M, F, N, P or U command. At end of the node's text, moves to the
2600 next node. No error is given if there is no node to follow."
2602 (and Info-button1-follows-hyperlink
2604 (Info-follow-nearest-node
2606 (select-window (event-window event))
2607 (event-point event))
2608 (1+ (point-min))))))
2610 (defun Info-find-nearest-node (point)
2613 ((= point (point-min)) nil) ; don't trigger on accidental RET.
2614 ((setq node (Info-get-token point
2615 (format "\\*%s[ \n]" Info-footnote-tag)
2616 (format "\\*%s[ \n]\\([^:]*\\):"
2617 Info-footnote-tag)))
2618 (list "Following cross-reference %s..."
2619 (list 'Info-follow-reference node)))
2620 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\)::"))
2621 (list "Selecting menu item %s..."
2622 (list 'Info-goto-node node nil t)))
2623 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\):"))
2624 (list "Selecting menu item %s..."
2625 (list 'Info-menu node)))
2626 ((setq node (Info-get-token point "Up: " "Up: \\([^,\n\t]*\\)"))
2628 (list 'Info-goto-node node)))
2629 ((setq node (Info-get-token point "Next: " "Next: \\([^,\n\t]*\\)"))
2630 (list "Next node..."
2631 (list 'Info-goto-node node)))
2632 ((setq node (Info-get-token point "File: " "File: \\([^,\n\t]*\\)"))
2634 (list 'Info-goto-node "Top")))
2635 ((setq node (Info-get-token point "Prev[ious]*: "
2636 "Prev[ious]*: \\([^,\n\t]*\\)"))
2637 (list "Previous node..."
2638 (list 'Info-goto-node node)))
2639 ((setq node (Info-get-token point "Node: " "Node: \\([^,\n\t]*\\)"))
2640 (list "Reselecting %s..."
2641 (list 'Info-goto-node node)))
2642 ((save-excursion (goto-char point) (looking-at "[ \n]*\\'"))
2643 (if Info-in-cross-reference
2644 (list "Back to last node..."
2646 (list "Next node..."
2647 '(Info-global-next)))))
2650 (defun Info-follow-nearest-node (point)
2651 "Follow a node reference near point. Like M, F, N, P or U command.
2652 At end of the node's text, moves to the next node."
2654 (let ((data (Info-find-nearest-node point)))
2657 (let ((msg (format (car data) (nth 1 (nth 1 data)))))
2660 (message "%sdone" msg))
2663 (defun Info-indicated-node (event)
2666 (cond ((eventp event)
2667 (set-buffer (event-buffer event))
2668 (setq event (event-point event))))
2669 (let* ((data (Info-find-nearest-node event))
2670 (name (nth 1 (nth 1 data))))
2671 (and name (nth 1 data))))
2674 (defun Info-mouse-track-double-click-hook (event click-count)
2675 "Handle double-clicks by turning pages, like the `gv' ghostscript viewer"
2676 (if (/= click-count 2)
2677 ;; Return nil so any other hooks are performed.
2679 (let* ((fw (face-width 'default))
2680 (fh (face-height 'default))
2681 (x (/ (event-x-pixel event) fw))
2682 (y (/ (event-y-pixel event) fw))
2683 (w (/ (window-pixel-width (event-window event)) fw))
2684 (h (/ (window-pixel-height (event-window event)) fh))
2688 ((<= y by) (Info-up) t)
2689 ((>= y (- h by)) (Info-nth-menu-item 1) t)
2690 ((<= x bx) (Info-prev) t)
2691 ((>= x (- w bx)) (Info-next) t)
2694 (defvar Info-mode-map nil
2695 "Keymap containing Info commands.")
2698 (setq Info-mode-map (make-sparse-keymap))
2699 (suppress-keymap Info-mode-map)
2700 (define-key Info-mode-map "." 'beginning-of-buffer)
2701 (define-key Info-mode-map " " 'Info-scroll-next)
2702 (define-key Info-mode-map "1" 'Info-nth-menu-item)
2703 (define-key Info-mode-map "2" 'Info-nth-menu-item)
2704 (define-key Info-mode-map "3" 'Info-nth-menu-item)
2705 (define-key Info-mode-map "4" 'Info-nth-menu-item)
2706 (define-key Info-mode-map "5" 'Info-nth-menu-item)
2707 (define-key Info-mode-map "6" 'Info-nth-menu-item)
2708 (define-key Info-mode-map "7" 'Info-nth-menu-item)
2709 (define-key Info-mode-map "8" 'Info-nth-menu-item)
2710 (define-key Info-mode-map "9" 'Info-nth-menu-item)
2711 (define-key Info-mode-map "0" 'Info-last-menu-item)
2712 (define-key Info-mode-map "?" 'Info-summary)
2713 (define-key Info-mode-map "a" 'Info-annotate)
2714 (define-key Info-mode-map "b" 'beginning-of-buffer)
2715 (define-key Info-mode-map "d" 'Info-directory)
2716 (define-key Info-mode-map "e" 'Info-edit)
2717 (define-key Info-mode-map "f" 'Info-follow-reference)
2718 (define-key Info-mode-map "g" 'Info-goto-node)
2719 (define-key Info-mode-map "h" 'Info-help)
2720 (define-key Info-mode-map "i" 'Info-index)
2721 (define-key Info-mode-map "j" 'Info-goto-bookmark)
2722 (define-key Info-mode-map "k" 'Info-emacs-key)
2723 (define-key Info-mode-map "l" 'Info-last)
2724 (define-key Info-mode-map "m" 'Info-menu)
2725 (define-key Info-mode-map "n" 'Info-next)
2726 (define-key Info-mode-map "p" 'Info-prev)
2727 (define-key Info-mode-map "q" 'Info-exit)
2728 (define-key Info-mode-map "r" 'Info-follow-reference)
2729 (define-key Info-mode-map "s" 'Info-search)
2730 (define-key Info-mode-map "t" 'Info-top)
2731 (define-key Info-mode-map "u" 'Info-up)
2732 (define-key Info-mode-map "v" 'Info-visit-file)
2733 (define-key Info-mode-map "x" 'Info-bookmark)
2734 (define-key Info-mode-map "<" 'Info-top)
2735 (define-key Info-mode-map ">" 'Info-end)
2736 (define-key Info-mode-map "[" 'Info-global-prev)
2737 (define-key Info-mode-map "]" 'Info-global-next)
2738 (define-key Info-mode-map "{" 'Info-page-prev)
2739 (define-key Info-mode-map "}" 'Info-page-next)
2740 (define-key Info-mode-map "=" 'Info-restore-point)
2741 (define-key Info-mode-map "!" 'Info-select-node)
2742 (define-key Info-mode-map "@" 'Info-follow-nearest-node)
2743 (define-key Info-mode-map "," 'Info-index-next)
2744 (define-key Info-mode-map "*" 'Info-elisp-ref)
2745 (define-key Info-mode-map [tab] 'Info-next-reference)
2746 (define-key Info-mode-map [(meta tab)] 'Info-prev-reference)
2747 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference)
2748 (define-key Info-mode-map "\r" 'Info-follow-nearest-node)
2750 (define-key Info-mode-map 'backspace 'Info-scroll-prev)
2751 (define-key Info-mode-map 'delete 'Info-scroll-prev)
2752 (define-key Info-mode-map 'button2 'Info-follow-clicked-node)
2753 (define-key Info-mode-map 'button3 'Info-select-node-menu))
2756 ;; Info mode is suitable only for specially formatted data.
2757 (put 'info-mode 'mode-class 'special)
2760 "Info mode is for browsing through the Info documentation tree.
2761 Documentation in Info is divided into \"nodes\", each of which
2762 discusses one topic and contains references to other nodes
2763 which discuss related topics. Info has commands to follow
2764 the references and show you other nodes.
2766 h Invoke the Info tutorial.
2767 q Quit Info: return to the previously selected file or buffer.
2769 Selecting other nodes:
2770 n Move to the \"next\" node of this node.
2771 p Move to the \"previous\" node of this node.
2772 m Pick menu item specified by name (or abbreviation).
2773 1-9, 0 Pick first..ninth, last item in node's menu.
2774 Menu items select nodes that are \"subsections\" of this node.
2775 u Move \"up\" from this node (i.e., from a subsection to a section).
2776 f or r Follow a cross reference by name (or abbrev). Type `l' to get back.
2777 RET Follow cross reference or menu item indicated by cursor.
2778 i Look up a topic in this file's Index and move to that node.
2779 , (comma) Move to the next match from a previous `i' command.
2780 l (letter L) Move back to the last node you were in.
2782 Moving within a node:
2783 Space Scroll forward a full screen. DEL Scroll backward.
2784 b Go to beginning of node. Meta-> Go to end of node.
2785 TAB Go to next cross-reference. Meta-TAB Go to previous ref.
2788 Left Button Set point (usual text-mode functionality)
2789 Middle Button Click on a highlighted node reference to go to it.
2790 Right Button Pop up a menu of applicable Info commands.
2792 Left Button Double Click in window edges:
2793 Top edge: Go up to the parent node, like `u'.
2794 Left edge: Go to the previous node, like `p'.
2795 Right edge: Go to the next node, like `n'.
2796 Bottom edge: Follow first menu item, like `1'.
2799 g Move to node, file, or annotation tag specified by name.
2800 Examples: `g Rectangles' `g (Emacs)Rectangles' `g Emacs'.
2801 v Move to file, with filename completion.
2802 k Look up a key sequence in Emacs manual (also C-h C-k at any time).
2803 * Look up a function name in Emacs Lisp manual (also C-h C-f).
2804 d Go to the main directory of Info files.
2805 < or t Go to Top (first) node of this file.
2806 > Go to last node in this file.
2807 \[ Go to previous node, treating file as one linear document.
2808 \] Go to next node, treating file as one linear document.
2809 { Scroll backward, or go to previous node if at top.
2810 } Scroll forward, or go to next node if at bottom.
2811 = Restore cursor position from last time in this node.
2812 a Add a private note (annotation) to the current node.
2813 x, j Add, jump to a bookmark (annotation tag).
2814 s Search this Info file for a node containing the specified regexp.
2815 e Edit the contents of the current node."
2816 (kill-all-local-variables)
2817 (setq major-mode 'Info-mode)
2818 (setq mode-name "Info")
2819 (use-local-map Info-mode-map)
2820 (set-syntax-table text-mode-syntax-table)
2821 (setq local-abbrev-table text-mode-abbrev-table)
2822 (setq case-fold-search t)
2823 (setq buffer-read-only t)
2824 ; (setq buffer-mouse-map Info-mode-mouse-map)
2825 (make-local-variable 'Info-current-file)
2826 (make-local-variable 'Info-current-subfile)
2827 (make-local-variable 'Info-current-node)
2828 (make-local-variable 'Info-tag-table-marker)
2829 (setq Info-tag-table-marker (make-marker))
2830 (make-local-variable 'Info-tag-table-buffer)
2831 (setq Info-tag-table-buffer nil)
2832 (make-local-variable 'Info-current-file-completions)
2833 (make-local-variable 'Info-current-annotation-completions)
2834 (make-local-variable 'Info-index-alternatives)
2835 (make-local-variable 'Info-history)
2836 ;; Faces are now defined by `defface'...
2837 (make-local-variable 'mouse-track-click-hook)
2838 (add-hook 'mouse-track-click-hook 'Info-maybe-follow-clicked-node)
2839 (add-hook 'mouse-track-click-hook 'Info-mouse-track-double-click-hook)
2840 ;; #### The console-on-window-system-p check is to allow this to
2841 ;; work on tty's. The real problem here is that featurep really
2842 ;; needs to have some device/console domain knowledge added to it.
2843 (defvar info::toolbar)
2844 (if (and (featurep 'toolbar)
2845 (console-on-window-system-p)
2846 (not Info-inhibit-toolbar))
2847 (set-specifier default-toolbar (cons (current-buffer) info::toolbar)))
2848 (if (featurep 'menubar)
2850 ;; make a local copy of the menubar, so our modes don't
2851 ;; change the global menubar
2852 (easy-menu-add '("Info" :filter Info-menu-filter))))
2853 (run-hooks 'Info-mode-hook)
2854 (Info-set-mode-line))
2856 (defvar Info-edit-map nil
2857 "Local keymap used within `e' command of Info.")
2860 ;; XEmacs: remove FSF stuff
2861 (setq Info-edit-map (make-sparse-keymap))
2862 (set-keymap-name Info-edit-map 'Info-edit-map)
2863 (set-keymap-parents Info-edit-map (list text-mode-map))
2864 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
2866 ;; Info-edit mode is suitable only for specially formatted data.
2867 (put 'info-edit-mode 'mode-class 'special)
2869 (defun Info-edit-mode ()
2870 "Major mode for editing the contents of an Info node.
2871 Like text mode with the addition of `Info-cease-edit'
2872 which returns to Info mode for browsing.
2877 "Edit the contents of this Info node.
2878 Allowed only if variable `Info-enable-edit' is non-nil."
2880 (or Info-enable-edit
2881 (error "Editing info nodes is not enabled"))
2882 (use-local-map Info-edit-map)
2883 (setq major-mode 'Info-edit-mode)
2884 (setq mode-name "Info Edit")
2885 (kill-local-variable 'modeline-buffer-identification)
2886 (setq buffer-read-only nil)
2887 ;; Make mode line update.
2888 (set-buffer-modified-p (buffer-modified-p))
2889 (message (substitute-command-keys
2890 "Editing: Type \\[Info-cease-edit] to return to info")))
2892 (defun Info-cease-edit ()
2893 "Finish editing Info node; switch back to Info proper."
2895 ;; Do this first, so nothing has changed if user C-g's at query.
2896 (and (buffer-modified-p)
2897 (y-or-n-p "Save the file? ")
2899 (use-local-map Info-mode-map)
2900 (setq major-mode 'Info-mode)
2901 (setq mode-name "Info")
2902 (Info-set-mode-line)
2903 (setq buffer-read-only t)
2904 ;; Make mode line update.
2905 (set-buffer-modified-p (buffer-modified-p))
2906 (and (marker-position Info-tag-table-marker)
2908 (message "Tags may have changed. Use Info-tagify if necessary")))
2910 (defun Info-find-emacs-command-nodes (command)
2911 "Return a list of locations documenting COMMAND in the XEmacs Info manual.
2912 The locations are of the format used in Info-history, i.e.
2913 \(FILENAME NODENAME BUFFERPOS\)."
2915 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
2916 ":\\s *\\(.*\\)\\.$")))
2918 (Info-find-node "XEmacs" "Command Index")
2919 ;; Take the index node off the Info history.
2920 ;; ??? says this isn't safe someplace else... hmmm.
2921 (setq Info-history (cdr Info-history))
2922 (goto-char (point-max))
2923 (while (re-search-backward cmd-desc nil t)
2924 (setq where (cons (list Info-current-file
2932 ;;; fontification and mousability for info
2934 (defun Info-highlight-region (start end face)
2936 (splitp (string-match "\n[ \t]+" (buffer-substring start end))))
2939 (setq extent (make-extent start (progn (goto-char start)
2942 (set-extent-face extent face)
2943 (set-extent-property extent 'info t)
2944 (set-extent-property extent 'highlight t)
2945 (skip-chars-forward "\n\t ")
2946 (setq extent (make-extent (point) end)))
2947 (setq extent (make-extent start end)))
2948 (set-extent-face extent face)
2949 (set-extent-property extent 'info t)
2950 (set-extent-property extent 'highlight t)))
2952 (defun Info-fontify-node ()
2954 (let ((case-fold-search t)
2955 (xref-regexp (concat "\\*"
2956 (regexp-quote Info-footnote-tag)
2957 "[ \n\t]*\\([^:]*\\):")))
2958 ;; Clear the old extents
2959 (map-extents #'(lambda (x y) (delete-extent x))
2960 (current-buffer) (point-min) (point-max) nil)
2961 ;; Break the top line iff it is > 79 characters. Some info nodes
2962 ;; have top lines that span 3 lines because of long node titles.
2963 ;; eg: (Info-find-node "lispref.info" "Window-Level Event Position Info")
2964 (toggle-read-only -1)
2969 (goto-char (point-min))
2970 (re-search-forward "Node: *[^,]+, " nil t)
2971 (setq len (- (point) (point-min))
2972 extent (make-extent (point-min) (point)))
2973 (set-extent-property extent 'invisible t)
2977 (if (< (current-column) (+ 78 len))
2980 (forward-char (+ 79 len))
2981 (re-search-backward "," nil t)
2985 (backward-delete-char 1)
2988 (toggle-read-only 1)
2989 ;; Highlight xrefs in the top few lines of the node
2990 (goto-char (point-min))
2991 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
2993 (goto-char (match-end 0))
2995 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?\n?")
2996 (goto-char (match-end 0))
2997 (Info-highlight-region (match-beginning 1) (match-end 1) 'info-xref))))
2998 ;; Now get the xrefs in the body
2999 (goto-char (point-min))
3000 (while (re-search-forward xref-regexp nil t)
3001 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
3003 (Info-highlight-region (match-beginning 1) (match-end 1) 'info-xref)))
3004 ;; then highlight the nodes in the menu.
3005 (goto-char (point-min))
3006 (if (and (search-forward "\n* menu:" nil t))
3007 (while (re-search-forward
3008 "^\\* \\([^:\t\n]*\\):?:[ \t\n]" nil t)
3009 (Info-highlight-region (match-beginning 1) (match-end 1) 'info-node)))
3010 (set-buffer-modified-p nil))))
3012 (defun Info-construct-menu (&optional event)
3013 "Construct a menu of Info commands.
3014 Adds an entry for the node at EVENT, or under point if EVENT is omitted.
3015 Used to construct the menubar submenu and popup menu."
3016 (or event (setq event (point)))
3017 (let ((case-fold-search t)
3018 (xref-regexp (concat "\\*"
3019 (regexp-quote Info-footnote-tag)
3020 "[ \n\t]*\\([^:]*\\):"))
3021 up-p prev-p next-p menu xrefs subnodes in)
3023 ;; `one-space' fixes "Notes:" xrefs that are split across lines.
3027 (while (setq i (string-match "[ \n\t]+" text i))
3028 (setq text (concat (substring text 0 i) " "
3029 (substring text (match-end 0))))
3032 (goto-char (point-min))
3033 (if (looking-at ".*\\bNext:") (setq next-p t))
3034 (if (looking-at ".*\\bPrev:") (setq prev-p t))
3035 (if (looking-at ".*Up:") (setq up-p t))
3037 (if (setq in (Info-indicated-node event))
3038 (list (vector (one-space (cadr in)) in t)
3039 "--:shadowEtchedIn"))
3041 ["Goto Info Top-level" Info-directory]
3042 (vector "Next Node" 'Info-next :active next-p)
3043 (vector "Previous Node" 'Info-prev :active prev-p)
3044 (vector "Parent Node (Up)" 'Info-up :active up-p)
3045 ["Goto Node..." Info-goto-node]
3046 ["Goto Last Visited Node " Info-last])))
3047 ;; Find the xrefs and make a list
3048 (while (re-search-forward xref-regexp nil t)
3049 (setq xrefs (cons (one-space (buffer-substring (match-beginning 1)
3052 (setq xrefs (nreverse xrefs))
3053 (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more)))
3054 ;; Find the subnodes and make a list
3055 (goto-char (point-min))
3056 (if (search-forward "\n* menu:" nil t)
3057 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
3058 (setq subnodes (cons (buffer-substring (match-beginning 1)
3061 (setq subnodes (nreverse subnodes))
3062 (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more))))
3064 (nconc menu (list "--:shadowDoubleEtchedIn"
3067 (mapcar #'(lambda (xref)
3071 (list 'Info-follow-reference xref))))
3074 (nconc menu (list "--:shadowDoubleEtchedIn"
3077 (mapcar #'(lambda (node)
3080 (vector node (list 'Info-menu node))))
3084 (defun Info-menu-filter (menu)
3085 "This is the menu filter for the \"Info\" submenu."
3086 (Info-construct-menu))
3088 (defun Info-select-node-menu (event)
3089 "Pops up a menu of applicable Info commands."
3091 (select-window (event-window event))
3092 (let ((menu (Info-construct-menu event)))
3093 (setq menu (nconc (list "Info" ; title: not displayed
3095 "--:shadowDoubleEtchedOut")
3097 (let ((popup-menu-titles nil))
3098 (popup-menu menu))))
3100 ;;; Info toolbar support
3102 ;; exit icon taken from GNUS
3103 (defvar info::toolbar-exit-icon
3104 (if (featurep 'toolbar)
3105 (toolbar-make-button-list
3106 (expand-file-name (if (featurep 'xpm) "info-exit.xpm" "info-exit.xbm")
3107 toolbar-icon-directory)))
3110 (defvar info::toolbar-up-icon
3111 (if (featurep 'toolbar)
3112 (toolbar-make-button-list
3113 (expand-file-name (if (featurep 'xpm) "info-up.xpm" "info-up.xbm")
3114 toolbar-icon-directory)))
3117 (defvar info::toolbar-next-icon
3118 (if (featurep 'toolbar)
3119 (toolbar-make-button-list
3120 (expand-file-name (if (featurep 'xpm) "info-next.xpm" "info-next.xbm")
3121 toolbar-icon-directory)))
3124 (defvar info::toolbar-prev-icon
3125 (if (featurep 'toolbar)
3126 (toolbar-make-button-list
3127 (expand-file-name (if (featurep 'xpm) "info-prev.xpm" "info-prev.xbm")
3128 toolbar-icon-directory)))
3131 (defvar info::toolbar
3132 (if (featurep 'toolbar)
3133 ; disabled until we get the next/prev-win icons working again.
3134 ; (cons (first initial-toolbar-spec)
3135 ; (cons (second initial-toolbar-spec)
3136 '([info::toolbar-exit-icon
3140 [info::toolbar-next-icon
3143 "Next entry in same section"]
3144 [info::toolbar-prev-icon
3147 "Prev entry in same section"]
3148 [info::toolbar-up-icon
3151 "Up entry to enclosing section"]
3157 (run-hooks 'Info-load-hook)
3159 ;;; info.el ends here