Two new recentf.el keybindings
[emacs.git] / doc / misc / gnus-news.el
blob0c083c85a4d329fa489679fd05ebf8bcb148b2d2
1 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
2 ;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
4 ;; Author: Reiner Steib <Reiner.Steib@gmx.de>
5 ;; Keywords: tools
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
22 ;;; Commentary:
24 ;;; Code:
26 (defvar gnus-news-header-disclaimer
27 "GNUS NEWS -- history of user-visible changes.
29 Copyright (C) 1999-2012 Free Software Foundation, Inc.
30 See the end of the file for license conditions.
32 Please send Gnus bug reports to bugs@gnus.org.
33 For older news, see Gnus info node \"New Features\".\n\n")
35 (defvar gnus-news-trailer
36 "\f
37 * For older news, see Gnus info node \"New Features\".
39 ----------------------------------------------------------------------
41 This file is part of GNU Emacs.
43 GNU Emacs is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
45 the Free Software Foundation, either version 3 of the License, or
46 \(at your option) any later version.
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.
53 You should have received a copy of the GNU General Public License
54 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
56 \f\nLocal variables:\nmode: outline
57 paragraph-separate: \"[ \f]*$\"\nend:\n")
59 (defvar gnus-news-makeinfo-command "makeinfo")
61 (defvar gnus-news-fill-column 80)
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)))))
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)))
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))))
115 ;;; gnus-news.el ends here