(gnus-news-header-disclaimer, gnus-news-trailer): Switch
[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
31 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
32    2006, 2007 Free Software Foundation, Inc.
33 See the end of the file for license conditions.
34
35 Please send Gnus bug reports to bugs@gnus.org.
36 For older news, see Gnus info node \"New Features\".")
37
38 (defvar gnus-news-trailer
39 "\f
40 * For older news, see Gnus info node \"New Features\".
41
42 ----------------------------------------------------------------------
43 \f
44 This file is part of GNU Emacs.
45
46 GNU Emacs is free software; you can redistribute it and/or modify
47 it under the terms of the GNU General Public License as published by
48 the Free Software Foundation; either version 2, or (at your option)
49 any later version.
50
51 GNU Emacs is distributed in the hope that it will be useful,
52 but WITHOUT ANY WARRANTY; without even the implied warranty of
53 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
54 GNU General Public License for more details.
55
56 You should have received a copy of the GNU General Public License
57 along with GNU Emacs; see the file COPYING.  If not, write to the
58 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
59 Boston, MA 02110-1301, USA.
60
61 \f\nLocal variables:\nmode: outline
62 paragraph-separate: \"[         \f]*$\"\nend:\n")
63
64 (defvar gnus-news-makeinfo-command "makeinfo")
65
66 (defvar gnus-news-fill-column 80)
67
68 (defvar gnus-news-makeinfo-switches
69   (concat " --no-headers --paragraph-indent=0"
70           " --no-validate" ;; Allow unresolved references.
71           " --fill-column=" (number-to-string
72                              (+ 3 ;; will strip leading spaces later
73                                 (or gnus-news-fill-column 80)))))
74
75 (defun batch-gnus-news ()
76   "Make GNUS-NEWS in batch mode."
77   (let (infile outfile)
78     (setq infile (car command-line-args-left)
79           command-line-args-left (cdr command-line-args-left)
80           outfile (car command-line-args-left)
81           command-line-args-left nil)
82     (if (and infile outfile)
83         (message "Creating `%s' from `%s'..." outfile infile)
84       (error "Not enough files given."))
85     (gnus-news-translate-file infile outfile)))
86
87 (defun gnus-news-translate-file (infile outfile)
88   "Translate INFILE (texinfo) to OUTFILE (GNUS-NEWS)."
89   (let* ((dir (concat (or (getenv "srcdir") ".") "/"))
90          (infile (concat dir infile))
91          (buffer (find-file-noselect (concat dir outfile))))
92     (with-temp-buffer
93       ;; Could be done using `texinfmt' stuff as in `infohack.el'.
94       (insert
95        (shell-command-to-string
96         (concat gnus-news-makeinfo-command " "
97                 gnus-news-makeinfo-switches " " infile)))
98       (goto-char (point-max))
99       (delete-char -1)
100       (goto-char (point-min))
101       (save-excursion
102         (while (re-search-forward "^   \\* " nil t)
103           (replace-match "\f\n* ")))
104       (save-excursion
105         (while (re-search-forward "^        \\* " nil t)
106           (replace-match "** ")))
107       (save-excursion
108         (while (re-search-forward "^     " nil t)
109           (replace-match "")))
110       ;; Avoid `*' from @ref at beginning of line:
111       (save-excursion
112         (while (re-search-forward "^\\*Note" nil t)
113           (replace-match " \\&")))
114       (goto-char (point-min))
115       (insert gnus-news-header-disclaimer)
116       (goto-char (point-max))
117       (insert gnus-news-trailer)
118       (write-region (point-min) (point-max) outfile))))
119
120 ;;; arch-tag: e23cdd27-eafd-4ba0-816f-98f5edb0dc29
121 ;;; gnus-news.el ends here