("Czech"): Fix the documentation.
[bpt/emacs.git] / lisp / info.el
index 28ec2ca..9ce5bb7 100644 (file)
@@ -1,7 +1,7 @@
-;;; info.el --- info package for Emacs.
+;;; info.el --- info package for Emacs
 
-;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software
-;; Foundation, Inc.
+;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
+;;  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help
@@ -61,22 +61,22 @@ The Lisp code is executed when the node is selected.")
   :group 'info)
 
 (defface info-node
-  '((((class color) (background light)) (:foreground "brown" :bold t :italic t))
-    (((class color) (background dark)) (:foreground "white" :bold t :italic t))
-    (t (:bold t :italic t)))
+  '((((class color) (background light)) (:foreground "brown" :weight bold :slant italic))
+    (((class color) (background dark)) (:foreground "white" :weight bold :slant italic))
+    (t (:weight bold :slant italic)))
   "Face for Info node names."
   :group 'info)
 
 (defface info-menu-5
   '((((class color)) (:foreground "red1"))
     (t (:underline t)))
-  "Face for the fifth and tenth `*' in an Info menu."
+  "Face for the fifth and nineth `*' in an Info menu."
   :group 'info)
 
 (defface info-xref
-  '((((class color) (background light)) (:foreground "magenta4" :bold t))
-    (((class color) (background dark)) (:foreground "cyan" :bold t))
-    (t (:bold t)))
+  '((((class color) (background light)) (:foreground "magenta4" :weight bold))
+    (((class color) (background dark)) (:foreground "cyan" :weight bold))
+    (t (:weight bold)))
   "Face for Info cross-references."
   :group 'info)
 
@@ -108,11 +108,21 @@ variable INFOPATH to initialize it, or `Info-default-directory-list'
 if there is no INFOPATH variable in the environment.
 
 When `Info-directory-list' is initialized from the value of
-`Info-default-directory-list', the first element of the resulting
+`Info-default-directory-list', and Emacs is installed in one of the
+standard directories, the directory of Info files that come with Emacs
+is put last (so that local Info files override standard ones).
+
+When `Info-directory-list' is initialized from the value of
+`Info-default-directory-list', and Emacs is not installed in one
+of the standard directories, the first element of the resulting
 list is the directory where Emacs installs the Info files that
 come with it.  This is so that Emacs's own manual, which suits the
-version of Emacs you are using, will always be found first.  (If
-you want to override that, set INFOPATH in the environment.)
+version of Emacs you are using, will always be found first.  This
+is useful when you install an experimental version of Emacs without
+removing the standard installation.
+
+If you want to override the order of directories in
+`Info-default-directory-list', set INFOPATH in the environment.
 
 If you run the Emacs executable from the `src' directory in the Emacs
 source tree, and INFOPATH is not defined, the `info' directory in the
@@ -122,10 +132,24 @@ a version of Emacs without installing it.")
 
 (defcustom Info-additional-directory-list nil
   "List of additional directories to search for Info documentation files.
-These directories are not searched for merging the `dir' file."
+These directories are searched after those in `Info-directory-list', and
+they are not searched for merging the `dir' file."
   :type '(repeat directory)
   :group 'info)
 
