Add 2010 to copyright years.
[bpt/emacs.git] / lisp / info.el
index cfaf749..4789d67 100644 (file)
@@ -1,7 +1,7 @@
 ;; info.el --- info package for Emacs
 
 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -607,9 +607,9 @@ in `Info-file-supports-index-cookies-list'."
   (let (same-window-buffer-names same-window-regexps)
     (info file-or-node)))
 
-;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
+;;;###autoload (add-hook 'same-window-regexps (purecopy "\\*info\\*\\(\\|<[0-9]+>\\)"))
 
-;;;###autoload (put 'info 'info-file "emacs")
+;;;###autoload (put 'info 'info-file (purecopy "emacs"))
 ;;;###autoload
 (defun info (&optional file-or-node buffer)
   "Enter Info, the documentation browser.
@@ -912,10 +912,12 @@ a case-insensitive match is tried."
        (cond
         ((functionp virtual-fun)
          (let ((filename (or filename Info-current-file)))
-           (setq buffer-file-name nil)
            (setq buffer-read-only nil)
+           (setq Info-current-file filename
+                 Info-current-subfile nil
+                 Info-current-file-completions nil
+                 buffer-file-name nil)
            (erase-buffer)
-           (setq Info-current-file filename)
            (Info-virtual-call virtual-fun filename nodename no-going-back)
            (set-marker Info-tag-table-marker nil)
            (setq buffer-read-only t)
@@ -928,8 +930,11 @@ a case-insensitive match is tried."
                    (equal Info-current-file filename))))
          ;; Switch files if necessary
          (let ((inhibit-read-only t))
-           (if (and Info-current-node-virtual (null filename))
-               (setq filename Info-current-file))
+           (when Info-current-node-virtual
+             ;; When moving from a virtual node.
+             (set (make-local-variable 'Info-current-node-virtual) nil)
+             (if (null filename)
+                 (setq filename Info-current-file)))
            (setq Info-current-file nil
                  Info-current-subfile nil
                  Info-current-file-completions nil
@@ -1441,7 +1446,8 @@ any double quotes or backslashes must be escaped (\\\",\\\\)."
              "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
              nil t)
        (let* ((start (match-beginning 1)))
-         (if (not (get-text-property start 'invisible))
+         (if (and (not (get-text-property start 'invisible))
+                  (not (get-text-property start 'display)))
              (put-text-property start (point) 'invisible t)))))
     (set-buffer-modified-p nil)))
 
@@ -2440,12 +2446,16 @@ Because of ambiguities, this should be concatenated with something like
             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)
+        (cond
+         ((eq (car-safe action) 'boundaries) nil)
+         ((eq action 'lambda)
+          (re-search-forward
+           (concat "\n\\* +" (regexp-quote string) ":") nil t))
+         (t
           (let ((pattern (concat "\n\\* +\\("
                                  (regexp-quote string)
-                                 Info-menu-entry-name-re "\\):" Info-node-spec-re))
+                                 Info-menu-entry-name-re "\\):"
+                                 Info-node-spec-re))
                 completions
                 (complete-nodes Info-complete-nodes))
             ;; Check the cache.
@@ -2480,9 +2490,7 @@ Because of ambiguities, this should be concatenated with something like
                   (list Info-current-file Info-current-node
                         Info-complete-next-re string completions
                         Info-complete-nodes)))
-           (if action
-               (all-completions string completions predicate)
-             (try-completion string completions predicate))))))))
+            (complete-with-action action completions string predicate))))))))
 
 
 (defun Info-menu (menu-item &optional fork)
@@ -2493,12 +2501,10 @@ 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
+   (let (;; If point is within a menu item, use that item as the default
         (default nil)
         (p (point))
         beg
-        (last nil)
         (case-fold-search t))
      (save-excursion
        (goto-char (point-min))
@@ -2892,7 +2898,7 @@ following nodes whose names also contain the word \"Index\"."
                                              (setq file (Info-find-file file))))
                                        default-directory))
                 Info-history Info-history-list Info-fontify-maximum-menu-size
-                (main-file file) subfiles nodes node)
+                (main-file file) subfiles nodes)
            (condition-case nil
                (with-temp-buffer
                  (while (or main-file subfiles)
@@ -2935,7 +2941,7 @@ following nodes whose names also contain the word \"Index\"."
                  (Info-goto-node (car nodes))
                  (while (and (setq node (Info-extract-pointer "next" t))
                              (string-match "\\<Index\\>" node))
-                   (setq nodes (cons node nodes))
+                   (push node nodes)
                    (Info-goto-node node))))
            (error nil))
          (if nodes
@@ -3650,6 +3656,8 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
      :help "Look for a string in the index items"]
     ["Next Matching Item" Info-index-next :active Info-index-alternatives
      :help "Look for another occurrence of previous item"]
+    ["Lookup a string and display index of results..." Info-virtual-index
+     :help "Look for a string in the index items and display node with results"]
     ["Lookup a string in all indices..." info-apropos
      :help "Look for a string in the indices of all manuals"])
    ["Copy Node Name" Info-copy-current-node-name
@@ -3824,6 +3832,7 @@ Advanced commands:
 \\[isearch-forward], \\[isearch-forward-regexp]        Use Isearch to search through multiple Info nodes.
 \\[Info-index] Search for a topic in this manual's Index and go to index entry.
 \\[Info-index-next]    (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
+\\[Info-virtual-index] Look for a string and display the index node with results.
 \\[info-apropos]       Look for a string in the indices of all manuals.
 \\[Info-goto-node]     Move to node specified by name.
          You may include a filename as well, as (FILENAME)NODENAME.
@@ -4038,7 +4047,7 @@ in the first element of the returned list (which is treated specially in
              (cdr where))
       where)))
 
-;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
+;;;###autoload (put 'Info-goto-emacs-command-node 'info-file (purecopy "emacs"))
 ;;;###autoload
 (defun Info-goto-emacs-command-node (command)
   "Go to the Info node in the Emacs manual for command COMMAND.
@@ -4080,7 +4089,7 @@ COMMAND must be a symbol or string."
                         (if (> num-matches 2) "them" "it")))))
       (error "Couldn't find documentation for %s" command))))
 
-;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
+;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file (purecopy "emacs"))
 ;;;###autoload
 (defun Info-goto-emacs-key-command-node (key)
   "Go to the node in the Emacs manual which describes the command bound to KEY.
@@ -4093,7 +4102,7 @@ the variable `Info-file-list-for-emacs'."
   (let ((command (key-binding key)))
     (cond ((null command)
           (message "%s is undefined" (key-description key)))
-         ((and (interactive-p)
+         ((and (called-interactively-p 'interactive)
                (eq command 'execute-extended-command))
           (Info-goto-emacs-command-node
            (read-command "Find documentation for command: ")))
@@ -4769,6 +4778,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
 
 (defun Info-bookmark-make-record ()
+  "This implements the `bookmark-make-record-function' type (which see)
+for Info nodes."
   `(,Info-current-node
     ,@(bookmark-make-record-default 'point-only)
     (filename . ,Info-current-file)
@@ -4777,8 +4788,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
 
 ;;;###autoload
 (defun Info-bookmark-jump (bmk)
-  ;; This implements the `handler' function interface for record type returned
-  ;; by `Info-bookmark-make-record', which see.
+  "This implements the `handler' function interface for the record
+type returned by `Info-bookmark-make-record', which see."
   (let* ((file                   (bookmark-prop-get bmk 'filename))
          (info-node              (bookmark-prop-get bmk 'info-node))
          (buf (save-window-excursion    ;FIXME: doesn't work with frames!