gnus-news.el 3.9 KB

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