Add page breaks during conversion to avoid seeing them in the manual.
[gnus] / texi / gnus-news.el
1 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
2 ;; Copyright (C)  2004, 2005, 2006  Free Software Foundation, Inc.
3
4 ;; Author: Reiner Steib  <Reiner.Steib@gmx.de>
5 ;; Keywords: tools
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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (defvar gnus-news-header-disclaimer
29 "GNUS NEWS -- history of user-visible changes.
30 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
31    2006 Free Software Foundation, Inc.
32 See the end for copying conditions.
33
34 Please send Gnus bug reports to bugs\@gnus.org.
35 For older news, see Gnus info node \"New Features\".
36
37 ")
38
39 (defvar gnus-news-trailer
40 "\f
41 * For older news, see Gnus info node \"New Features\".
42
43 ----------------------------------------------------------------------
44 Copyright information:
45
46 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
47    2006 Free Software Foundation, Inc.
48
49    Permission is granted to anyone to make or distribute verbatim copies
50    of this document as received, in any medium, provided that the
51    copyright notice and this permission notice are preserved,
52    thus giving the recipient permission to redistribute in turn.
53
54    Permission is granted to distribute modified versions
55    of this document, or of portions of it,
56    under the above conditions, provided also that they
57    carry prominent notices stating who last changed them.
58 \f\nLocal variables:\nmode: outline
59 paragraph-separate: \"[         \f]*$\"\nend:\n")
60
61 (defvar gnus-news-makeinfo-command "makeinfo")
62
63 (defvar gnus-news-fill-column 80)
64
65 (defvar gnus-news-makeinfo-switches
66   (concat " --no-headers --paragraph-indent=0"
67           " --no-validate" ;; Allow unresolved references.
68           " --fill-column=" (number-to-string
69                              (+ 3 ;; will strip leading spaces later
70                                 (or gnus-news-fill-column 80)))))
71
72 (defun batch-gnus-news ()
73   "Make GNUS-NEWS in batch mode."
74   (let (infile outfile)
75     (setq infile (car command-line-args-left)
76           command-line-args-left (cdr command-line-args-left)
77           outfile (car command-line-args-left)
78           command-line-args-left nil)
79     (if (and infile outfile)
80         (message "Creating `%s' from `%s'..." outfile infile)
81       (error "Not enough files given."))
82     (gnus-news-translate-file infile outfile)))
83
84 (defun gnus-news-translate-file (infile outfile)
85   "Translate INFILE (texinfo) to OUTFILE (GNUS-NEWS)."
86   (let* ((dir (concat (or (getenv "srcdir") ".") "/"))
87          (infile (concat dir infile))
88          (buffer (find-file-noselect (concat dir outfile))))
89     (with-temp-buffer
90       ;; Could be done using `texinfmt' stuff as in `infohack.el'.
91       (insert
92        (shell-command-to-string
93         (concat gnus-news-makeinfo-command " "
94                 gnus-news-makeinfo-switches " " infile)))
95       (goto-char (point-max))
96       (delete-char -1)
97       (goto-char (point-min))
98       (save-excursion
99         (while (re-search-forward "^   \\* " nil t)
100           (replace-match "\f\n* ")))
101       (save-excursion
102         (while (re-search-forward "^        \\* " nil t)
103           (replace-match "** ")))
104       (save-excursion
105         (while (re-search-forward "^     " nil t)
106           (replace-match "")))
107       ;; Avoid `*' from @ref at beginning of line:
108       (save-excursion
109         (while (re-search-forward "^\\*Note" nil t)
110           (replace-match " \\&")))
111       (goto-char (point-min))
112       (insert gnus-news-header-disclaimer)
113       (goto-char (point-max))
114       (insert gnus-news-trailer)
115       (write-region (point-min) (point-max) outfile))))
116
117 ;;; arch-tag: e23cdd27-eafd-4ba0-816f-98f5edb0dc29
118 ;;; gnus-news.el ends here