(Man-notify-when-ready): Don't use window-system. If
[bpt/emacs.git] / lisp / info.el
index 10e52e2..78c2193 100644 (file)
@@ -109,8 +109,8 @@ It doesn't contain directory names or file name extensions added by Info.
 Can also be t when using `Info-on-current-buffer'.")
 
 (defvar Info-current-subfile nil
-  "Info subfile that is actually in the *info* buffer now,
-or nil if current info file is not split into subfiles.")
+  "Info subfile that is actually in the *info* buffer now.
+nil if current info file is not split into subfiles.")
 
 (defvar Info-current-node nil
   "Name of node that Info is now looking at, or nil.")
@@ -126,7 +126,7 @@ Marker points nowhere if file has no tag table.")
   "Cached completion list for current Info file.")
 
 (defvar Info-index-alternatives nil
-  "List of possible matches for last Info-index command.")
+  "List of possible matches for last `Info-index' command.")
 
 (defvar Info-standalone nil
   "Non-nil if Emacs was started solely as an Info browser.")
@@ -250,8 +250,8 @@ Do the right thing if the file has been compressed or zipped."
            (call-process-region (point-min) (point-max) decoder t t)))
       (insert-file-contents fullname visit))))
 \f
-;; Initialize Info-directory-list, if that hasn't been done yet.
 (defun info-initialize ()
+  "Initialize `Info-directory-list', if that hasn't been done yet."
   (unless Info-directory-list
     (let ((path (getenv "INFOPATH"))
          (source (expand-file-name "info/" source-directory))
@@ -291,7 +291,7 @@ Do the right thing if the file has been compressed or zipped."
                   (list (read-file-name "Info file name: " nil nil t))))
   (let (same-window-buffer-names)
     (info file)))
-  
+
 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
 
 ;;;###autoload
@@ -306,7 +306,7 @@ In interactive use, a prefix argument directs this command
 to read a file name from the minibuffer.
 
 The search path for Info files is in the variable `Info-directory-list'.
-The top-level Info directory is made by combining all the files named `dir' 
+The top-level Info directory is made by combining all the files named `dir'
 in all the directories in that path."
   (interactive (if current-prefix-arg
                   (list (read-file-name "Info file name: " nil nil t))))
@@ -354,18 +354,18 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
 ;; The return value is the value of point at the beginning of matching
 ;; REGERXP, 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?
+  (and (bobp)                          ; are we at beginning of buffer?
+       (looking-at "\^_")              ; does it begin with node delimiter?
        (let (beg)
         (forward-line 1)
         (setq beg (point))
-        (forward-line 1)       ; does the line after delimiter match REGEXP?
+        (forward-line 1)               ; does the line after delimiter match REGEXP?
         (re-search-backward regexp beg t))))
 
-;; Go to an info node specified as separate filename and nodename.
-;; no-going-back is non-nil if recovering from an error in this function;
-;; it says do not attempt further (recursive) error recovery.
 (defun Info-find-node (filename nodename &optional no-going-back)
+  "Go to an info node specified as separate FILENAME and NODENAME.
+NO-GOING-BACK is non-nil if recovering from an error in this function;
+it says do not attempt further (recursive) error recovery."
   (info-initialize)
   ;; Convert filename to lower case if not found as specified.
   ;; Expand it.
@@ -425,10 +425,81 @@ else defaults to `Top'."
             (completing-read "Node name: " (Info-build-node-completions)
                              nil t "Top")
           "Top")))
