]> code.delx.au - gnu-emacs/blobdiff - lisp/info.el
(forms--change-commands): Use command remapping instead of
[gnu-emacs] / lisp / info.el
index 2b4b72fe65af8c71f2c51b5411ae0fb4cc39d2ac..ed323d6e7f090cb707ecc51ce62c7172e8189bd3 100644 (file)
@@ -127,8 +127,7 @@ 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 searched after those in `Info-directory-list', and
-they are not searched for merging the `dir' file."
+These directories are searched after those in `Info-directory-list'."
   :type '(repeat directory)
   :group 'info)
 
@@ -535,6 +534,40 @@ else defaults to \"Top\"."
   (set (make-local-variable 'Info-current-file) t)
   (Info-find-node-2 nil nodename))
 
+;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
+;; but at least it keeps this routine (which is only for the benefit of
+;; makeinfo-buffer) out of the way of normal operations.
+;;
+(defun Info-revert-find-node (filename nodename)
+  "Go to an info node FILENAME and NODENAME, re-reading disk contents.
+When *info* is already displaying FILENAME and NODENAME, the window position
+is preserved, if possible."
+  (pop-to-buffer "*info*")
+  (let ((old-filename Info-current-file)
+       (old-nodename Info-current-node)
+       (pcolumn      (current-column))
+       (pline        (count-lines (point-min) (line-beginning-position)))
+       (wline        (count-lines (point-min) (window-start)))
+       (old-history  Info-history)
+       (new-history (and Info-current-file
+                         (list Info-current-file Info-current-node (point)))))
+    (kill-buffer (current-buffer))
+    (Info-find-node filename nodename)
+    (setq Info-history old-history)
+    (if (and (equal old-filename Info-current-file)
+            (equal old-nodename Info-current-node))
+       (progn
+         ;; note goto-line is no good, we want to measure from point-min
+         (beginning-of-buffer)
+         (forward-line wline)
+         (set-window-start (selected-window) (point))
+         (beginning-of-buffer)
+         (forward-line pline)
+         (move-to-column pcolumn))
+      ;; only add to the history when coming from a different file+node
+      (if new-history
+         (setq Info-history (cons new-history Info-history))))))
+
 (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.
@@ -775,14 +808,13 @@ a case-insensitive match is tried."
                    (append Info-directory-list
                            Info-additional-directory-list)
                  Info-directory-list))
+         (dir-file-attrs nil)
          ;; Bind this in case the user sets it to nil.
          (case-fold-search t)
          ;; This is set non-nil if we find a problem in some input files.
          problems
          buffers buffer others nodes dirs-done)
 
-      (setq Info-dir-file-attributes nil)
-
       ;; Search the directory list for the directory file.
       (while dirs
        (let ((truename (file-truename (expand-file-name (car dirs)))))
@@ -813,17 +845,19 @@ a case-insensitive match is tried."
                      (condition-case nil
                          (progn
                            (insert-file-contents file)
-                           (make-local-variable 'Info-dir-file-name)
-                           (setq Info-dir-file-name file)
+                           (set (make-local-variable 'Info-dir-file-name)
+                                file)
                            (push (current-buffer) buffers)
-                           (push (cons file attrs) Info-dir-file-attributes))
+                           (push (cons file attrs) dir-file-attrs))
                        (error (kill-buffer (current-buffer))))))))
-         (or (cdr dirs) (setq Info-dir-contents-directory
-                              (file-name-as-directory (car dirs))))
+         (unless (cdr dirs)
+           (set (make-local-variable '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
       ;; others.  Yes, that is really what this is supposed to do.
       ;; The definition of `Info-directory-list' puts it first on that
@@ -901,8 +935,9 @@ a case-insensitive match is tried."
       (goto-char (point-min))
       (if problems
          (message "Composing main Info directory...problems encountered, see `*Messages*'")
-       (message "Composing main Info directory...done")))
-    (setq Info-dir-contents (buffer-string)))
+       (message "Composing main Info directory...done"))
+      (set (make-local-variable 'Info-dir-contents) (buffer-string))
+      (set (make-local-variable 'Info-dir-file-attributes) dir-file-attrs)))
   (setq default-directory Info-dir-contents-directory))
 
 (defvar Info-streamline-headings
@@ -966,7 +1001,7 @@ a case-insensitive match is tried."
                (if (member-ignore-case x seen)
                    (delete-region (match-beginning 0)
                                   (progn (re-search-forward "^[^ \t]" nil t)
-                                         (goto-char (match-beginning 0))))
+                                         (match-beginning 0)))
                  (push x seen))))))))))
 
 ;; Note that on entry to this function the current-buffer must be the
