1 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
2 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 ;; Author: Reiner Steib <Reiner.Steib@gmx.de>
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/>.
26 (defvar gnus-news-header-disclaimer
27 "GNUS NEWS -- history of user-visible changes.
29 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
30 2006, 2007, 2008 Free Software Foundation, Inc.
31 See the end of the file for license conditions.
33 Please send Gnus bug reports to bugs@gnus.org.
34 For older news, see Gnus info node \"New Features\".\n\n")
36 (defvar gnus-news-trailer
38 * For older news, see Gnus info node \"New Features\".
40 ----------------------------------------------------------------------
42 This file is part of GNU Emacs.
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.
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.
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/>.
57 \f\nLocal variables:\nmode: outline
58 paragraph-separate: \"[ \f]*$\"\nend:\n")
60 (defvar gnus-news-makeinfo-command
"makeinfo")
62 (defvar gnus-news-fill-column
80)
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)))))
71 (defun batch-gnus-news ()
72 "Make GNUS-NEWS in batch mode."
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
)))
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
))))
89 ;; Could be done using `texinfmt' stuff as in `infohack.el'.
91 (shell-command-to-string
92 (concat gnus-news-makeinfo-command
" "
93 gnus-news-makeinfo-switches
" " infile
)))
94 (goto-char (point-max))
96 (goto-char (point-min))
98 (while (re-search-forward "^ \\* " nil t
)
99 (replace-match "\f\n* ")))
101 (while (re-search-forward "^ \\* " nil t
)
102 (replace-match "** ")))
104 (while (re-search-forward "^ " nil t
)
106 ;; Avoid `*' from @ref at beginning of line:
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
))))
116 ;; arch-tag: e23cdd27-eafd-4ba0-816f-98f5edb0dc29
117 ;;; gnus-news.el ends here