]> code.delx.au - gnu-emacs/blobdiff - lisp/info.el
Merge from emacs-24; up to 2012-12-02T06:22:32Z!cyd@gnu.org
[gnu-emacs] / lisp / info.el
index 5862e5e850fbf614c492416749e6572ae85197d8..4c7bb981afc25d90278a5581f1662f9305d71276 100644 (file)
@@ -1668,7 +1668,9 @@ escaped (\\\",\\\\)."
                 " ("
                 (if (stringp Info-current-file)
                     (replace-regexp-in-string
-                     "%" "%%" (file-name-nondirectory Info-current-file))
+                     "%" "%%"
+                     (file-name-sans-extension
+                      (file-name-nondirectory Info-current-file)))
                   (format "*%S*" Info-current-file))
                 ") "
                 (if Info-current-node
@@ -2646,6 +2648,7 @@ Because of ambiguities, this should be concatenated with something like
                     (while (re-search-forward pattern nil t)
                       (push (match-string-no-properties 1)
                             completions))
+                   (setq completions (delete-dups completions))
                     ;; Check subsequent nodes if applicable.
                     (or (and Info-complete-next-re
                              (setq nextnode (Info-extract-pointer "next" t))
@@ -4031,7 +4034,9 @@ With a zero prefix arg, put the name inside a function call to `info'."
   (unless Info-current-node
     (user-error "No current Info node"))
   (let ((node (if (stringp Info-current-file)
-                 (concat "(" (file-name-nondirectory Info-current-file) ") "
+                 (concat "(" (file-name-sans-extension
+                              (file-name-nondirectory Info-current-file))
+                         ") "
                          Info-current-node))))
     (if (zerop (prefix-numeric-value arg))
         (setq node (concat "(info \"" node "\")")))
@@ -4418,7 +4423,8 @@ first line or header line, and for breadcrumb links.")
               (if (not (equal node "Top")) node
                 (format "(%s)Top"
                         (if (stringp Info-current-file)
-                            (file-name-nondirectory Info-current-file)
+                            (file-name-sans-extension
+                             (file-name-nondirectory Info-current-file))
                           ;; Some legacy code can still use a symbol.
                           Info-current-file)))))
          (setq line (concat
@@ -4530,7 +4536,8 @@ first line or header line, and for breadcrumb links.")
              (if (re-search-forward
                   (format "File: %s\\([^,\n\t]+\\),"
                           (if (stringp Info-current-file)
-                              (file-name-nondirectory Info-current-file)
+                              (file-name-sans-extension
+                               (file-name-nondirectory Info-current-file))
                             Info-current-file))
                   header-end t)
                  (put-text-property (match-beginning 1) (match-end 1)
@@ -4825,8 +4832,8 @@ first line or header line, and for breadcrumb links.")
       ;; Hide empty lines at the end of the node.
       (goto-char (point-max))
       (skip-chars-backward "\n")
-      (when (< (1+ (point)) (point-max))
-       (put-text-property (1+ (point)) (point-max) 'invisible t))
+      (when (< (point) (1- (point-max)))
+       (put-text-property (point) (1- (point-max)) 'invisible t))
 
       (set-buffer-modified-p nil))))
 \f
@@ -4835,6 +4842,17 @@ first line or header line, and for breadcrumb links.")
 ;; current Info node.
 (eval-when-compile (require 'speedbar))
 
+(declare-function speedbar-add-expansion-list "speedbar" (new-list))
+(declare-function speedbar-center-buffer-smartly "speedbar" ())
+(declare-function speedbar-change-expand-button-char "speedbar" (char))
+(declare-function speedbar-change-initial-expansion-list "speedbar" (new-default))
+(declare-function speedbar-delete-subblock "speedbar" (indent))
+(declare-function speedbar-make-specialized-keymap "speedbar" ())
+(declare-function speedbar-make-tag-line "speedbar"
+                  (exp-button-type exp-button-char exp-button-function
+                   exp-button-data tag-button tag-button-function
+                   tag-button-data tag-button-face depth))
+
 (defvar Info-speedbar-key-map nil
   "Keymap used when in the Info display mode.")
 
@@ -5057,7 +5075,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
   "This implements the `bookmark-make-record-function' type (which see)
 for Info nodes."
   (let* ((file (and (stringp Info-current-file)
-                   (file-name-nondirectory Info-current-file)))
+                   (file-name-sans-extension
+                    (file-name-nondirectory Info-current-file))))
         (bookmark-name (if file
                            (concat "(" file ") " Info-current-node)
                          Info-current-node))
@@ -5085,8 +5104,16 @@ type returned by `Info-bookmark-make-record', which see."
 \f
 ;;;###autoload
 (defun info-display-manual (manual)
-  "Go to Info buffer that displays MANUAL, creating it if none already exists."
-  (interactive "sManual name: ")
+  "Display an Info buffer displaying MANUAL.
+If there is an existing Info buffer for MANUAL, display it.
+Otherwise, visit the manual in a new Info buffer."
+  (interactive
+   (list
+    (progn
+      (info-initialize)
+      (completing-read "Manual name: "
+                      (info--manual-names)
+                      nil t))))
   (let ((blist (buffer-list))
        (manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
        (case-fold-search t)
@@ -5101,7 +5128,22 @@ type returned by `Info-bookmark-make-record', which see."
     (if found
        (switch-to-buffer found)
       (info-initialize)
-      (info (Info-find-file manual)))))
+      (info (Info-find-file manual)
+           (generate-new-buffer-name "*info*")))))
+
+(defun info--manual-names ()
+  (let (names)
+    (dolist (buffer (buffer-list))
+      (with-current-buffer buffer
+       (and (eq major-mode 'Info-mode)
+            (stringp Info-current-file)
+            (push (file-name-sans-extension
+                   (file-name-nondirectory Info-current-file))
+                  names))))
+    (delete-dups (append (nreverse names)
+                        (apply-partially 'Info-read-node-name-2
+                                         Info-directory-list
+                                         (mapcar 'car Info-suffix-list))))))
 
 (provide 'info)