Merge from trunk
[bpt/emacs.git] / doc / misc / gnus-news.el
CommitLineData
01c52d31 1;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
114f9c96 2;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
01c52d31
MB
3
4;; Author: Reiner Steib <Reiner.Steib@gmx.de>
5;; Keywords: tools
6
7;; This file is part of GNU Emacs.
8
97c0352c 9;; GNU Emacs is free software: you can redistribute it and/or modify
01c52d31 10;; it under the terms of the GNU General Public License as published by
97c0352c
GM
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
01c52d31
MB
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
97c0352c 20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
01c52d31
MB
21
22;;; Commentary:
23
24;;; Code:
25
26(defvar gnus-news-header-disclaimer
27"GNUS NEWS -- history of user-visible changes.
28
29Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
114f9c96 30 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
01c52d31
MB
31See the end of the file for license conditions.
32
33Please send Gnus bug reports to bugs@gnus.org.
34For 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
42This file is part of GNU Emacs.
43
97c0352c 44GNU Emacs is free software: you can redistribute it and/or modify
01c52d31 45it under the terms of the GNU General Public License as published by
97c0352c 46the Free Software Foundation, either version 3 of the License, or
ba2b460a 47\(at your option) any later version.
01c52d31
MB
48
49GNU Emacs is distributed in the hope that it will be useful,
50but WITHOUT ANY WARRANTY; without even the implied warranty of
51MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52GNU General Public License for more details.
53
54You should have received a copy of the GNU General Public License
97c0352c 55along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
01c52d31
MB
56
57\f\nLocal variables:\nmode: outline
58paragraph-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
01c52d31 116;;; gnus-news.el ends here