+(defun infohack-include-files ()
+ "Insert @include files."
+ (goto-char (point-min))
+ (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))))))))
+