]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/info.el (Info-file-attributes): New variable.
authorJuri Linkov <juri@jurta.org>
Tue, 21 Aug 2012 00:12:42 +0000 (03:12 +0300)
committerJuri Linkov <juri@jurta.org>
Tue, 21 Aug 2012 00:12:42 +0000 (03:12 +0300)
(info-insert-file-contents): Add file attributes to
`Info-file-attributes'.  Clear the caches `Info-index-nodes' and
`Info-toc-nodes' when previous modtime of the Info file is less
than new modtime.
(Info-toc-nodes, Info-index-nodes): Move definitions up to the top
of info.el.

Fixes: debbugs:12230
lisp/ChangeLog
lisp/info.el

index a1464b52e6cfd0a39979924b8dd3e2eae4bf1e6d..0b9a95ef35263a396599c86ed21282903e7ce9cd 100644 (file)
@@ -1,3 +1,13 @@
+2012-08-21  Juri Linkov  <juri@jurta.org>
+
+       * info.el (Info-file-attributes): New variable.
+       (info-insert-file-contents): Add file attributes to
+       `Info-file-attributes'.  Clear the caches `Info-index-nodes' and
+       `Info-toc-nodes' when previous modtime of the Info file is less
+       than new modtime.
+       (Info-toc-nodes, Info-index-nodes): Move definitions up to the top
+       of info.el.  (Bug#12230)
+
 2012-08-20  Glenn Morris  <rgm@gnu.org>
 
        * calendar/diary-lib.el (diary-include-files, diary-sexp-entry):
index 317cba865000b63a04cf8c70ea82afc36ab09cb4..15478f9063c66291dbef903387bf8bed9c919f00 100644 (file)
@@ -417,6 +417,21 @@ If number, the point is moved to the corresponding line.")
 (defvar Info-standalone nil
   "Non-nil if Emacs was started solely as an Info browser.")
 
+(defvar Info-file-attributes nil
+  "Alist of file attributes of visited Info files.
+Each element is a list (FILE-NAME FILE-ATTRIBUTES...).")
+
+(defvar Info-toc-nodes nil
+  "Alist of cached parent-children node information in visited Info files.
+Each element is (FILE (NODE-NAME PARENT SECTION CHILDREN) ...)
+where PARENT is the parent node extracted from the Up pointer,
+SECTION is the section name in the Top node where this node is placed,
+CHILDREN is a list of child nodes extracted from the node menu.")
+
+(defvar Info-index-nodes nil
+  "Alist of cached index node names of visited Info files.
+Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
+
 (defvar Info-virtual-files nil
   "List of definitions of virtual Info files.
 Each element of the list has the format (FILENAME (OPERATION . HANDLER) ...)
@@ -609,7 +624,26 @@ Do the right thing if the file has been compressed or zipped."
            (apply 'call-process-region (point-min) (point-max)
                   (car decoder) t t nil (cdr decoder))))
       (let ((inhibit-null-byte-detection t)) ; Index nodes include null bytes
-       (insert-file-contents fullname visit)))))
+       (insert-file-contents fullname visit)))
+
+    ;; Clear the caches of modified Info files.
+    (let* ((attribs-old (cdr (assoc fullname Info-file-attributes)))
+          (modtime-old (and attribs-old (nth 5 attribs-old)))
+          (attribs-new (and (stringp fullname) (file-attributes fullname)))
+          (modtime-new (and attribs-new (nth 5 attribs-new))))
+      (when (and modtime-old modtime-new
+                (> (float-time modtime-new) (float-time modtime-old)))
+       (setq Info-index-nodes (remove (assoc (or Info-current-file filename)
+                                             Info-index-nodes)
+                                      Info-index-nodes))
+       (setq Info-toc-nodes (remove (assoc (or Info-current-file filename)
+                                           Info-toc-nodes)
+                                    Info-toc-nodes)))
+      ;; Add new modtime to `Info-file-attributes'.
+      (setq Info-file-attributes
+           (cons (cons fullname attribs-new)
+                 (remove (assoc fullname Info-file-attributes)
+                         Info-file-attributes))))))
 
 (defun Info-file-supports-index-cookies (&optional file)
   "Return non-nil value if FILE supports Info index cookies.
@@ -2394,13 +2428,6 @@ Table of contents is created from the tree structure of menus."
       (message "")
       (nreverse nodes))))
 
-(defvar Info-toc-nodes nil
-  "Alist of cached parent-children node information in visited Info files.
-Each element is (FILE (NODE-NAME PARENT SECTION CHILDREN) ...)
-where PARENT is the parent node extracted from the Up pointer,
-SECTION is the section name in the Top node where this node is placed,
-CHILDREN is a list of child nodes extracted from the node menu.")
-
 (defun Info-toc-nodes (filename)
   "Return a node list of Info FILENAME with parent-children information.
 This information is cached in the variable `Info-toc-nodes' with the help
@@ -3032,10 +3059,6 @@ See `Info-scroll-down'."
       (if (looking-at "^\\* ")
          (forward-char 2)))))
 \f
-(defvar Info-index-nodes nil
-  "Alist of cached index node names of visited Info files.
-Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
-
 (defun Info-index-nodes (&optional file)
   "Return a list of names of all index nodes in Info FILE.
 If FILE is omitted, it defaults to the current Info file.