+  (info-initialize)
   (Info-mode)
   (set (make-local-variable 'Info-current-file) t)
   (Info-find-node-2 nil nodename))
 
+(defun Info-find-in-tag-table-1 (marker regexp case-fold)
+  "Find a node in a tag table.
+MARKER specifies the buffer and position to start searching at.
+REGEXP is a regular expression matching nodes or references.  Its first
+group should match `Node:' or `Ref:'.
+CASE-FOLD t means search for a case-insensitive match.
+If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
+FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
+where the match was found, and MODE is `major-mode' of the buffer in
+which the match was found."
+  (let ((case-fold-search case-fold)
+       found-mode guesspos found-anchor)
+    (save-excursion
+      (set-buffer (marker-buffer marker))
+      (goto-char marker)
+    
+      ;; Search tag table
+      (beginning-of-line)
+      (when (re-search-forward regexp nil t)
+       (list (string-equal "Ref:" (match-string 1))
+             (1+ (read (current-buffer)))
+             major-mode)))))
+
+(defun Info-find-in-tag-table (marker regexp)
+  "Find a node in a tag table.
+MARKER specifies the buffer and position to start searching at.
+REGEXP is a regular expression matching nodes or references.  Its first
+group should match `Node:' or `Ref:'.
+If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
+FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
+where the match was found, and MODE is `major-mode' of the buffer in
+which the match was found.
+This function tries to find a case-sensitive match first, then a
+case-insensitive match is tried."
+  (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
+    (when (null (car result))
+      (setq result (Info-find-in-tag-table-1 marker regexp t)))
+    result))
+
+(defun Info-find-node-in-buffer-1 (regexp case-fold)
+  "Find a node or anchor in the current buffer.
+REGEXP is a regular expression matching nodes or references.  Its first
+group should match `Node:' or `Ref:'.
+CASE-FOLD t means search for a case-insensitive match.
+Value is the position at which a match was found, or nil if not found."
+  (let ((case-fold-search case-fold)
+       found)
+    (save-excursion
+      (when (Info-node-at-bob-matching regexp)
+       (setq found (point)))
+      (while (and (not found)
+                 (search-forward "\n\^_" nil t))
+       (forward-line 1)
+       (let ((beg (point)))
+         (forward-line 1)
+         (when (re-search-backward regexp beg t)
+           (beginning-of-line)
+           (setq found (point)))))
+      found)))
+                 
+(defun Info-find-node-in-buffer (regexp)
+  "Find a node or anchor in the current buffer.
+REGEXP is a regular expression matching nodes or references.  Its first
+group should match `Node:' or `Ref:'.
+Value is the position at which a match was found, or nil if not found.
+This function looks for a case-sensitive match first.  If none is found,
+a case-insensitive match is tried."
+  (or (Info-find-node-in-buffer-1 regexp nil)
+      (Info-find-node-in-buffer-1 regexp t)))
+  
 (defun Info-find-node-2 (filename nodename &optional no-going-back)
   (buffer-disable-undo (current-buffer))
   (or (eq major-mode 'Info-mode)
@@ -436,7 +507,6 @@ else defaults to `Top'."
   (widen)
   (setq Info-current-node nil)
   (unwind-protect
-      ;; Bind case-fold-search in case the user sets it to nil.
       (let ((case-fold-search t)
            anchorpos)
         ;; Switch files if necessary
@@ -504,112 +574,52 @@ else defaults to `Top'."
 
           ;; Search file for a suitable node.
          (let ((guesspos (point-min))
-               (regexp
-                (concat "\\(Node:\\|Ref:\\) *\\("
-                        (regexp-quote nodename)
-                        "\\) *[,\t\n\177]"))
+               (regexp (concat "\\(Node:\\|Ref:\\) *\\("
+                               (regexp-quote nodename)
+                               "\\) *[,\t\n\177]"))
                (nodepos nil))
 
-            ;; First, search a tag table, if any
-            (if (marker-position Info-tag-table-marker)
-               (let ((found-in-tag-table t)
-                     found-anchor
-                     found-mode
-                     (m Info-tag-table-marker))
-                  (save-excursion
-                    (set-buffer (marker-buffer m))
-                    (goto-char m)
-                    (beginning-of-line) ; so re-search will work.
-
-                    ;; Search tag table
-                   (catch 'foo
-                     (while (re-search-forward regexp nil t)
-                       (setq found-anchor
-                             (string-equal "Ref:" (match-string 1)))
-                       (or nodepos (setq nodepos (point))
-                       (if (string-equal (match-string 2) nodename)
-                           (throw 'foo t))))
-                     (if nodepos
-                         (goto-char nodepos)
-                       (setq found-in-tag-table nil)))
-                    (if found-in-tag-table
-                        (setq guesspos (1+ (read (current-buffer)))))
-                    (setq found-mode major-mode))
-
-                  ;; Indirect file among split files
-                  (if found-in-tag-table
-                      (progn
-                        ;; If this is an indirect file, determine
-                        ;; which file really holds this node and
-                        ;; read it in.
-                        (if (not (eq found-mode 'Info-mode))
-                            ;; Note that the current buffer must be
-                            ;; the *info* buffer on entry to
-                            ;; Info-read-subfile.  Thus the hackery
-                            ;; above.
-                            (setq guesspos (Info-read-subfile guesspos)))))
-
-                  ;; Handle anchor
-                  (if found-anchor
+           (catch 'foo
+             
+             ;; First, search a tag table, if any
+             (when (marker-position Info-tag-table-marker)
+               (let* ((m Info-tag-table-marker)
+                      (found (Info-find-in-tag-table m regexp)))
+                 
+                 (when found
+                   ;; FOUND is (ANCHOR POS MODE).
+                   (setq guesspos (nth 1 found))
+                   
+                   ;; If this is an indirect file, determine which
+                   ;; file really holds this node and read it in.
+                   (unless (eq (nth 2 found) 'Info-mode)
+                     ;; Note that the current buffer must be the
+                     ;; *info* buffer on entry to
+                     ;; Info-read-subfile.  Thus the hackery above.
+                     (setq guesspos (Info-read-subfile guesspos)))
+
+                   ;; Handle anchor
+                   (when (nth 0 found)
                      (goto-char (setq anchorpos guesspos))
-
-                    ;; Else we may have a node, which we search for:
-                   (let ((guesschar
-                          (or (byte-to-position guesspos)
-                              (if (< (position-bytes (point-max)) guesspos)
-                                  (point-max)
-                                (point-min)))))
-                     (goto-char (max (point-min)
-                                     (- guesschar 1000))))
-                    ;; Now search from our advised position
-                    ;; (or from beg of buffer)
-                    ;; to find the actual node.
-                   ;; First, check whether the node is right
-                   ;; where we are, in case the buffer begins
-                   ;; with a node.
-                   (setq nodepos nil)
-                   (or (Info-node-at-bob-matching regexp)
-                       (catch 'foo
-                         (while (search-forward "\n\^_" nil t)
-                           (forward-line 1)
-                           (let ((beg (point)))
-                             (forward-line 1)
-                             (if (re-search-backward regexp beg t)
-                                 (if (string-equal (match-string 2) nodename)
-                                     (progn
-                                       (beginning-of-line)
-                                       (throw 'foo t))
-                                   (or nodepos
-                                     (setq nodepos (point)))))))
-                         (if nodepos
-                             (progn
-                               (goto-char nodepos)
-                               (beginning-of-line))
-                           (error
-                            "No such anchor in tag table or node in tag table or file: %s"
-                            nodename))))))
-             (goto-char (max (point-min) (- guesspos 1000)))
-             ;; Now search from our advised position (or from beg of buffer)
-             ;; to find the actual node.
-             ;; First, check whether the node is right where we are, in case
-             ;; the buffer begins with a node.
-             (setq nodepos nil)
-             (or (Info-node-at-bob-matching regexp)
-                 (catch 'foo
-                   (while (search-forward "\n\^_" nil t)
-                     (forward-line 1)
-                     (let ((beg (point)))
-                       (forward-line 1)
-                       (if (re-search-backward regexp beg t)
-                           (if (string-equal (match-string 2) nodename)
-                               (throw 'foo t)
-                             (or nodepos
-                                 (setq nodepos (point)))))))
-                   (if nodepos
-                       (goto-char nodepos)
-                     (error "No such node: %s" nodename))))))
-          (Info-select-node)
-         (goto-char (or anchorpos (point-min)))))
+                     (throw 'foo t)))))
+
+             ;; Else we may have a node, which we search for:
+             (goto-char (max (point-min)
+                             (- (byte-to-position guesspos) 1000)))
+             
+             ;; Now search from our advised position (or from beg of
+             ;; buffer) to find the actual node.  First, check
+             ;; whether the node is right where we are, in case the
+             ;; buffer begins with a node.
+             (let ((pos (Info-find-node-in-buffer regexp)))
+               (when pos
+                 (goto-char pos)
+                 (throw 'foo t))
+               (error "No such anchor in tag table or node in tag table or file: %s"
+                      nodename)))
+
+           (Info-select-node)
+           (goto-char (or anchorpos (point-min))))))
     ;; If we did not finish finding the specified node,
     ;; go back to the previous one.
     (or Info-current-node no-going-back (null Info-history)
@@ -641,15 +651,15 @@ else defaults to `Top'."
           ;; Verify that none of the files we used has changed
           ;; since we used it.
           (eval (cons 'and
-                      (mapcar '(lambda (elt)
-                                 (let ((curr (file-attributes 
-                                              ;; Handle symlinks
-                                              (file-truename (car elt)))))
-                                   
-                                   ;; Don't compare the access time.
-                                   (if curr (setcar (nthcdr 4 curr) 0))
-                                   (setcar (nthcdr 4 (cdr elt)) 0)
-                                   (equal (cdr elt) curr)))
+                      (mapcar (lambda (elt)
+                                (let ((curr (file-attributes
+                                             ;; Handle symlinks
+                                             (file-truename (car elt)))))
+
+                                  ;; Don't compare the access time.
+                                  (if curr (setcar (nthcdr 4 curr) 0))
+                                  (setcar (nthcdr 4 (cdr elt)) 0)
+                                  (equal (cdr elt) curr)))
                               Info-dir-file-attributes))))
       (progn
        (insert Info-dir-contents)
@@ -703,7 +713,7 @@ else defaults to `Top'."
          (or (cdr dirs) (setq Info-dir-contents-directory
                               (file-name-as-directory (car dirs))))
          (setq dirs (cdr dirs))))
-      
+
       (or buffers
          (error "Can't find the Info directory node"))
       ;; Distinguish the dir file that comes with Emacs from all the
@@ -721,6 +731,8 @@ else defaults to `Top'."
       ;; Look at each of the other buffers one by one.
       (while others
        (let ((other (car others))
+             ;; Bind this in case the user sets it to nil.
+             (case-fold-search t)
              this-buffer-nodes)
          ;; In each, find all the menus.
          (save-excursion
@@ -748,7 +760,8 @@ else defaults to `Top'."
              (message "No `top' node in %s" Info-dir-file-name))))
        (setq others (cdr others)))
       ;; Add to the main menu a menu item for each other node.
-      (re-search-forward "^\\* Menu:")
+      (let ((case-fold-search t)
+           (re-search-forward "^\\* Menu:")))
       (forward-line 1)
       (let ((menu-items '("top"))
            (nodes nodes)
@@ -769,7 +782,8 @@ else defaults to `Top'."
       ;; Now take each node of each of the other buffers
       ;; and merge it into the main buffer.
       (while nodes
-       (let ((nodename (car (car nodes))))
+       (let ((case-fold-search t)
+             (nodename (car (car nodes))))
          (goto-char (point-min))
          ;; Find the like-named node in the main buffer.
          (if (re-search-forward (concat "^\^_.*\n.*Node: "
@@ -847,52 +861,50 @@ else defaults to `Top'."
     (if (numberp nodepos)
        (+ (- nodepos lastfilepos) (point)))))
 
-;; Select the info node that point is in.
 (defun Info-select-node ()
-  ;; Bind this in case the user sets it to nil.
+"Select the info node that point is in.
+Bind this in case the user sets it to nil."
   (let ((case-fold-search t))
     (save-excursion
-     ;; Find beginning of node.
-     (if (search-backward "\n\^_" nil 'move)
-        (forward-line 2)
-       (if (looking-at "\^_")
-          (forward-line 1)
-        (signal 'search-failed (list "\n\^_"))))
-     ;; Get nodename spelled as it is in the node.
-     (re-search-forward "Node:[ \t]*")
-     (setq Info-current-node
-          (buffer-substring-no-properties (point)
-                                          (progn
-                                           (skip-chars-forward "^,\t\n")
-                                           (point))))
-     (Info-set-mode-line)
-     ;; Find the end of it, and narrow.
-     (beginning-of-line)
-     (let (active-expression)
-       (narrow-to-region (point)
-                        (if (re-search-forward "\n[\^_\f]" nil t)
-                            (prog1
-                             (1- (point))
-                             (if (looking-at "[\n\^_\f]*execute: ")
-                                 (progn
-                                   (goto-char (match-end 0))
-                                   (setq active-expression
-                                         (read (current-buffer))))))
-                          (point-max)))
-       (if Info-enable-active-nodes (eval active-expression))
-       (if Info-fontify (Info-fontify-node))
-       (run-hooks 'Info-selection-hook)))))
+      ;; Find beginning of node.
+      (if (search-backward "\n\^_" nil 'move)
+         (forward-line 2)
+       (if (looking-at "\^_")
+           (forward-line 1)
+         (signal 'search-failed (list "\n\^_"))))
+      ;; Get nodename spelled as it is in the node.
+      (re-search-forward "Node:[ \t]*")
+      (setq Info-current-node
+           (buffer-substring-no-properties (point)
+                                           (progn
+                                             (skip-chars-forward "^,\t\n")
+                                             (point))))
+      (Info-set-mode-line)
+      ;; Find the end of it, and narrow.
+      (beginning-of-line)
+      (let (active-expression)
+       (narrow-to-region (point)
+                         (if (re-search-forward "\n[\^_\f]" nil t)
+                             (prog1
+                                 (1- (point))
+                               (if (looking-at "[\n\^_\f]*execute: ")
+                                   (progn
+                                     (goto-char (match-end 0))
+                                     (setq active-expression
+                                           (read (current-buffer))))))
+                           (point-max)))
+       (if Info-enable-active-nodes (eval active-expression))
+       (if Info-fontify (Info-fontify-node))
+       (run-hooks 'Info-selection-hook)))))
 
 (defun Info-set-mode-line ()
   (setq mode-line-buffer-identification
        (concat
-        "  Info:  ("
-        (if Info-current-file
-            (file-name-nondirectory (if (stringp Info-current-file)
-                                        Info-current-file
-                                      (or buffer-file-name "")))
-          "")
-        ")"
+        "  *Info* ("
+        (file-name-nondirectory (if (stringp Info-current-file)
+                                    Info-current-file
+                                  (or buffer-file-name "")))
+        ") "
         (or Info-current-node ""))))
 \f
 ;; Go to an info node specified with a filename-and-nodename string
@@ -905,8 +917,8 @@ 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))
   (info-initialize)
   (if fork
-    (set-buffer
-     (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
+      (set-buffer
+       (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
   (let (filename)
     (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
                  nodename)
@@ -964,9 +976,9 @@ If FORK is a string, it is the name to use for the new buffer."
                  (set-buffer (marker-buffer marker))
                  (widen)
                  (goto-char marker)
-                 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
+                 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t)
                    (setq compl
-                         (cons (list (match-string-no-properties 1))
+                         (cons (list (match-string-no-properties 2))
                                compl))))
              (widen)
              (goto-char (point-min))
@@ -979,7 +991,7 @@ If FORK is a string, it is the name to use for the new buffer."
                (let ((beg (point)))
                  (forward-line 1)
                  (if (re-search-backward node-regexp beg t)
-                     (setq compl 
+                     (setq compl
                            (cons (list (match-string-no-properties 1))
                                  compl))))))))
        (setq compl (cons '("*") compl))
@@ -1021,7 +1033,7 @@ If FORK is a string, it is the name to use for the new buffer."
            (condition-case err
                (progn (re-search-forward regexp) (setq found (point)))
              (search-failed nil)))))
-      (if (not found) ;can only happen in subfile case -- else would have erred
+      (if (not found)                  ;can only happen in subfile case -- else would have erred
          (unwind-protect
              (let ((list ()))
                (save-excursion
@@ -1060,20 +1072,20 @@ If FORK is a string, it is the name to use for the new buffer."
                       (goto-char opoint)
                       (Info-select-node)
                       (set-window-start (selected-window) ostart)))))
-    (widen)
-    (goto-char found)
-    (Info-select-node)
-    ;; Use string-equal, not equal, to ignore text props.
-    (or (and (string-equal onode Info-current-node)
-            (equal ofile Info-current-file))
-       (setq Info-history (cons (list ofile onode opoint)
-                                Info-history))))))
+      (widen)
+      (goto-char found)
+      (Info-select-node)
+      ;; Use string-equal, not equal, to ignore text props.
+      (or (and (string-equal onode Info-current-node)
+              (equal ofile Info-current-file))
+         (setq Info-history (cons (list ofile onode opoint)
+                                  Info-history))))))
 \f
-;; Extract the value of the node-pointer named NAME.
-;; If there is none, use ERRORNAME in the error message; 
-;; if ERRORNAME is nil, just return nil.
 (defun Info-extract-pointer (name &optional errorname)
-  ;; Bind this in case the user sets it to nil.
+  "Extract the value of the node-pointer named NAME.
+If there is none, use ERRORNAME in the error message;
+if ERRORNAME is nil, just return nil.
+Bind this in case the user sets it to nil."
   (let ((case-fold-search t))
     (save-excursion
       (goto-char (point-min))
@@ -1086,10 +1098,10 @@ If FORK is a string, it is the name to use for the new buffer."
            nil
          (error "Node has no %s" (capitalize (or errorname name))))))))
 
-;; Return the node name in the buffer following point.
-;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
-;; saying which chars may appear in the node name.
 (defun Info-following-node-name (&optional allowedchars)
+  "Return the node name in the buffer following point.
+ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
+saying which chars may appear in the node name."
   (skip-chars-forward " \t")
   (buffer-substring-no-properties
    (point)
@@ -1143,8 +1155,8 @@ If SAME-FILE is non-nil, do not move to a different Info file."
   (Info-find-node "dir" "top"))
 \f
 (defun Info-follow-reference (footnotename)
-  "Follow cross reference named NAME to the node it refers to.
-NAME may be an abbreviation of the reference name."
+  "Follow cross reference named FOOTNOTENAME to the node it refers to.
+FOOTNOTENAME may be an abbreviation of the reference name."
   (interactive
    (let ((completion-ignore-case t)
         (case-fold-search t)
@@ -1255,7 +1267,8 @@ NAME may be an abbreviation of the reference name."
 (defvar Info-complete-menu-buffer)
 
 (defun Info-complete-menu-item (string predicate action)
-  (let ((case-fold-search t))
+  (let ((completion-ignore-case t)
+       (case-fold-search t))
     (cond ((eq action nil)
           (let (completions
                 (pattern (concat "\n\\* +\\("
@@ -1306,7 +1319,8 @@ Completion is allowed, and the menu item point is on is the default."
         (default nil)
         (p (point))
         beg
-        (last nil))
+        (last nil)
+        (case-fold-search t))
      (save-excursion
        (goto-char (point-min))
        (if (not (search-forward "\n* menu:" nil t))
@@ -1325,7 +1339,7 @@ Completion is allowed, and the menu item point is on is the default."
                      (completing-read (if default
                                           (format "Menu item (default %s): "
                                                   default)
-                                          "Menu item: ")
+                                        "Menu item: ")
                                       'Info-complete-menu-item nil t)))
         ;; we rely on the fact that completing-read accepts an input
         ;; of "" even when the require-match argument is true and ""
@@ -1333,40 +1347,42 @@ Completion is allowed, and the menu item point is on is the default."
         (if (string= item "")
             (if default
                 (setq item default)
-                ;; ask again
-                (setq item nil))))
+              ;; ask again
+              (setq item nil))))
        (list item current-prefix-arg))))
   ;; there is a problem here in that if several menu items have the same
   ;; name you can only go to the node of the first with this command.
   (Info-goto-node (Info-extract-menu-item menu-item) (if fork menu-item)))
-  
+
 (defun Info-extract-menu-item (menu-item)
   (setq menu-item (regexp-quote menu-item))
   (let ((case-fold-search t))
     (save-excursion
-      (goto-char (point-min))
-      (or (search-forward "\n* menu:" nil t)
-         (error "No menu in this node"))
-      (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
-         (re-search-forward (concat "\n\\* +" menu-item) nil t)
-         (error "No such item in menu"))
-      (beginning-of-line)
-      (forward-char 2)
-      (Info-extract-menu-node-name))))
+      (let ((case-fold-search t))
+       (goto-char (point-min))
+       (or (search-forward "\n* menu:" nil t)
+           (error "No menu in this node"))
+       (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
+           (re-search-forward (concat "\n\\* +" menu-item) nil t)
+           (error "No such item in menu"))
+       (beginning-of-line)
+       (forward-char 2)
+       (Info-extract-menu-node-name)))))
 
 ;; If COUNT is nil, use the last item in the menu.
 (defun Info-extract-menu-counting (count)
   (let ((case-fold-search t))
     (save-excursion
-      (goto-char (point-min))
-      (or (search-forward "\n* menu:" nil t)
-         (error "No menu in this node"))
-      (if count
-         (or (search-forward "\n* " nil t count)
-             (error "Too few items in menu"))
-       (while (search-forward "\n* " nil t)
-         nil))
-      (Info-extract-menu-node-name))))
+      (let ((case-fold-search t))
+       (goto-char (point-min))
+       (or (search-forward "\n* menu:" nil t)
+           (error "No menu in this node"))
+       (if count
+           (or (search-forward "\n* " nil t count)
+               (error "Too few items in menu"))
+         (while (search-forward "\n* " nil t)
+           nil))
+       (Info-extract-menu-node-name)))))
 
 (defun Info-nth-menu-item ()
   "Go to the node of the Nth menu item.
@@ -1385,11 +1401,12 @@ N is the digit argument used to invoke this command."
   "Go to the final node in this file."
   (interactive)
   (Info-goto-node "Top")
-  (let (Info-history)
+  (let ((Info-history nil)
+       (case-fold-search t))
     ;; Go to the last node in the menu of Top.
     (Info-goto-node (Info-extract-menu-counting nil))
     ;; If the last node in the menu is not last in pointer structure,
-    ;; move forward until we can't go any farther. 
+    ;; move forward until we can't go any farther.
     (while (Info-forward-node t t) nil)
     ;; Then keep moving down to last subnode, unless we reach an index.
     (while (and (not (string-match "\\<index\\>" Info-current-node))
@@ -1401,36 +1418,38 @@ N is the digit argument used to invoke this command."
   (interactive)
   (goto-char (point-min))
   (forward-line 1)
-  ;; three possibilities, in order of priority:
-  ;;     1. next node is in a menu in this node (but not in an index)
-  ;;     2. next node is next at same level
-  ;;     3. next node is up and next
-  (cond ((and (not not-down)
-              (save-excursion (search-forward "\n* menu:" nil t))
-             (not (string-match "\\<index\\>" Info-current-node)))
-        (Info-goto-node (Info-extract-menu-counting 1))
-         t)
-        ((save-excursion (search-backward "next:" nil t))
-         (Info-next)
-         t)
-        ((and (save-excursion (search-backward "up:" nil t))
-             ;; Use string-equal, not equal, to ignore text props.
-             (not (string-equal (downcase (Info-extract-pointer "up"))
-                                "top")))
-         (let ((old-node Info-current-node))
-           (Info-up)
-           (let (Info-history success)
-             (unwind-protect
-                 (setq success (Info-forward-node t no-error))
-               (or success (Info-goto-node old-node))))))
-        (no-error nil)
-        (t (error "No pointer forward from this node"))))
+  (let ((case-fold-search t))
+    ;; three possibilities, in order of priority:
+    ;;     1. next node is in a menu in this node (but not in an index)
+    ;;     2. next node is next at same level
+    ;;     3. next node is up and next
+    (cond ((and (not not-down)
+               (save-excursion (search-forward "\n* menu:" nil t))
+               (not (string-match "\\<index\\>" Info-current-node)))
+          (Info-goto-node (Info-extract-menu-counting 1))
+          t)
+         ((save-excursion (search-backward "next:" nil t))
+          (Info-next)
+          t)
+         ((and (save-excursion (search-backward "up:" nil t))
+               ;; Use string-equal, not equal, to ignore text props.
+               (not (string-equal (downcase (Info-extract-pointer "up"))
+                                  "top")))
+          (let ((old-node Info-current-node))
+            (Info-up)
+            (let (Info-history success)
+              (unwind-protect
+                  (setq success (Info-forward-node t no-error))
+                (or success (Info-goto-node old-node))))))
+         (no-error nil)
+         (t (error "No pointer forward from this node")))))
 
 (defun Info-backward-node ()
   "Go backward one node, considering all nodes as forming one sequence."
   (interactive)
   (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
-       (upnode (Info-extract-pointer "up" t)))
+       (upnode (Info-extract-pointer "up" t))
+       (case-fold-search t))
     (cond ((and upnode (string-match "(" upnode))
           (error "First node in file"))
          ((and upnode (or (null prevnode)
@@ -1459,12 +1478,14 @@ N is the digit argument used to invoke this command."
 
 (defun Info-next-menu-item ()
   (interactive)
-  (let ((node
-        (save-excursion
-          (forward-line -1)
-          (search-forward "\n* menu:" nil t)
-          (and (search-forward "\n* " nil t)
-               (Info-extract-menu-node-name)))))
+  ;; Bind this in case the user sets it to nil.
+  (let* ((case-fold-search t)
+        (node
+         (save-excursion
+           (forward-line -1)
+           (search-forward "\n* menu:" nil t)
+           (and (search-forward "\n* " nil t)
+                (Info-extract-menu-node-name)))))
     (if node (Info-goto-node node)
       (error "No more items in menu"))))
 
@@ -1472,9 +1493,11 @@ N is the digit argument used to invoke this command."
   (interactive)
   (save-excursion
     (forward-line 1)
-    (let ((beg (save-excursion
-                (and (search-backward "\n* menu:" nil t)
-                     (point)))))
+    ;; Bind this in case the user sets it to nil.
+    (let* ((case-fold-search t)
+          (beg (save-excursion
+                 (and (search-backward "\n* menu:" nil t)
+                      (point)))))
       (or (and beg (search-backward "\n* " beg t))
          (error "No previous items in menu")))
     (Info-goto-node (save-excursion
@@ -1526,8 +1549,9 @@ N is the digit argument used to invoke this command."
         (recenter -1))
        ((Info-no-error (Info-up t))
         (goto-char (point-min))
-        (or (search-forward "\n* Menu:" nil t)
-            (goto-char (point-max))))
+        (let ((case-fold-search t))
+          (or (search-forward "\n* Menu:" nil t)
+              (goto-char (point-max)))))
        (t (error "No previous nodes"))))
 
 (defun Info-scroll-up ()
@@ -1545,11 +1569,12 @@ normally result from this command, but can happen in other ways.)"
   (if (or (< (window-start) (point-min))
          (> (window-start) (point-max)))
       (set-window-start (selected-window) (point)))
-  (let ((virtual-end (save-excursion
-                      (goto-char (point-min))
-                      (if (search-forward "\n* Menu:" nil t)
-                          (point)
-                        (point-max)))))
+  (let* ((case-fold-search t)
+        (virtual-end (save-excursion
+                       (goto-char (point-min))
+                       (if (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)
@@ -1564,7 +1589,8 @@ previous node or back up to the parent node."
   (if (or (< (window-start) (point-min))
          (> (window-start) (point-max)))
       (set-window-start (selected-window) (point)))
-  (let* ((current-point (point))
+  (let* ((case-fold-search t)
+        (current-point (point))
         (virtual-end (save-excursion
                        (beginning-of-line)
                        (setq current-point (point))
@@ -1616,7 +1642,7 @@ previous node or back up to the parent node."
          (Info-prev-reference t)))))
 
 (defun Info-index (topic)
-  "Look up a string in the index for this file.
+  "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
 name contains the word \"Index\", plus any immediately following
 nodes whose names also contain the word \"Index\".
@@ -1689,7 +1715,7 @@ Give a blank topic name to go to the Index node itself."
   (Info-goto-node (nth 1 (car Info-index-alternatives)))
   (if (> (nth 3 (car Info-index-alternatives)) 0)
       (forward-line (nth 3 (car Info-index-alternatives)))
-    (forward-line 3)  ; don't search in headers
+    (forward-line 3)                   ; don't search in headers
     (let ((name (car (car Info-index-alternatives))))
       (Info-find-index-name name)))
   (message "Found `%s' in %s.  %s"
@@ -1749,15 +1775,15 @@ Give a blank topic name to go to the Index node itself."
     (bury-buffer "*Help*")))
 \f
 (defun Info-get-token (pos start all &optional errorstring)
-  "Return the token around POS,
+  "Return the token around POS.
 POS must be somewhere inside the token
 START is a regular expression which will match the
     beginning of the tokens delimited string
 ALL is a regular expression with a single
     parenthesized subpattern which is the token to be
-    returned. E.g. '{\(.*\)}' would return any string
+    returned.  E.g. '{\(.*\)}' would return any string
     enclosed in braces around POS.
-SIG optional fourth argument, controls action on no match
+ERRORSTRING optional fourth argument, controls action on no match
     nil: return nil
     t: beep
     a string: signal an error, using that string."
@@ -1886,49 +1912,49 @@ If no reference to follow, moves to the next node, or up if none."
   )
 
 (defun Info-check-pointer (item)
-  ;; Non-nil if ITEM is present in this node.
+  "Non-nil if ITEM is present in this node."
   (condition-case nil
       (Info-extract-pointer item)
     (error nil)))
 
 (easy-menu-define Info-mode-menu Info-mode-map
-  "Menu for info files."
-  '("Info"
-    ["Up" Info-up (Info-check-pointer "up")
-     :help "Go up in the Info tree"]
-    ["Next" Info-next (Info-check-pointer "next")
-     :help "Go to the next node"]
-    ["Previous" Info-prev (Info-check-pointer "prev[ious]*")
-     :help "Go to the previous node"]
-    ["Backward" Info-backward-node t
-     :help "Go backward one node, considering all as a sequence"]
-    ["Forward" Info-forward-node t
-     :help "Go forward one node, considering all as a sequence"]
-    ["Top" Info-top-node t
-     :help "Go to top node of file"]
-    ["Final node" Info-final-node t
-     :help "Go to final node in this file"]
-    ("Menu item" ["You should never see this" report-emacs-bug t])
-    ("Reference" ["You should never see this" report-emacs-bug t])
-    ["Search..." Info-search t
-     :help "Search for regular expression in this Info file"]
-    ["Goto node..." Info-goto-node t
-     :help "Go to a named node]"]
-    ["Last" Info-last Info-history
-     :help "Go to the last node you were at"]
-    ("Index..."
-     ["Lookup a String" Info-index t
-      :help "Look for a string in the index items"]
-     ["Next Matching Item" Info-index-next t
-      :help "Look for another occurrence of previous item"])
-    ["Exit" Info-exit t]))
+                 "Menu for info files."
+                 '("Info"
+                   ["Up" Info-up (Info-check-pointer "up")
+                    :help "Go up in the Info tree"]
+                   ["Next" Info-next (Info-check-pointer "next")
+                    :help "Go to the next node"]
+                   ["Previous" Info-prev (Info-check-pointer "prev[ious]*")
+                    :help "Go to the previous node"]
+                   ["Backward" Info-backward-node t
+                    :help "Go backward one node, considering all as a sequence"]
+                   ["Forward" Info-forward-node t
+                    :help "Go forward one node, considering all as a sequence"]
+                   ["Top" Info-top-node t
+                    :help "Go to top node of file"]
+                   ["Final node" Info-final-node t
+                    :help "Go to final node in this file"]
+                   ("Menu item" ["You should never see this" report-emacs-bug t])
+                   ("Reference" ["You should never see this" report-emacs-bug t])
+                   ["Search..." Info-search t
+                    :help "Search for regular expression in this Info file"]
+                   ["Goto node..." Info-goto-node t
+                    :help "Go to a named node]"]
+                   ["Last" Info-last Info-history
+                    :help "Go to the last node you were at"]
+                   ("Index..."
+                    ["Lookup a String" Info-index t
+                     :help "Look for a string in the index items"]
+                    ["Next Matching Item" Info-index-next t
+                     :help "Look for another occurrence of previous item"])
+                   ["Exit" Info-exit t]))
 
 (defvar Info-menu-last-node nil)
 ;; Last node the menu was created for.
 ;; Value is a list, (FILE-NAME NODE-NAME).
 
 (defun Info-menu-update ()
-  ;; Update the Info menu for the current node.
+  "Update the Info menu for the current node."
   (condition-case nil
       (if (or (not (eq major-mode 'Info-mode))
              (equal (list Info-current-file Info-current-node)
@@ -1940,13 +1966,13 @@ If no reference to follow, moves to the next node, or up if none."
                                    (Info-complete-menu-item
                                     "" (lambda (e) t) t)
                                  (error nil))))
-              entries current 
+              entries current
               (number 0))
          (while (and items (< number 9))
            (setq current (car items)
                  items (cdr items)
                  number (1+ number))
-           (setq entries (cons `[,current 
+           (setq entries (cons `[,current
                                  (Info-menu ,current)
                                  :keys ,(format "%d" number)]
                                entries)))
@@ -1957,7 +1983,7 @@ If no reference to follow, moves to the next node, or up if none."
          (easy-menu-change '("Info") "Menu item" (nreverse entries)))
        ;; Update reference menu.  Code stolen from `Info-follow-reference'.
        (let ((items nil)
-             str i entries current 
+             str i entries current
              (number 0)
              (case-fold-search t))
          (save-excursion
@@ -1977,7 +2003,7 @@ If no reference to follow, moves to the next node, or up if none."
            (setq current (car items)
                  items (cdr items)
                  number (1+ number))
-           (setq entries (cons `[,current 
+           (setq entries (cons `[,current
                                  (Info-follow-reference ,current)
                                  t]
                                entries)))
@@ -1997,12 +2023,12 @@ If no reference to follow, moves to the next node, or up if none."
 (put 'info-mode 'mode-class 'special)
 
 (defun Info-mode ()
-  "\\<Info-mode-map>
-Info mode provides commands for browsing through the Info documentation tree.
+  "Info mode provides commands for browsing through the Info documentation tree.
 Documentation in Info is divided into \"nodes\", each of which discusses
 one topic and contains references to other nodes which discuss related
 topics.  Info has commands to follow the references and show you other nodes.
 
+\\<Info-mode-map>\
 \\[Info-help]  Invoke the Info tutorial.
 \\[Info-exit]  Quit Info: reselect previously selected buffer.
 
@@ -2035,7 +2061,7 @@ When after all menu items (or if their 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.
-\\[beginning-of-buffer]        Go to beginning of node.  
+\\[beginning-of-buffer]        Go to beginning of node.
 
 Advanced commands:
 \\[Info-exit]  Quit Info: reselect previously selected buffer.
@@ -2118,7 +2144,7 @@ Allowed only if variable `Info-enable-edit' is non-nil."
       (error "Editing info nodes is not enabled"))
   (Info-edit-mode)
   (message "%s" (substitute-command-keys
-           "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
+                "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
 
 (defun Info-cease-edit ()
   "Finish editing Info node; switch back to Info proper."
@@ -2150,7 +2176,7 @@ If the element is just a file name, the file name also serves as the prefix.")
 The `info-file' property of COMMAND says which Info manual to search.
 If COMMAND has no property, the variable `Info-file-list-for-emacs'
 defines heuristics for which Info manual to try.
-The locations are of the format used in Info-history, i.e.
+The locations are of the format used in `Info-history', i.e.
 \(FILENAME NODENAME BUFFERPOS\)."
   (let ((where '())
        (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
@@ -2184,10 +2210,10 @@ The locations are of the format used in Info-history, i.e.
       (setq Info-history (cdr Info-history))
       (goto-char (point-max))
       (while (re-search-backward cmd-desc nil t)
-         (setq where (cons (list Info-current-file
-                                 (match-string-no-properties 1)
-                                 0)
-                           where)))
+       (setq where (cons (list Info-current-file
+                               (match-string-no-properties 1)
+                               0)
+                         where)))
       where)))
 
 ;;;###autoload
@@ -2226,7 +2252,7 @@ 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.
-Interactively, if the binding is execute-extended-command, a command is read.
+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
 or in another manual found via COMMAND's `info-file' property or
 the variable `Info-file-list-for-emacs'."
@@ -2286,20 +2312,20 @@ The alist key is the character the title is underlined with (?*, ?= or ?-)."
                               'mouse-face 'highlight))))
       (goto-char (point-min))
       (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
-                                nil t)
+                               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))) 
+               (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))
-           (put-text-property (match-end 1) (match-end 2)
-                              'invisible t)))
+           (add-text-properties (match-end 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
@@ -2316,7 +2342,7 @@ The alist key is the character the title is underlined with (?*, ?= or ?-)."
          (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
+             (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))
@@ -2425,32 +2451,32 @@ specific node to expand."
             (setq completions (cdr completions)))
           t)
        nil))))
-  
+
 (defun Info-speedbar-goto-node (text node indent)
   "When user clicks on TEXT, goto an info NODE.
 The INDENT level is ignored."
-    (select-frame speedbar-attached-frame)
-    (let* ((buff (or (get-buffer "*info*")
-                    (progn (info) (get-buffer "*info*"))))
-          (bwin (get-buffer-window buff 0)))
-      (if bwin
-         (progn
-           (select-window bwin)
-           (raise-frame (window-frame bwin)))
-       (if speedbar-power-click
-           (let ((pop-up-frames t)) (select-window (display-buffer buff)))
-         (select-frame speedbar-attached-frame)
-         (switch-to-buffer buff)))
-      (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
-           (file (match-string 1 node))
-           (node (match-string 2 node)))
-       (Info-find-node file node)
-       ;; If we do a find-node, and we were in info mode, restore
-       ;; the old default method.  Once we are in info mode, it makes
-       ;; sense to return to whatever method the user was using before.
-       (if (string= speedbar-initial-expansion-list-name "Info")
-           (speedbar-change-initial-expansion-list
-            speedbar-previously-used-expansion-list-name)))))
+  (select-frame speedbar-attached-frame)
+  (let* ((buff (or (get-buffer "*info*")
+                  (progn (info) (get-buffer "*info*"))))
+        (bwin (get-buffer-window buff 0)))
+    (if bwin
+       (progn
+         (select-window bwin)
+         (raise-frame (window-frame bwin)))
+      (if speedbar-power-click
+         (let ((pop-up-frames t)) (select-window (display-buffer buff)))
+       (select-frame speedbar-attached-frame)
+       (switch-to-buffer buff)))
+    (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
+         (file (match-string 1 node))
+         (node (match-string 2 node)))
+      (Info-find-node file node)
+      ;; If we do a find-node, and we were in info mode, restore
+      ;; the old default method.  Once we are in info mode, it makes
+      ;; sense to return to whatever method the user was using before.
+      (if (string= speedbar-initial-expansion-list-name "Info")
+         (speedbar-change-initial-expansion-list
+          speedbar-previously-used-expansion-list-name)))))
 
 (defun Info-speedbar-expand-node (text token indent)
   "Expand the node the user clicked on.
@@ -2460,9 +2486,9 @@ INDENT is the current indentation depth."
   (cond ((string-match "+" text)       ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (if (speedbar-with-writable
-              (save-excursion
-                (end-of-line) (forward-char 1)
-                (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
+             (save-excursion
+               (end-of-line) (forward-char 1)
+               (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
             (speedbar-change-expand-button-char ?-)
           (speedbar-change-expand-button-char ??)))
        ((string-match "-" text)        ;we have to contract this node
@@ -2520,6 +2546,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
 (dolist (mess '("^Node has no Previous$"
                "^No menu in this node$"
                "^Node has no Next$"
+                "^No cross-references in this node^"
+                search-failed
                "^No \".*\" in index$"))
   (add-to-list 'debug-ignored-errors mess))