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