1 ;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
2 ;; Copyright (C) 2004, 2005, 2006 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, or (at your option)
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; 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.
28 (defvar gnus-news-header-disclaimer
29 "GNUS NEWS -- history of user-visible changes.
31 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,
32 2006, 2007 Free Software Foundation, Inc.
33 See the end of the file for license conditions.
35 Please send Gnus bug reports to bugs@gnus.org.
36 For older news, see Gnus info node \"New Features\".\n\n")
38 (defvar gnus-news-trailer
40 * For older news, see Gnus info node \"New Features\".
42 ----------------------------------------------------------------------
44 This file is part of GNU Emacs.
46 GNU Emacs is free software; you can redistribute it and/or modify
47 it under the terms of the GNU General Public License as published by
48 the Free Software Foundation; either version 3, or (at your option)
51 GNU Emacs is distributed in the hope that it will be useful,
52 but WITHOUT ANY WARRANTY; without even the implied warranty of
53 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 GNU General Public License for more details.
56 You should have received a copy of the GNU General Public License
57 along with GNU Emacs; see the file COPYING. If not, write to the
58 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
59 Boston, MA 02110-1301, USA.
61 \f\nLocal variables:\nmode: outline
62 paragraph-separate: \"[ \f]*$\"\nend:\n")
64 (defvar gnus-news-makeinfo-command
"makeinfo")
66 (defvar gnus-news-fill-column
80)
68 (defvar gnus-news-makeinfo-switches
69 (concat " --no-headers --paragraph-indent=0"
70 " --no-validate" ;; Allow unresolved references.
71 " --fill-column=" (number-to-string
72 (+ 3 ;; will strip leading spaces later
73 (or gnus-news-fill-column
80)))))
75 (defun batch-gnus-news ()
76 "Make GNUS-NEWS in batch mode."
78 (setq infile
(car command-line-args-left
)
79 command-line-args-left
(cdr command-line-args-left
)
80 outfile
(car command-line-args-left
)
81 command-line-args-left nil
)
82 (if (and infile outfile
)
83 (message "Creating `%s' from `%s'..." outfile infile
)
84 (error "Not enough files given."))
85 (gnus-news-translate-file infile outfile
)))
87 (defun gnus-news-translate-file (infile outfile
)
88 "Translate INFILE (texinfo) to OUTFILE (GNUS-NEWS)."
89 (let* ((dir (concat (or (getenv "srcdir") ".") "/"))
90 (infile (concat dir infile
))
91 (buffer (find-file-noselect (concat dir outfile
))))
93 ;; Could be done using `texinfmt' stuff as in `infohack.el'.
95 (shell-command-to-string
96 (concat gnus-news-makeinfo-command
" "
97 gnus-news-makeinfo-switches
" " infile
)))
98 (goto-char (point-max))
100 (goto-char (point-min))
102 (while (re-search-forward "^ \\* " nil t
)
103 (replace-match "\f\n* ")))
105 (while (re-search-forward "^ \\* " nil t
)
106 (replace-match "** ")))
108 (while (re-search-forward "^ " nil t
)
110 ;; Avoid `*' from @ref at beginning of line:
112 (while (re-search-forward "^\\*Note" nil t
)
113 (replace-match " \\&")))
114 (goto-char (point-min))
115 (insert gnus-news-header-disclaimer
)
116 (goto-char (point-max))
117 (insert gnus-news-trailer
)
118 (write-region (point-min) (point-max) outfile
))))
120 ;;; arch-tag: e23cdd27-eafd-4ba0-816f-98f5edb0dc29
121 ;;; gnus-news.el ends here