Update Copyright.
[gnus] / texi / gnus-news.el
1 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
2 ;; Copyright (C)  2004, 2005  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 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 \f
37 * Changes in No Gnus
38
39 ")
40
41 (defvar gnus-news-trailer
42 "\f
43 * For older news, see Gnus info node \"New Features\".
44
45 ----------------------------------------------------------------------
46 Copyright information:
47
48 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
49
50    Permission is granted to anyone to make or distribute verbatim copies
51    of this document as received, in any medium, provided that the
52    copyright notice and this permission notice are preserved,
53    thus giving the recipient permission to redistribute in turn.
54
55    Permission is granted to distribute modified versions
56    of this document, or of portions of it,
57    under the above conditions, provided also that they
58    carry prominent notices stating who last changed them.
59 \f\nLocal variables:\nmode: outline
60 paragraph-separate: \"[         \f]*$\"\nend:\n")
61
62 (defvar gnus-news-makeinfo-command "makeinfo")
63
64 (defvar gnus-news-fill-column 72)
65
66 (defvar gnus-news-makeinfo-switches
67   (concat " --no-headers --paragraph-indent=0"
68           " --no-validate" ;; Allow unresolved references.
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       ;; Avoid `*' from @ref at beginning of line:
100       (save-excursion
101         (while (re-search-forward "^\\*Note" nil t)
102           (replace-match " \\&")))
103       (save-excursion
104         (while (re-search-forward "^   \\* " nil t)
105           (replace-match "** ")))
106       (save-excursion
107         (while (re-search-forward "^     " nil t)
108           (replace-match "")))
109       (goto-char (point-min))
110       (insert gnus-news-header-disclaimer)
111       (goto-char (point-max))
112       (insert gnus-news-trailer)
113       (write-region (point-min) (point-max) outfile))))
114
115 ;;; arch-tag: e23cdd27-eafd-4ba0-816f-98f5edb0dc29
116 ;;; gnus-news.el ends here