X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=texi%2Finfohack.el;h=31e301146cd78745d0c9064a29a8070be352c1ae;hb=5f010ae4af62767b310552982e231d082ac51652;hp=e5c326f1710c54b6723913d56ed4dc9e71dadebf;hpb=295f0ae7023b7db676a5d27e404e7428d7116419;p=gnus diff --git a/texi/infohack.el b/texi/infohack.el index e5c326f17..31e301146 100644 --- a/texi/infohack.el +++ b/texi/infohack.el @@ -1,5 +1,5 @@ ;;; infohack.el --- a hack to format info file. -;; Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. +;; Copyright (C) 2001-2011 Free Software Foundation, Inc. ;; Author: Shenghuo Zhu ;; Keywords: info @@ -8,7 +8,7 @@ ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -18,8 +18,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -69,6 +69,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)) @@ -81,6 +104,7 @@ which are indicated by the @copying ... @end copying command." (setq buffer-read-only nil) (setq coding-system buffer-file-coding-system) (infohack-remove-unsupported) + (infohack-include-files) (texinfo-every-node-update) (texinfo-format-buffer t) ;; Don't save any file. (setq default-directory dest-directory) @@ -88,7 +112,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))) @@ -118,5 +144,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