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