+(defcustom Info-scroll-prefer-subnodes t
+  "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
+If this is non-nil, and you scroll far enough in a node that its menu
+appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
+moves to a subnode indicated by the following menu item.  This means
+that you visit a subnode before getting to the end of the menu.
+
+Setting this option to nil results in behavior similar to the stand-alone
+Info reader program, which visits the first subnode from the menu only
+when you hit the end of the current node."
+  :type 'boolean
+  :group 'info)
+
 (defvar Info-current-file nil
   "Info file that Info is now looking at, or nil.
 This is the name that was specified in Info, not the actual file name.
@@ -161,7 +185,7 @@ Marker points nowhere if file has no tag table.")
   (if (eq system-type 'ms-dos)
       '( (".gz"      . "gunzip")
         (".z"       . "gunzip")
-        (".bz2"     . "bzip2 -dc")
+        (".bz2"     . ("bzip2" "-dc"))
         (".inz"     . "gunzip")
         (".igz"     . "gunzip")
         (".info.Z"  . "gunzip")
@@ -179,37 +203,42 @@ Marker points nowhere if file has no tag table.")
        (".info.Y".    "unyabba")
        (".info.gz".   "gunzip")
        (".info.z".    "gunzip")
-       (".info.bz2" . "bzip2 -dc")
+       (".info.bz2" . ("bzip2" "-dc"))
        (".info".      nil)
        ("-info.Z".   "uncompress")
        ("-info.Y".   "unyabba")
        ("-info.gz".  "gunzip")
-       ("-info.bz2" . "bzip2 -dc")
+       ("-info.bz2" . ("bzip2" "-dc"))
        ("-info.z".   "gunzip")
        ("-info".     nil)
        ("/index.Z".   "uncompress")
        ("/index.Y".   "unyabba")
        ("/index.gz".  "gunzip")
        ("/index.z".   "gunzip")
-       ("/index.bz2". "bzip2 -dc")
+       ("/index.bz2". ("bzip2" "-dc"))
        ("/index".     nil)
        (".Z".         "uncompress")
        (".Y".         "unyabba")
        (".gz".        "gunzip")
        (".z".         "gunzip")
-       (".bz2" .      "bzip2 -dc")
+       (".bz2" .      ("bzip2" "-dc"))
        ("".           nil)))
   "List of file name suffixes and associated decoding commands.
 Each entry should be (SUFFIX . STRING); the file is given to
-the command as standard input.  If STRING is nil, no decoding is done.
+the command as standard input.
+
+STRING may be a list of strings.  In that case, the first element is
+the command name, and the rest are arguments to that command.
+
+If STRING is nil, no decoding is done.
 Because the SUFFIXes are tried in order, the empty string should
 be last in the list.")
 
 ;; Concatenate SUFFIX onto FILENAME.  SUFFIX should start with a dot.
-;; First, on ms-dos, delete some of the extension in FILENAME
-;; to make room.
-(defun info-insert-file-contents-1 (filename suffix)
-  (if (not (eq system-type 'ms-dos))
+;; First, on MS-DOS with no long file names support, delete some of
+;; the extension in FILENAME to make room.
+(defun info-insert-file-contents-1 (filename suffix lfn)
+  (if lfn      ; long file names are supported
       (concat filename suffix)
     (let* ((sans-exts (file-name-sans-extension filename))
           ;; How long is the extension in FILENAME (not counting the dot).
@@ -235,9 +264,13 @@ be last in the list.")
 (defun info-insert-file-contents (filename &optional visit)
   "Insert the contents of an info file in the current buffer.
 Do the right thing if the file has been compressed or zipped."
-  (let ((tail Info-suffix-list)
-       fullname decoder)
-    (if (file-exists-p filename)
+  (let* ((tail Info-suffix-list)
+        (lfn (or (not (fboundp 'msdos-long-file-names))
+                 (msdos-long-file-names)))
+        (check-short (and (fboundp 'msdos-long-file-names)
+                          lfn))
+        fullname decoder done)
+    (if (info-file-exists-p filename)
        ;; FILENAME exists--see if that name contains a suffix.
        ;; If so, set DECODE accordingly.
        (progn
@@ -249,14 +282,23 @@ Do the right thing if the file has been compressed or zipped."
          (setq fullname filename
                decoder (cdr (car tail))))
       ;; Try adding suffixes to FILENAME and see if we can find something.
-      (while (and tail
-                 (not (info-file-exists-p (info-insert-file-contents-1
-                                           filename (car (car tail))))))
+      (while (and tail (not done))
+       (setq fullname (info-insert-file-contents-1 filename
+                                                   (car (car tail)) lfn))
+       (if (info-file-exists-p fullname)
+           (setq done t
+                 ;; If we found a file with a suffix, set DECODER
+                 ;; according to the suffix.
+                 decoder (cdr (car tail)))
+         ;; When the MS-DOS port runs on Windows, we need to check
+         ;; the short variant of a long file name as well.
+         (when check-short
+           (setq fullname (info-insert-file-contents-1 filename
+                                                       (car (car tail)) nil))
+           (if (info-file-exists-p fullname)
+               (setq done t
+                     decoder (cdr (car tail))))))
        (setq tail (cdr tail)))
-      ;; If we found a file with a suffix, set DECODER according to the suffix
-      ;; and set FULLNAME to the file's actual name.
-      (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
-           decoder (cdr (car tail)))
       (or tail
          (error "Can't find %s or any compressed version of it" filename)))
     ;; check for conflict with jka-compr
@@ -271,7 +313,10 @@ Do the right thing if the file has been compressed or zipped."
                (coding-system-for-write 'no-conversion)
                (default-directory (or (file-name-directory fullname)
                                       default-directory)))
-           (call-process-region (point-min) (point-max) decoder t t)))
+           (or (consp decoder)
+               (setq decoder (list decoder)))
+           (apply 'call-process-region (point-min) (point-max)
+                  (car decoder) t t nil (cdr decoder))))
       (insert-file-contents fullname visit))))
 \f
 (defun info-initialize ()
@@ -280,7 +325,18 @@ Do the right thing if the file has been compressed or zipped."
     (let ((path (getenv "INFOPATH"))
          (source (expand-file-name "info/" source-directory))
          (sibling (if installation-directory
-                      (expand-file-name "info/" installation-directory)))
+                      (expand-file-name "info/" installation-directory)
+                    (if invocation-directory
+                        (let ((infodir (expand-file-name
+                                        "../info/"
+                                        invocation-directory)))
+                          (if (file-exists-p infodir)
+                              infodir
+                            (setq infodir (expand-file-name
+                                           "../../../info/"
+                                           invocation-directory))
+                            (and (file-exists-p infodir)
+                                 infodir))))))
          alternative)
       (setq Info-directory-list
            (prune-directory-list
@@ -367,7 +423,7 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
               (save-buffers-kill-emacs)))
     (info)))
 \f
-;; See if the the accessible portion of the buffer begins with a node
+;; See if the accessible portion of the buffer begins with a node
 ;; delimiter, and the node header line which follows matches REGEXP.
 ;; Typically, this test will be followed by a loop that examines the
 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
@@ -377,7 +433,7 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
 ;; want to use the results of re-search-backward.
 
 ;; The return value is the value of point at the beginning of matching
-;; REGERXP, if the function succeeds, nil otherwise.
+;; REGEXP, if the function succeeds, nil otherwise.
 (defun Info-node-at-bob-matching (regexp)
   (and (bobp)                          ; are we at beginning of buffer?
        (looking-at "\^_")              ; does it begin with node delimiter?
@@ -417,16 +473,24 @@ it says do not attempt further (recursive) error recovery."
               (setq temp-downcase
                     (expand-file-name (downcase filename) (car dirs)))
               ;; Try several variants of specified name.
-              (let ((suffix-list Info-suffix-list))
+              (let ((suffix-list Info-suffix-list)
+                   (lfn (or (not (fboundp 'msdos-long-file-names))
+                            (msdos-long-file-names))))
                 (while (and suffix-list (not found))
                   (cond ((info-file-exists-p
                           (info-insert-file-contents-1
-                           temp (car (car suffix-list))))
+                           temp (car (car suffix-list)) lfn))
                          (setq found temp))
                         ((info-file-exists-p
                           (info-insert-file-contents-1
-                           temp-downcase (car (car suffix-list))))
-                         (setq found temp-downcase)))
+                           temp-downcase (car (car suffix-list)) lfn))
+                         (setq found temp-downcase))
+                       ((and (fboundp 'msdos-long-file-names)
+                             lfn
+                             (info-file-exists-p
+                              (info-insert-file-contents-1
+                               temp (car (car suffix-list)) nil)))
+                        (setq found temp)))
                   (setq suffix-list (cdr suffix-list))))
               (setq dirs (cdr dirs)))))
         (if found
@@ -444,12 +508,12 @@ it says do not attempt further (recursive) error recovery."
 (defun Info-on-current-buffer (&optional nodename)
   "Use the `Info-mode' to browse the current info buffer.
 If a prefix arg is provided, it queries for the NODENAME which
-else defaults to `Top'."
+else defaults to \"Top\"."
   (interactive
    (list (if current-prefix-arg
             (completing-read "Node name: " (Info-build-node-completions)
-                             nil t "Top")
-          "Top")))
+                             nil t "Top"))))
+  (unless nodename (setq nodename "Top"))
   (info-initialize)
   (Info-mode)
   (set (make-local-variable 'Info-current-file) t)
@@ -545,7 +609,7 @@ a case-insensitive match is tried."
               (erase-buffer)
               (if (eq filename t)
                   (Info-insert-dir)
-                (info-insert-file-contents filename t)
+                (info-insert-file-contents filename nil)
                 (setq default-directory (file-name-directory filename)))
               (set-buffer-modified-p nil)
               ;; See whether file has a tag table.  Record the location if yes.
@@ -600,7 +664,7 @@ a case-insensitive match is tried."
           ;; Search file for a suitable node.
          (let ((guesspos (point-min))
                (regexp (concat "\\(Node:\\|Ref:\\) *\\("
-                               (if (stringp nodename) 
+                               (if (stringp nodename)
                                    (regexp-quote nodename)
                                  "")
                                "\\) *[,\t\n\177]"))
@@ -772,6 +836,8 @@ a case-insensitive match is tried."
            (while (re-search-forward "^\\* Menu:" nil t)
              (let (beg nodename end)
                (forward-line 1)
+               (while (and (eolp) (not (eobp)))
+                 (forward-line 1))
                (setq beg (point))
                (or (search-backward "\n\^_" nil 'move)
                    (looking-at "\^_")
@@ -884,6 +950,8 @@ a case-insensitive match is tried."
          (info-insert-file-contents lastfilename)
          (set-buffer-modified-p nil)
          (setq Info-current-subfile lastfilename)))
+    ;; Widen in case we are in the same subfile as before.
+    (widen)
     (goto-char (point-min))
     (if (looking-at "\^_")
        (forward-char 1)
@@ -931,37 +999,55 @@ Bind this in case the user sets it to nil."
        (if Info-fontify (Info-fontify-node))
        (if Info-use-header-line
            (Info-setup-header-line)
-         (setq Info-header-line nil))
+         (setq Info-header-line nil)
+         (setq header-line-format nil)) ; so the header line isn't displayed
        (run-hooks 'Info-selection-hook)))))
 
 (defun Info-set-mode-line ()
   (setq mode-line-buffer-identification
-       (concat
-        "  *Info* ("
-        (file-name-nondirectory (if (stringp Info-current-file)
-                                    Info-current-file
-                                  (or buffer-file-name "")))
-        ") "
-        (or Info-current-node ""))))
+       (nconc (propertized-buffer-identification "%b")
+              (list
+               (concat " ("
+                       (file-name-nondirectory
+                        (if (stringp Info-current-file)
+                            Info-current-file
+                          (or buffer-file-name "")))
+                       ") "
+                       (or Info-current-node ""))))))
 \f
 ;; Skip the node header and make it into a header-line.  This function
 ;; should be called when the node is already narrowed.
 (defun Info-setup-header-line ()
   (goto-char (point-min))
-  (forward-line 1)
-  (set (make-local-variable 'Info-header-line)
-       (buffer-substring (point-min) (1- (point))))
-  (setq header-line-format 'Info-header-line)
-  (narrow-to-region (point) (point-max)))
+  (let* ((case-fold-search t)
+        (header-end (save-excursion (forward-line 1) (1- (point))))
+        ;; If we find neither Next: nor Prev: link, show the entire
+        ;; node header.  Otherwise, don't show the File: and Node:
+        ;; parts, to avoid wasting precious space on information that
+        ;; is available in the mode line.
+        (header-beg (if (re-search-forward
+                         "\\(next\\|prev[ious]*\\): "
+                         header-end t)
+                        (match-beginning 1)
+                      (point))))
+    (set (make-local-variable 'Info-header-line)
+        (buffer-substring header-beg header-end))
+    (setq header-line-format 'Info-header-line)
+    (narrow-to-region (1+ header-end) (point-max))))
 \f
 ;; Go to an info node specified with a filename-and-nodename string
 ;; of the sort that is found in pointers in nodes.
 
 (defun Info-goto-node (nodename &optional fork)
-  "Go to info node named NAME.  Give just NODENAME or (FILENAME)NODENAME.
-If FORK is non-nil, show the node in a new info buffer.
+  "Go to info node named NODENAME.  Give just NODENAME or (FILENAME)NODENAME.
+If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
+FILENAME; otherwise, NODENAME should be in the current Info file (or one of
+its sub-files).
+Completion is available, but only for node names in the current Info file.
+If FORK is non-nil (interactively with a prefix arg), show the node in
+a new info buffer.
 If FORK is a string, it is the name to use for the new buffer."
-  (interactive (list (Info-read-node-name "Goto node: ") current-prefix-arg))
+  (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
   (info-initialize)
   (if fork
       (set-buffer
@@ -1042,7 +1128,7 @@ If FORK is a string, it is the name to use for the new buffer."
                            (cons (list (match-string-no-properties 1))
                                  compl))))))))
        (setq compl (cons '("*") compl))
-       (setq Info-current-file-completions compl))))
+       (set (make-local-variable 'Info-current-file-completions) compl))))
 \f
 (defun Info-restore-point (hl)
   "If this node has been visited, restore the point value when we left."
@@ -1060,8 +1146,12 @@ If FORK is a string, it is the name to use for the new buffer."
 
 (defun Info-search (regexp)
   "Search for REGEXP, starting from point, and select node it's found in."
-  (interactive (list (read-string "Regexp search: "
-                                 nil 'Info-search-history)))
+  (interactive (list (read-string
+                     (if Info-search-history
+                         (format "Regexp search (default `%s'): "
+                                 (car Info-search-history))
+                       "Regexp search: ")
+                     nil 'Info-search-history)))
   (when transient-mark-mode
     (deactivate-mark))
   (when (equal regexp "")
@@ -1109,7 +1199,6 @@ If FORK is a string, it is the name to use for the new buffer."
                  (message "Searching subfile %s..." (cdr (car list)))
                  (Info-read-subfile (car (car list)))
                  (setq list (cdr list))
-;;;            (goto-char (point-min))
                  (if (re-search-forward regexp nil t)
                      (setq found (point) list ())))
                (if found
@@ -1144,9 +1233,9 @@ Bind this in case the user sets it to nil."
          (forward-line -1))
        (let ((bound (point)))
          (forward-line 1)
-         (cond ((re-search-backward (concat name ":") nil bound)
-           (goto-char (match-end 0))
-           (Info-following-node-name))
+         (cond ((re-search-backward (concat name ":") bound t)
+                (goto-char (match-end 0))
+                (Info-following-node-name))
                ((not (eq errorname t))
                 (error "Node has no %s"
                        (capitalize (or errorname name))))))))))
@@ -1264,8 +1353,9 @@ FOOTNOTENAME may be an abbreviation of the reference name."
          (setq default (car (car completions))))
      (if completions
         (let ((input (completing-read (if default
-                                          (concat "Follow reference named: ("
-                                                  default ") ")
+                                          (concat
+                                           "Follow reference named: (default "
+                                           default ") ")
                                         "Follow reference named: ")
                                       completions nil t)))
           (list (if (equal input "")
@@ -1304,12 +1394,7 @@ FOOTNOTENAME may be an abbreviation of the reference name."
              (buffer-substring-no-properties beg (1- (point)))
            (skip-chars-forward " \t\n")
            (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
-    (while (setq i (string-match "\n" str i))
-      (aset str i ?\ ))
-    ;; Collapse multiple spaces.
-    (while (string-match "  +" str)
-      (setq str (replace-match " " t t str)))
-    str))
+    (replace-regexp-in-string "[ \n]+" " " str)))
 
 ;; No one calls this.
 ;;(defun Info-menu-item-sequence (list)
@@ -1318,54 +1403,72 @@ FOOTNOTENAME may be an abbreviation of the reference name."
 ;;    (setq list (cdr list))))
 
 (defvar Info-complete-menu-buffer)
+(defvar Info-complete-next-re nil)
+(defvar Info-complete-cache nil)
 
 (defun Info-complete-menu-item (string predicate action)
-  (let ((completion-ignore-case t)
-       (case-fold-search t))
-    (cond ((eq action nil)
-          (let (completions
-                (pattern (concat "\n\\* +\\("
-                                 (regexp-quote string)
-                                 "[^:\t\n]*\\):")))
-            (save-excursion
-              (set-buffer Info-complete-menu-buffer)
-              (goto-char (point-min))
-              (search-forward "\n* Menu:")
-              (while (re-search-forward pattern nil t)
-                (setq completions
-                      (cons (cons (match-string-no-properties 1)
-                                  (match-beginning 1))
-                            completions))))
-            (try-completion string completions predicate)))
-         ((eq action t)
-          (let (completions
-                (pattern (concat "\n\\* +\\("
-                                 (regexp-quote string)
-                                 "[^:\t\n]*\\):")))
-            (save-excursion
-              (set-buffer Info-complete-menu-buffer)
-              (goto-char (point-min))
-              (search-forward "\n* Menu:")
-              (while (re-search-forward pattern nil t)
-                (setq completions (cons (cons
-                                         (match-string-no-properties 1)
-                                         (match-beginning 1))
-                                        completions))))
-            (all-completions string completions predicate)))
-         (t
-          (save-excursion
-            (set-buffer Info-complete-menu-buffer)
-            (goto-char (point-min))
-            (search-forward "\n* Menu:")
-            (re-search-forward (concat "\n\\* +"
-                                       (regexp-quote string)
-                                       ":")
-                               nil t))))))
+  ;; This uses two dynamically bound variables:
+  ;; - `Info-complete-menu-buffer' which contains the buffer in which
+  ;; is the menu of items we're trying to complete.
+  ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
+  ;; also look for menu items in subsequent nodes as long as those
+  ;; nodes' names match `Info-complete-next-re'.  This feature is currently
+  ;; only used for completion in Info-index.
+  (save-excursion
+    (set-buffer Info-complete-menu-buffer)
+    (let ((completion-ignore-case t)
+         (case-fold-search t)
+         (orignode Info-current-node)
+         nextnode)
+      (goto-char (point-min))
+      (search-forward "\n* Menu:")
+      (if (not (memq action '(nil t)))
+         (re-search-forward
+          (concat "\n\\* +" (regexp-quote string) ":") nil t)
+       (let ((pattern (concat "\n\\* +\\("
+                              (regexp-quote string)
+                              "[^:\t\n]*\\):"))
+             completions)
+         ;; Check the cache.
+         (if (and (equal (nth 0 Info-complete-cache) Info-current-file)
+                  (equal (nth 1 Info-complete-cache) Info-current-node)
+                  (equal (nth 2 Info-complete-cache) Info-complete-next-re)
+                  (let ((prev (nth 3 Info-complete-cache)))
+                    (eq t (compare-strings string 0 (length prev)
+                                           prev 0 nil t))))
+             ;; We can reuse the previous list.
+             (setq completions (nth 4 Info-complete-cache))
+           ;; The cache can't be used.
+           (while
+               (progn
+                 (while (re-search-forward pattern nil t)
+                   (push (cons (match-string-no-properties 1)
+                               (match-beginning 1))
+                         completions))
+                 ;; Check subsequent nodes if applicable.
+                 (and Info-complete-next-re
+                      (setq nextnode (Info-extract-pointer "next" t))
+                      (string-match Info-complete-next-re nextnode)))
+             (Info-goto-node nextnode))
+           ;; Go back to the start node (for the next completion).
+           (unless (equal Info-current-node orignode)
+             (Info-goto-node orignode))
+           ;; Update the cache.
+           (setq Info-complete-cache
+                 (list Info-current-file Info-current-node
+                       Info-complete-next-re string completions)))
+         (if action
+             (all-completions string completions predicate)
+           (try-completion string completions predicate)))))))
 
 
 (defun Info-menu (menu-item &optional fork)
-  "Go to node for menu item named (or abbreviated) NAME.
-Completion is allowed, and the menu item point is on is the default."
+  "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
+The menu item should one of those listed in the current node's menu.
+Completion is allowed, and the default menu item is the one point is on.
+If FORK is non-nil (interactively with a prefix arg), show the node in
+a new info buffer.  If FORK is a string, it is the name to use for the
+new buffer."
   (interactive
    (let ((completions '())
         ;; If point is within a menu item, use that item as the default
@@ -1481,10 +1584,28 @@ N is the digit argument used to invoke this command."
                (not (string-match "\\<index\\>" Info-current-node)))
           (Info-goto-node (Info-extract-menu-counting 1))
           t)
-         ((save-excursion (search-backward "next:" nil t))
+         ((save-excursion
+            (save-restriction
+              (let (limit)
+                (when Info-header-line
+                  (goto-char (point-min))
+                  (widen)
+                  (forward-line -1)
+                  (setq limit (point))
+                  (forward-line 1))
+                (search-backward "next:" limit t))))
           (Info-next)
           t)
-         ((and (save-excursion (search-backward "up:" nil t))
+         ((and (save-excursion
+                 (save-restriction
+                   (let (limit)
+                     (when Info-header-line
+                       (goto-char (point-min))
+                       (widen)
+                       (forward-line -1)
+                       (setq limit (point))
+                       (forward-line 1))
+                     (search-backward "up:" limit t))))
                ;; Use string-equal, not equal, to ignore text props.
                (not (string-equal (downcase (Info-extract-pointer "up"))
                                   "top")))
@@ -1590,7 +1711,8 @@ N is the digit argument used to invoke this command."
                 ;; so we can scroll back through it.
                 (goto-char (point-max))))
         (recenter -1))
-       ((and (not (equal (Info-extract-pointer "up")
+       ((and (Info-no-error (Info-extract-pointer "prev"))
+             (not (equal (Info-extract-pointer "up")
                          (Info-extract-pointer "prev"))))
         (Info-no-error (Info-prev))
         (goto-char (point-max))
@@ -1610,13 +1732,16 @@ N is the digit argument used to invoke this command."
 (defun Info-scroll-up ()
   "Scroll one screenful forward in Info, considering all nodes as one sequence.
 Once you scroll far enough in a node that its menu appears on the screen
-but after point, the next scroll moves into its first subnode.
+but after point, the next scroll moves into its first subnode, unless
+`Info-scroll-prefer-subnodes' is nil.
 
-When you scroll past the end of a node, that goes to the next node; if
-this node has no successor, it moves to the parent node's successor,
-and so on.  If point is inside the menu of a node, it moves to
-subnode indicated by the following menu item.  (That case won't
-normally result from this command, but can happen in other ways.)"
+When you scroll past the end of a node, that goes to the next node if
+`Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
+if this node has no successor, it moves to the parent node's successor,
+and so on.  If `Info-scroll-prefer-subnodes' is non-nil and point is inside
+the menu of a node, it moves to subnode indicated by the following menu
+item.  (That case won't normally result from this command, but can happen
+in other ways.)"
 
   (interactive)
   (if (or (< (window-start) (point-min))
@@ -1625,33 +1750,41 @@ normally result from this command, but can happen in other ways.)"
   (let* ((case-fold-search t)
         (virtual-end (save-excursion
                        (goto-char (point-min))
-                       (if (search-forward "\n* Menu:" nil t)
+                       (if (and Info-scroll-prefer-subnodes
+                                (search-forward "\n* Menu:" nil t))
                            (point)
                          (point-max)))))
     (if (or (< virtual-end (window-start))
            (pos-visible-in-window-p virtual-end))
-       (Info-next-preorder)
+       (cond
+        (Info-scroll-prefer-subnodes (Info-next-preorder))
+        ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
+        (t (Info-next-preorder)))
       (scroll-up))))
 
 (defun Info-scroll-down ()
   "Scroll one screenful back in Info, considering all nodes as one sequence.
-Within the menu of a node, this goes to its last subnode.
-When you scroll past the beginning of a node, that goes to the
-previous node or back up to the parent node."
+If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
+is non-nil, this goes to its last subnode.  When you scroll past the
+beginning of a node, that goes to the previous node or back up to the
+parent node."
   (interactive)
   (if (or (< (window-start) (point-min))
          (> (window-start) (point-max)))
       (set-window-start (selected-window) (point)))
   (let* ((case-fold-search t)
         (current-point (point))
-        (virtual-end (save-excursion
-                       (beginning-of-line)
-                       (setq current-point (point))
-                       (goto-char (point-min))
-                       (search-forward "\n* Menu:"
-                                       current-point
-                                       t))))
-    (if (or virtual-end (pos-visible-in-window-p (point-min)))
+        (virtual-end
+         (and Info-scroll-prefer-subnodes
+              (save-excursion
+                (beginning-of-line)
+                (setq current-point (point))
+                (goto-char (point-min))
+                (search-forward "\n* Menu:"
+                                current-point
+                                t)))))
+    (if (or virtual-end 
+           (pos-visible-in-window-p (point-min) nil t))
        (Info-last-preorder)
       (scroll-down))))
 
@@ -1694,51 +1827,61 @@ previous node or back up to the parent node."
            (error "No cross references in this node")
          (Info-prev-reference t)))))
 
+(defun Info-goto-index ()
+  (Info-goto-node "Top")
+  (or (search-forward "\n* menu:" nil t)
+      (error "No index"))
+  (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
+      (error "No index"))
+  (goto-char (match-beginning 1))
+  ;; Protect Info-history so that the current node (Top) is not added to it.
+  (let ((Info-history nil))
+    (Info-goto-node (Info-extract-menu-node-name))))
+
 (defun Info-index (topic)
   "Look up a string TOPIC in the index for this file.
-The index is defined as the first node in the top-level menu whose
+The index is defined as the first node in the top level menu whose
 name contains the word \"Index\", plus any immediately following
 nodes whose names also contain the word \"Index\".
 If there are no exact matches to the specified topic, this chooses
 the first match which is a case-insensitive substring of a topic.
 Use the `,' command to see the other matches.
 Give a blank topic name to go to the Index node itself."
-  (interactive "sIndex topic: ")
+  (interactive
+   (list
+    (let ((Info-complete-menu-buffer (clone-buffer))
+         (Info-complete-next-re "\\<Index\\>"))
+      (unwind-protect
+         (with-current-buffer Info-complete-menu-buffer
+           (Info-goto-index)
+           (completing-read "Index topic: " 'Info-complete-menu-item))
+       (kill-buffer Info-complete-menu-buffer)))))
   (let ((orignode Info-current-node)
        (rnode nil)
        (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
                         (regexp-quote topic)))
        node
        (case-fold-search t))
-    (Info-goto-node "Top")
-    (or (search-forward "\n* menu:" nil t)
-       (error "No index"))
-    (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
-       (error "No index"))
-    (goto-char (match-beginning 1))
-    ;; Here, and subsequently in this function,
-    ;; we bind Info-history to nil for internal node-switches
-    ;; so that we don't put junk in the history.
-    ;; In the first Info-goto-node call, above, we do update the history
-    ;; because that is what the user's previous node choice into it.
-    (let ((Info-history nil))
-      (Info-goto-node (Info-extract-menu-node-name)))
+    (Info-goto-index)
     (or (equal topic "")
        (let ((matches nil)
              (exact nil)
+             ;; We bind Info-history to nil for internal node-switches so
+             ;; that we don't put junk in the history.  In the first
+             ;; Info-goto-index call, above, we do update the history
+             ;; because that is what the user's previous node choice into it.
              (Info-history nil)
              found)
          (while
              (progn
                (goto-char (point-min))
                (while (re-search-forward pattern nil t)
-                 (setq matches
-                       (cons (list (match-string-no-properties 1)
-                                   (match-string-no-properties 2)
-                                   Info-current-node
-                                   (string-to-int (concat "0"
-                                                          (match-string 3))))
-                             matches)))
+                 (push (list (match-string-no-properties 1)
+                             (match-string-no-properties 2)
+                             Info-current-node
+                             (string-to-int (concat "0"
+                                                    (match-string 3))))
+                       matches))
                (and (setq node (Info-extract-pointer "next" t))
                     (string-match "\\<Index\\>" node)))
            (Info-goto-node node))
@@ -1873,11 +2016,7 @@ ERRORSTRING optional fourth argument, controls action on no match
 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
 At end of the node's text, moves to the next node, or up if none."
   (interactive "e")
-  (let* ((start (event-start click))
-        (window (car start))
-        (pos (car (cdr start))))
-    (select-window window)
-    (goto-char pos))
+  (mouse-set-point click)
   (and (not (Info-try-follow-nearest-node))
        (save-excursion (forward-line 1) (eobp))
        (Info-next-preorder)))
@@ -1984,6 +2123,8 @@ If no reference to follow, moves to the next node, or up if none."
     :help "Go backward one node, considering all as a sequence"]
    ["Forward" Info-forward-node
     :help "Go forward one node, considering all as a sequence"]
+   ["Beginning" beginning-of-buffer
+    :help "Go to beginning of this node"]
    ["Top" Info-top-node
     :help "Go to top node of file"]
    ["Final Node" Info-final-node
@@ -1992,16 +2133,35 @@ If no reference to follow, moves to the next node, or up if none."
    ("Reference" ["You should never see this" report-emacs-bug t])
    ["Search..." Info-search
     :help "Search for regular expression in this Info file"]
-   ["Goto Node..." Info-goto-node
+   ["Go to Node..." Info-goto-node
     :help "Go to a named node"]
-   ["Last" Info-last Info-history
+   ["Last" Info-last :active Info-history
     :help "Go to the last node you were at"]
    ("Index..."
     ["Lookup a String" Info-index
      :help "Look for a string in the index items"]
     ["Next Matching Item" Info-index-next
      :help "Look for another occurrence of previous item"])
-   ["Exit" Info-exit t]))
+   ["Edit" Info-edit :help "Edit contents of this node"
+    :active Info-enable-edit]
+   ["Copy Node Name" Info-copy-current-node-name
+    :help "Copy the name of the current node into the kill ring"]
+   ["Exit" Info-exit :help "Stop reading Info"]))
+
+
+(defvar info-tool-bar-map
+  (if (display-graphic-p)
+      (let ((tool-bar-map (make-sparse-keymap)))
+       (tool-bar-add-item-from-menu 'Info-exit "close" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-prev "left_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-next "right_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-up "up_arrow" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-last "undo" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-top-node "home" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-index "index" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-goto-node "jump_to" Info-mode-map)
+       (tool-bar-add-item-from-menu 'Info-search "search" Info-mode-map)
+       tool-bar-map)))
 
 (defvar Info-menu-last-node nil)
 ;; Last node the menu was created for.
@@ -2017,8 +2177,7 @@ If no reference to follow, moves to the next node, or up if none."
        ;; Update menu menu.
        (let* ((Info-complete-menu-buffer (current-buffer))
               (items (nreverse (condition-case nil
-                                   (Info-complete-menu-item
-                                    "" (lambda (e) t) t)
+                                   (Info-complete-menu-item "" nil t)
                                  (error nil))))
               entries current
               (number 0))
@@ -2033,7 +2192,7 @@ If no reference to follow, moves to the next node, or up if none."
          (if items
              (setq entries (cons ["Other..." Info-menu t] entries)))
          (or entries
-             (setq entries (list ["No menu" nil nil])))
+             (setq entries (list ["No menu" nil nil] nil :active)))
          (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
        ;; Update reference menu.  Code stolen from `Info-follow-reference'.
        (let ((items nil)
@@ -2065,7 +2224,7 @@ If no reference to follow, moves to the next node, or up if none."
              (setq entries (cons ["Other..." Info-follow-reference t]
                                  entries)))
          (or entries
-             (setq entries (list ["No references" nil nil])))
+             (setq entries (list ["No references" nil nil] nil :active)))
          (easy-menu-change '("Info") "Reference" (nreverse entries)))
        ;; Update last seen node.
        (setq Info-menu-last-node (list Info-current-file Info-current-node)))
@@ -2073,8 +2232,25 @@ If no reference to follow, moves to the next node, or up if none."
     (error (ding))))
 
 \f
+(defun Info-copy-current-node-name ()
+  "Put the name of the current info node into the kill ring.
+The name of the info file is prepended to the node name in parentheses."
+  (interactive)
+  (unless Info-current-node
+    (error "No current info node"))
+  (kill-new
+   (concat "("
+          (file-name-nondirectory
+           (if (stringp Info-current-file)
+               Info-current-file
+             (or buffer-file-name "")))
+          ")"
+          Info-current-node)))
+
+\f
 ;; Info mode is suitable only for specially formatted data.
-(put 'info-mode 'mode-class 'special)
+(put 'Info-mode 'mode-class 'special)
+(put 'Info-mode 'no-clone-indirect t)
 
 (defun Info-mode ()
   "Info mode provides commands for browsing through the Info documentation tree.
@@ -2096,7 +2272,7 @@ Selecting other nodes:
 \\[Info-prev]  Move to the \"previous\" node of this node.
 \\[Info-up]    Move \"up\" from this node.
 \\[Info-menu]  Pick menu item specified by name (or abbreviation).
-       Picking a menu item causes another node to be selected.
+         Picking a menu item causes another node to be selected.
 \\[Info-directory]     Go to the Info directory node.
 \\[Info-follow-reference]      Follow a cross reference.  Reads name of reference.
 \\[Info-last]  Move to the last node you were at.
@@ -2109,12 +2285,13 @@ Selecting other nodes:
 
 Moving within a node:
 \\[Info-scroll-up]     Normally, scroll forward a full screen.
-Once you scroll far enough in a node that its menu appears on the screen
-but after point, the next scroll moves into its first subnode.
-When after all menu items (or if their is no menu), move up to
-the parent node.
+         Once you scroll far enough in a node that its menu appears on the
+         screen but after point, the next scroll moves into its first
+         subnode.  When after all menu items (or if there is no menu),
+         move up to the parent node.
 \\[Info-scroll-down]   Normally, scroll backward.  If the beginning of the buffer is
-already visible, try to go to the previous menu entry, or up if there is none.
+         already visible, try to go to the previous menu entry, or up
+         if there is none.
 \\[beginning-of-buffer]        Go to beginning of node.
 
 Advanced commands:
@@ -2123,10 +2300,10 @@ Advanced commands:
 1      Pick first item in node's menu.
 2, 3, 4, 5   Pick second ... fifth item in node's menu.
 \\[Info-goto-node]     Move to node specified by name.
-       You may include a filename as well, as (FILENAME)NODENAME.
+         You may include a filename as well, as (FILENAME)NODENAME.
 \\[universal-argument] \\[info]        Move to new Info file with completion.
 \\[Info-search]        Search through this Info file for specified regexp,
-       and select the node in which the next occurrence is found.
+         and select the node in which the next occurrence is found.
 \\[Info-next-reference]        Move cursor to next cross-reference or menu item.
 \\[Info-prev-reference]        Move cursor to previous cross-reference or menu item."
   (kill-all-local-variables)
@@ -2134,7 +2311,6 @@ Advanced commands:
   (setq mode-name "Info")
   (setq tab-width 8)
   (use-local-map Info-mode-map)
-  (make-local-hook 'activate-menubar-hook)
   (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
   (set-syntax-table text-mode-syntax-table)
   (setq local-abbrev-table text-mode-abbrev-table)
@@ -2149,32 +2325,34 @@ Advanced commands:
   (setq Info-tag-table-buffer nil)
   (make-local-variable 'Info-history)
   (make-local-variable 'Info-index-alternatives)
+  (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
   ;; This is for the sake of the invisible text we use handling titles.
   (make-local-variable 'line-move-ignore-invisible)
   (setq line-move-ignore-invisible t)
-  (add-hook (make-local-hook 'clone-buffer-hook) 'Info-clone-buffer-hook nil t)
+  (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
   (Info-set-mode-line)
   (run-hooks 'Info-mode-hook))
 
 (defun Info-clone-buffer-hook ()
   (when (bufferp Info-tag-table-buffer)
     (setq Info-tag-table-buffer
-         (with-current-buffer Info-tag-table-buffer (clone-buffer)))
-    (let ((m Info-tag-table-marker))
-      (when (and (markerp m) (marker-position m))
-       (setq Info-tag-table-marker
-             (with-current-buffer Info-tag-table-buffer
-               (copy-marker (marker-position m))))))))
-
-(defvar Info-edit-map nil
+         (with-current-buffer Info-tag-table-buffer (clone-buffer))))
+  (let ((m Info-tag-table-marker))
+    (when (markerp m)
+      (setq Info-tag-table-marker
+           (if (and (marker-position m) (bufferp Info-tag-table-buffer))
+               (with-current-buffer Info-tag-table-buffer
+                 (copy-marker (marker-position m)))
+             (make-marker))))))
+
+(defvar Info-edit-map (let ((map (make-sparse-keymap)))
+                       (set-keymap-parent map text-mode-map)
+                       (define-key map "\C-c\C-c" 'Info-cease-edit)
+                       map)
   "Local keymap used within `e' command of Info.")
-(if Info-edit-map
-    nil
-  (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
-  (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
 
 ;; Info-edit mode is suitable only for specially formatted data.
-(put 'info-edit-mode 'mode-class 'special)
+(put 'Info-edit-mode 'mode-class 'special)
 
 (defun Info-edit-mode ()
   "Major mode for editing the contents of an Info node.
@@ -2218,14 +2396,26 @@ Allowed only if variable `Info-enable-edit' is non-nil."
        (message "Tags may have changed.  Use Info-tagify if necessary")))
 \f
 (defvar Info-file-list-for-emacs
-  '("ediff" "forms" "gnus" ("mh" . "mh-e") "sc" "message"
-    ("dired" . "dired-x") ("c" . "ccmode") "viper" "vip"
+  '("ediff" "eudc" "forms" "gnus" "info" ("mh" . "mh-e")
+    "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
+    ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
+    ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
     ("skeleton" . "autotype") ("auto-insert" . "autotype")
     ("copyright" . "autotype") ("executable" . "autotype")
     ("time-stamp" . "autotype") ("quickurl" . "autotype")
     ("tempo" . "autotype") ("hippie-expand" . "autotype")
-    ("cvs" . "pcl-cvs")
-    "ebrowse" "cl" "idlwave" "reftex" "widget" "woman")
+    ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
+    ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
+    "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
+    ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
+    ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
+    ("rfc2045" . "emacs-mime")
+    ("rfc2231" . "emacs-mime")  ("rfc2047" . "emacs-mime")
+    ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
+    ("ietf-drums" . "emacs-mime")  ("quoted-printable" . "emacs-mime")
+    ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
+    ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
+    ("mml" . "emacs-mime"))
   "List of Info files that describe Emacs commands.
 An element can be a file name, or a list of the form (PREFIX . FILE)
 where PREFIX is a name prefix and FILE is the file to look in.
@@ -2287,7 +2477,7 @@ The locations are of the format used in `Info-history', i.e.
 ;;;###autoload
 (defun Info-goto-emacs-command-node (command)
   "Go to the Info node in the Emacs manual for command COMMAND.
-The command is found by looking up in Emacs manual's Command Index
+The command is found by looking up in Emacs manual's indices
 or in another manual found via COMMAND's `info-file' property or
 the variable `Info-file-list-for-emacs'."
   (interactive "CFind documentation for command: ")
@@ -2323,9 +2513,10 @@ the variable `Info-file-list-for-emacs'."
 
 ;;;###autoload
 (defun Info-goto-emacs-key-command-node (key)
-  "Go to the Info node in the Emacs manual the command bound to KEY, a string.
+  "Go to the node in the Emacs manual which describes the command bound to KEY.
+KEY is a string.
 Interactively, if the binding is `execute-extended-command', a command is read.
-The command is found by looking up in Emacs manual's Command Index
+The command is found by looking up in Emacs manual's indices
 or in another manual found via COMMAND's `info-file' property or
 the variable `Info-file-list-for-emacs'."
   (interactive "kFind documentation for key: ")
@@ -2340,91 +2531,144 @@ the variable `Info-file-list-for-emacs'."
           (Info-goto-emacs-command-node command)))))
 \f
 (defface Info-title-1-face
-  '((t (:height 1.2 :inherit Info-title-2-face)))
+  '((((type tty pc) (class color)) (:foreground "yellow" :weight bold))
+    (t (:height 1.2 :inherit Info-title-2-face)))
   "Face for Info titles at level 1."
   :group 'info)
 
 (defface Info-title-2-face
-  '((t (:height 1.2 :inherit Info-title-3-face)))
+  '((((type tty pc) (class color)) (:foreground "lightblue" :weight bold))
+    (t (:height 1.2 :inherit Info-title-3-face)))
   "Face for Info titles at level 2."
   :group 'info)
 
 (defface Info-title-3-face
-  '((t (:height 1.2 :weight bold :inherit variable-pitch)))
+  '((((type tty pc) (class color)) (:weight bold))
+    (t (:height 1.2 :inherit Info-title-4-face)))
   "Face for Info titles at level 3."
   :group 'info)
 
-(defun Info-fontify-node ()
+(defface Info-title-4-face
+  '((((type tty pc) (class color)) (:weight bold))
+    (t (:weight bold :inherit variable-pitch)))
+  "Face for Info titles at level 4."
+  :group 'info)
+
+(defface info-menu-header
+  '((((type tty pc))
+     :underline t
+     :weight bold)
+    (t
+     :inherit variable-pitch
+     :weight bold))
+  "Face for headers in Info menus."
+  :group 'info)
+
+(defun Info-fontify-menu-headers ()
+  "Add the face `info-menu-header' to any header before a menu entry."
   (save-excursion
-    (let ((buffer-read-only nil)
-         (case-fold-search t))
-      (goto-char (point-min))
-      (when (looking-at "^File: [^,: \t]+,?[ \t]+")
-       (goto-char (match-end 0))
-       (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
+    (goto-char (point-min))
+    (when (re-search-forward "\\* Menu:" nil t)
+      (put-text-property (match-beginning 0) (match-end 0)
+                        'face 'info-menu-header)
+      (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
+       (put-text-property (match-beginning 1) (match-end 1)
+                          'face 'info-menu-header)))))
+
+(defun Info-fontify-node ()
+  ;; Only fontify the node if it hasn't already been done.  [We pass in
+  ;; LIMIT arg to `next-property-change' because it seems to search past
+  ;; (point-max).]
+  (unless (and (< (next-property-change (point-min) nil (point-max))
+                 (point-max))
+              ;; But do put the text properties if the local-map property
+              ;; is inconsistent with Info-use-header-line's value.
+              (eq
+               (= (next-single-property-change
+                   (point-min) 'local-map nil (point-max))
+                  (point-max))
+               (null Info-use-header-line)))
+    (save-excursion
+      (let ((buffer-read-only nil)
+           (case-fold-search t))
+       (goto-char (point-min))
+       (when (looking-at "^File: [^,: \t]+,?[ \t]+")
          (goto-char (match-end 0))
-         (let* ((nbeg (match-beginning 2))
-                (nend (match-end 2))
-                (tbeg (match-beginning 1))
-                (tag (buffer-substring tbeg (match-end 1))))
-           (if (string-equal tag "Node")
-               (put-text-property nbeg nend 'face 'info-header-node)
-             (put-text-property nbeg nend 'face 'info-header-xref)
-             (put-text-property nbeg nend 'mouse-face 'highlight)
-             (put-text-property tbeg nend
-                                'help-echo
-                                (concat "Goto node "
-                                        (buffer-substring nbeg nend)))
-             (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
-                                          ("Next" . Info-next)
-                                          ("Up" . Info-up))))))
-               (when fun
-                 (let ((keymap (make-sparse-keymap)))
-                   (define-key keymap [header-line mouse-1] fun)
-                   (define-key keymap [header-line mouse-2] fun)
-                   (put-text-property tbeg nend 'local-map keymap))))
-             ))))
-      (goto-char (point-min))
-      (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
-                               nil t)
-       (let ((c (preceding-char))
-             face)
-         (cond ((= c ?*) (setq face 'Info-title-1-face))
-               ((= c ?=) (setq face 'Info-title-2-face))
-               (t        (setq face 'Info-title-3-face)))
-         (put-text-property (match-beginning 1) (match-end 1)
-                            'face face))
-       ;; This is a serious problem for trying to handle multiple
-       ;; frame types at once.  We want this text to be invisible
-       ;; on frames that can display the font above.
-       (if (memq (framep (selected-frame)) '(x pc w32))
-           (add-text-properties (match-end 1) (match-end 2)
+         (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
+           (goto-char (match-end 0))
+           (let* ((nbeg (match-beginning 2))
+                  (nend (match-end 2))
+                  (tbeg (match-beginning 1))
+                  (tag (buffer-substring tbeg (match-end 1))))
+             (if (string-equal tag "Node")
+                 (put-text-property nbeg nend 'face 'info-header-node)
+               (put-text-property nbeg nend 'face 'info-header-xref)
+               (put-text-property nbeg nend 'mouse-face 'highlight)
+               (put-text-property tbeg nend
+                                  'help-echo
+                                  (concat "Go to node "
+                                          (buffer-substring nbeg nend)))
+               ;; Don't bind mouse events on the header line if we
+               ;; aren't going to display the header line.
+               (when Info-use-header-line
+                 (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
+                                              ("Next" . Info-next)
+                                              ("Up" . Info-up))))))
+                   (when fun
+                     (let ((keymap (make-sparse-keymap)))
+                       (define-key keymap [header-line down-mouse-1] fun)
+                       (define-key keymap [header-line down-mouse-2] fun)
+                       (put-text-property tbeg nend 'local-map keymap)))))
+               (if (not Info-use-header-line)
+                   ;; In case they switched Info-use-header-line off
+                   ;; in the middle of an Info session, some text
+                   ;; properties may have been left lying around from
+                   ;; past visits of this node.  Remove them.
+                   (remove-text-properties tbeg nend '(local-map nil)))
+                 ))))
+       (goto-char (point-min))
+       (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
+                                 nil t)
+         (let ((c (preceding-char))
+               face)
+           (cond ((= c ?*) (setq face 'Info-title-1-face))
+                 ((= c ?=) (setq face 'Info-title-2-face))
+                 ((= c ?-) (setq face 'Info-title-3-face))
+                 (t        (setq face 'Info-title-4-face)))
+           (put-text-property (match-beginning 1) (match-end 1)
+                              'face face))
+         ;; This is a serious problem for trying to handle multiple
+         ;; frame types at once.  We want this text to be invisible
+         ;; on frames that can display the font above.
+         (when (memq (framep (selected-frame)) '(x pc w32 mac))
+           (add-text-properties (match-beginning 2) (1+ (match-end 2))
                                 '(invisible t intangible t))))
-      (goto-char (point-min))
-      (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
-       (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
-           nil
-         (put-text-property (match-beginning 1) (match-end 1)
-                            'face 'info-xref)
-         (put-text-property (match-beginning 1) (match-end 1)
-                            'mouse-face 'highlight)))
-      (goto-char (point-min))
-      (if (and (search-forward "\n* Menu:" nil t)
-              (not (string-match "\\<Index\\>" Info-current-node))
-              ;; Don't take time to annotate huge menus
-              (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
-         (let ((n 0))
-           (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t)
-             (setq n (1+ n))
-             (if (memq n '(5 9))       ; visual aids to help with 1-9 keys
-                 (put-text-property (match-beginning 0)
-                                    (1+ (match-beginning 0))
-                                    'face 'info-menu-5))
-             (put-text-property (match-beginning 1) (match-end 1)
-                                'face 'info-xref)
-             (put-text-property (match-beginning 1) (match-end 1)
-                                'mouse-face 'highlight))))
-      (set-buffer-modified-p nil))))
+       (goto-char (point-min))
+       (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
+         (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
+             nil
+           (add-text-properties (match-beginning 1) (match-end 1)
+                                '(face info-xref
+                                  mouse-face highlight
+                                  help-echo "mouse-2: go to this node"))))
+       (goto-char (point-min))
+       (if (and (search-forward "\n* Menu:" nil t)
+                (not (string-match "\\<Index\\>" Info-current-node))
+                ;; Don't take time to annotate huge menus
+                (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
+           (let ((n 0))
+             (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t)
+               (setq n (1+ n))
+               (if (zerop (% n 3)) ; visual aids to help with 1-9 keys
+                   (put-text-property (match-beginning 0)
+                                      (1+ (match-beginning 0))
+                                      'face 'info-menu-5))
+               (add-text-properties (match-beginning 1) (match-end 1)
+                                    '(face info-xref
+                                      mouse-face highlight
+                                      help-echo "mouse-2: go to this node")))))
+       (Info-fontify-menu-headers)
+       (set-buffer-modified-p nil)))))
 \f
 
 ;; When an Info buffer is killed, make sure the associated tags buffer
@@ -2490,6 +2734,8 @@ This will add a speedbar major display mode."
   (speedbar-change-initial-expansion-list "Info")
   )
 
+(eval-when-compile (defvar speedbar-attached-frame))
+
 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
   "Display an Info directory hierarchy in speedbar.
 DIRECTORY is the current directory in the attached frame.
@@ -2527,7 +2773,7 @@ specific node to expand."
        nil))))
 
 (defun Info-speedbar-goto-node (text node indent)
-  "When user clicks on TEXT, goto an info NODE.
+  "When user clicks on TEXT, go to an info NODE.
 The INDENT level is ignored."
   (select-frame speedbar-attached-frame)
   (let* ((buff (or (get-buffer "*info*")