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