X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=texi%2Finfohack.el;h=7cc5887fd7bd7933fb35fe87247c58bd7a8cf878;hb=e5e8e4ab3378fc46fa3d54e8a8b0f8693c80241f;hp=86af4c6809e01e2e9dc71290d334cbbbe1174015;hpb=fe16500c3d7dad825929681f28f4979781d1429f;p=gnus diff --git a/texi/infohack.el b/texi/infohack.el index 86af4c680..7cc5887fd 100644 --- a/texi/infohack.el +++ b/texi/infohack.el @@ -1,5 +1,6 @@ ;;; infohack.el --- a hack to format info file. -;; Copyright (C) 2001, 2003, 2004, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2001, 2003, 2004, 2008, 2009, 2010 +;; Free Software Foundation, Inc. ;; Author: Shenghuo Zhu ;; Keywords: info @@ -69,6 +70,29 @@ which are indicated by the @copying ... @end copying command." (delete-region (1+ (match-beginning 0)) (search-forward "\n@end iflatex\n")))) +(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)))))))) + (defun infohack (file) (let ((dest-directory default-directory) (max-lisp-eval-depth (max max-lisp-eval-depth 600)) @@ -80,29 +104,8 @@ 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) + (infohack-include-files) (texinfo-every-node-update) (texinfo-format-buffer t) ;; Don't save any file. (setq default-directory dest-directory) @@ -110,7 +113,9 @@ which are indicated by the @copying ... @end copying command." (expand-file-name (file-name-nondirectory buffer-file-name) default-directory)) (setq buffer-file-coding-system coding-system) - (if (> (buffer-size) 100000) + (if (> (buffer-size) (if (boundp 'Info-split-threshold) + (+ 50000 Info-split-threshold) + 100000)) (Info-split)) (save-buffer))) @@ -140,5 +145,4 @@ Both characters must have the same length of multi-byte form." (infohack (car command-line-args-left)) (setq command-line-args-left nil)) -;;; arch-tag: 9ca2f71f-b280-48b3-9826-8dc052dfbbfe ;;; infohack.el ends here