Changes to support filenames as tags too and provided
[bpt/emacs.git] / lisp / info.el
index dfe842c..7feaf6b 100644 (file)
@@ -55,7 +55,9 @@ in paths.el.")
 
 (defvar Info-directory-list
   (let ((path (getenv "INFOPATH"))
-       (sep (if (eq system-type 'ms-dos) ";" ":"))
+       (sep (if (or (eq system-type 'ms-dos) 
+                    (eq system-type 'windows-nt))
+                ";" ":"))
        (sibling (expand-file-name "../info/" (invocation-directory))))
     (if path
        (let ((list nil)
@@ -68,9 +70,9 @@ in paths.el.")
          (nreverse list))
       (if (or (member sibling Info-default-directory-list)
              (not (file-exists-p sibling))
-             ;; On MS-DOS, we use movable executables always,
+             ;; On DOS/NT, we use movable executables always,
              ;; and we must always find the Info dir at run time.
-             (if (eq system-type 'ms-dos)
+             (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
                  nil
                ;; Use invocation-directory for Info only if we used it for
                ;; exec-directory also.
@@ -153,14 +155,13 @@ Do the right thing if the file has been compressed or zipped."
        (setq tail (cdr tail)))
       (setq fullname (concat filename (car (car tail)))
            decoder (cdr (car tail)))
-      ;; check for conflict with jka-compr
-      (if (and (featurep 'jka-compr)
-              (jka-compr-installed-p)
-              (jka-compr-get-compression-info (concat filename
-                                                      (car (car tail)))))
-         (setq decoder nil))
       (or tail
          (error "Can't find %s or any compressed version of it!" filename)))
+    ;; check for conflict with jka-compr
+    (if (and (featurep 'jka-compr)
+            (jka-compr-installed-p)
+            (jka-compr-get-compression-info fullname))
+       (setq decoder nil))
     (insert-file-contents fullname visit)
     (if decoder
        (let ((buffer-read-only nil))
@@ -215,10 +216,14 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
                          ;; If specified name starts with `./'
                          ;; then just try current directory.
                          '("./")
-                       (if Info-additional-directory-list
-                           (append Info-directory-list
-                                   Info-additional-directory-list)
-                         Info-directory-list))))
+                       (if (file-name-absolute-p filename)
+                           ;; No point in searching for an
+                           ;; absolute file name
+                           '(nil)
+                         (if Info-additional-directory-list
+                             (append Info-directory-list
+                                     Info-additional-directory-list)
+                           Info-directory-list)))))
            ;; Search the directory list for file FILENAME.
            (while (and dirs (not found))
              (setq temp (expand-file-name filename (car dirs)))
@@ -475,14 +480,14 @@ In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
                                 nil t)
              (progn
                (search-forward "\n\^_" nil 'move)
-               (beginning-of-line))
+               (beginning-of-line)
+               (insert "\n"))
            ;; If none exists, add one.
            (goto-char (point-max))
            (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
          ;; Merge the text from the other buffer's menu
          ;; into the menu in the like-named node in the main buffer.
-         (apply 'insert-buffer-substring (cdr (car nodes)))
-         (insert "\n"))
+         (apply 'insert-buffer-substring (cdr (car nodes))))
        (setq nodes (cdr nodes)))
       ;; Kill all the buffers we just made.
       (while buffers
@@ -823,7 +828,7 @@ NAME may be an abbreviation of the reference name."
           (list (if (equal input "")
                     default input)))
        (error "No cross-references in this node"))))
-  (let (target beg i (str (concat "\\*note " footnotename)))
+  (let (target beg i (str (concat "\\*note " (regexp-quote footnotename))))
     (while (setq i (string-match " " str i))
       (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
       (setq i (+ i 6)))
@@ -1116,7 +1121,10 @@ N is the digit argument used to invoke this command."
        (t                                      (error "No previous nodes"))))
 
 (defun Info-scroll-up ()
-  "Read the next screen.  If end of buffer is visible, go to next entry."
+  "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,
+the next scroll moves into its first subnode.  When you scroll past
+the end of a node, that goes back to the parent node."
   (interactive)
   (if (or (< (window-start) (point-min))
          (> (window-start) (point-max)))
@@ -1132,7 +1140,11 @@ N is the digit argument used to invoke this command."
       (scroll-up))))
 
 (defun Info-scroll-down ()
-  "Read the previous screen.  If start of buffer is visible, go to last entry."
+  "Scroll one screenful back in Info, considering all nodes as one sequence.
+If you are within the menu of a node, this follows the previous
+menu item, so that you scroll through all the subnodes, ordered
+as if they appeared in place of the menu.  When you scroll past
+the beginning of a node, that goes back to the parent node."
   (interactive)
   (if (or (< (window-start) (point-min))
          (> (window-start) (point-max)))
@@ -1290,6 +1302,7 @@ Give a blank topic name to go to the Index node itself."
     (switch-to-buffer "*Help*")
     (erase-buffer)
     (insert (documentation 'Info-mode))
+    (help-mode)
     (goto-char (point-min))
     (let (ch flag)
       (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
@@ -1415,6 +1428,8 @@ If no reference to follow, moves to the next node, or up if none."
   (define-key Info-mode-map "p" 'Info-prev)
   (define-key Info-mode-map "q" 'Info-exit)
   (define-key Info-mode-map "s" 'Info-search)
+  ;; For consistency with Rmail.
+  (define-key Info-mode-map "\M-s" 'Info-search)
   (define-key Info-mode-map "t" 'Info-top-node)
   (define-key Info-mode-map "u" 'Info-up)
   (define-key Info-mode-map "," 'Info-index-next)
@@ -1486,7 +1501,7 @@ Advanced commands:
   (make-local-variable 'Info-tag-table-marker)
   (make-local-variable 'Info-history)
   (make-local-variable 'Info-index-alternatives)
-  (if (fboundp 'make-face)
+  (if (memq (framep (selected-frame)) '(x pc))
       (progn
        (make-face 'info-node)
        (make-face 'info-menu-5)
@@ -1518,14 +1533,6 @@ Advanced commands:
 Like text mode with the addition of `Info-cease-edit'
 which returns to Info mode for browsing.
 \\{Info-edit-map}"
-  )
-
-(defun Info-edit ()
-  "Edit the contents of this Info node.
-Allowed only if variable `Info-enable-edit' is non-nil."
-  (interactive)
-  (or Info-enable-edit
-      (error "Editing info nodes is not enabled"))
   (use-local-map Info-edit-map)
   (setq major-mode 'Info-edit-mode)
   (setq mode-name "Info Edit")
@@ -1533,8 +1540,18 @@ Allowed only if variable `Info-enable-edit' is non-nil."
   (setq buffer-read-only nil)
   ;; Make mode line update.
   (set-buffer-modified-p (buffer-modified-p))
+  (buffer-enable-undo (current-buffer))
+  (run-hooks 'Info-edit-mode-hook))
+
+(defun Info-edit ()
+  "Edit the contents of this Info node.
+Allowed only if variable `Info-enable-edit' is non-nil."
+  (interactive)
+  (or Info-enable-edit
+      (error "Editing info nodes is not enabled"))
+  (Info-edit-mode)
   (message (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."