2001-03-04 09:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
[gnus] / texi / infohack.el
1 ;;; infohack.el --- a hack to format info file.
2 ;; Copyright (C)  2001  Free Software Foundation, Inc.
3
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: info
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'texinfmt)
29
30 (defun infohack-remove-unsupported ()
31   (goto-char (point-min))
32   (while (re-search-forward "@\\(end \\)?ifnottex" nil t) 
33     (replace-match "")))
34
35 (defun infohack (file)
36   (let ((dest-directory default-directory)
37         (max-lisp-eval-depth (max max-lisp-eval-depth 600)))
38     (find-file file)
39     (infohack-remove-unsupported)
40     (texinfo-every-node-update) 
41     (texinfo-format-buffer t) ;; Don't save any file.
42     (setq default-directory dest-directory)
43     (setq buffer-file-name 
44           (expand-file-name (file-name-nondirectory buffer-file-name)
45                             default-directory))
46     (if (> (buffer-size) 100000)
47         (Info-split))
48     (save-buffer)))
49
50 (defun batch-makeinfo ()
51   "Emacs makeinfo in batch mode."
52   (infohack (car command-line-args-left))
53   (setq command-line-args-left nil))
54
55 ;;; infohack.el ends here