(infohack): Insert @include files before performing texinfo-every-node-update.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 24 Sep 2008 06:45:00 +0000 (06:45 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 24 Sep 2008 06:45:00 +0000 (06:45 +0000)
texi/ChangeLog
texi/infohack.el

index dc2a48f..198757f 100644 (file)
@@ -1,5 +1,8 @@
 2008-09-24  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+       * infohack.el (infohack): Insert @include files before performing
+       texinfo-every-node-update.
+
        * gnus.texi (The Gnus Registry): Don't give argument to @item used in
        @enumerate section so as to be able to be formatted with MAKEINFO=no.
 
index 40fd5be..86af4c6 100644 (file)
@@ -80,6 +80,28 @@ which are indicated by the @copying ... @end copying command."
     (find-file file)
     (setq buffer-read-only nil)
     (setq coding-system buffer-file-coding-system)
+
+    ;; Insert @include files before performing `texinfo-every-node-update'.
+    (set-syntax-table texinfo-format-syntax-table)
+    (let (start texinfo-command-end filename)
+      (while (re-search-forward "^@include" nil t)
+       (setq start (match-beginning 0)
+             texinfo-command-end (point)
+             filename (texinfo-parse-line-arg))
+       (delete-region start (point-at-bol 2))
+       (message "Reading included file: %s" filename)
+       (save-excursion
+         (save-restriction
+           (narrow-to-region
+            (point)
+            (+ (point) (car (cdr (insert-file-contents filename)))))
+           (goto-char (point-min))
+           ;; Remove `@setfilename' line from included file, if any,
+           ;; so @setfilename command not duplicated.
+           (if (re-search-forward "^@setfilename" (point-at-eol 100) t)
+               (delete-region (point-at-bol 1)
+                              (point-at-bol 2)))))))
+
     (infohack-remove-unsupported)
     (texinfo-every-node-update) 
     (texinfo-format-buffer t) ;; Don't save any file.