@@ -1508,9 +1543,9 @@ FOOTNOTENAME may be an abbreviation of the reference name."
            (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)))
+           (set (make-local-variable '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)))))))
@@ -2658,7 +2693,8 @@ the variable `Info-file-list-for-emacs'."
   (unless (next-property-change (point-min))
     (save-excursion
       (let ((inhibit-read-only t)
-           (case-fold-search t))
+           (case-fold-search t)
+           paragraph-markers)
        (goto-char (point-min))
        (when (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?")
          (goto-char (match-end 0))
@@ -2730,14 +2766,15 @@ the variable `Info-file-list-for-emacs'."
            (add-text-properties (match-beginning 2) (1+ (match-end 2))
                                 '(invisible t))))
        (goto-char (point-min))
-       (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[^.,:]*[,:]?\\)" nil t)
+       (while (re-search-forward "\\(\\*Note[ \n\t]*\\)\\([^:]*\\)\\(:[^.,:(]*\\(([^)]*)[^.,:]*\\)?[,:]?\n?\\)" nil t)
          (unless (= (char-after (1- (match-beginning 0))) ?\") ; hack
-           (let ((next (point))
+           (let ((start (match-beginning 0))
+                 (next (point))
                  (hide-tag Info-hide-note-references)
                  other-tag)
              (when hide-tag
                ;; *Note is often used where *note should have been
-               (goto-char (match-beginning 0))
+               (goto-char start)
                (skip-syntax-backward " ")
                (setq other-tag
                      (cond
@@ -2750,24 +2787,40 @@ the variable `Info-file-list-for-emacs'."
                (goto-char next))
              (if hide-tag
                  (add-text-properties (match-beginning 1) (match-end 1)
-                                      (if other-tag
-                                          (list 'display other-tag)
-                                        '(invisible t))))
+                                      '(invisible t)))
              (add-text-properties (match-beginning 2) (match-end 2)
                                   '(font-lock-face info-xref
                                                    mouse-face highlight
                                                    help-echo "mouse-2: go to this node"))
-             (if (eq Info-hide-note-references t)
-                 (add-text-properties (match-beginning 3) (match-end 3)
-                                      '(invisible t))))))
+             (when (eq Info-hide-note-references t)
+               (add-text-properties (match-beginning 3) (match-end 3)
+                                    '(invisible t)))
+             (when other-tag
+               (goto-char (match-beginning 1))
+               (insert other-tag))
+             (when (or hide-tag (eq Info-hide-note-references t))
+               (setq paragraph-markers (cons (set-marker (make-marker) start)
+                                             paragraph-markers))))))
+
+       (let ((fill-nobreak-invisible t))
+         (goto-char (point-max))
+         (while paragraph-markers
+           (let ((m (car paragraph-markers)))
+             (setq paragraph-markers (cdr paragraph-markers))
+             (when (< m (point))
+               (goto-char m)
+               (fill-paragraph nil)
+               (backward-paragraph 1))
+             (set-marker m nil))))
 
        (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]*\\)\\(:[^.,:]*[,:.][ \t]*\\)" nil t)
+           (let ((n 0)
+                 cont)
+             (while (re-search-forward "^\\* +\\([^:\t\n]*\\)\\(:[^.,:(]*\\(([^)]*)[^.,:]*\\)?[,:.][ \t]*\\)" nil t)
                (setq n (1+ n))
                (if (zerop (% n 3)) ; visual aids to help with 1-9 keys
                    (put-text-property (match-beginning 0)
@@ -2777,10 +2830,17 @@ the variable `Info-file-list-for-emacs'."
                                     '(font-lock-face info-xref
                                       mouse-face highlight
                                       help-echo "mouse-2: go to this node"))
+               (when (eq Info-hide-note-references t)
+                 (add-text-properties (match-beginning 2) (match-end 2)
+                                      (list 'display
+                                            (make-string (max 2 (- 22 (- (match-end 1) (match-beginning 1)))) ? )))
+                 (setq cont (looking-at "[ \t]*[^\n]")))
                (if (eq Info-hide-note-references t)
-                   (add-text-properties (match-beginning 2) (match-end 2)
-                                        (list 'display
-                                              (make-string (max 2 (- 22 (- (match-end 1) (match-beginning 1)))) ? )))))))
+                   (while (and (= (forward-line 1) 0)
+                               (looking-at "\\([ \t]+\\)[^*\n]"))
+                     (add-text-properties (match-beginning 1) (match-end 1)
+                                          (list 'display (make-string (+ 22 (if cont 4 2)) ? )))
+                     (setq cont t))))))
 
        (Info-fontify-menu-headers)
        (set-buffer-modified-p nil)))))