PageRenderTime 22ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/incoming/news-hack.el

https://github.com/emacsmirror/ohio-archive
Emacs Lisp | 236 lines | 134 code | 32 blank | 70 comment | 5 complexity | fa1867deff0ed21dc634c8daf49e4a65 MD5 | raw file
  1. ;;; news-hack.el --- create newsrc buffers for foreign groups
  2. ;; This file is not part of GNU Emacs
  3. ;; This is released under the GNU Public License
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation; either version 2, or (at your option)
  7. ;; any later version.
  8. ;;
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with this GNU Emacs; if not, write to the Free Software
  16. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ;;; This is poorly documented, and is likely to stay that way for the
  18. ;; forseeable future. Any help appreciated.
  19. ;; Mail me for help, with comments etc. I like getting mail (that is
  20. ;; actually to me, spam I can't stand.)
  21. ;; Instructions i) Run netscape-news-create-newsrc-buffers
  22. ;; ii) Save the buffers
  23. ;; This uses *a lot* of recursive functions. If you get errors, you may need
  24. ;; to increase max-lisp-eval-depth to something higher.
  25. ;; Put
  26. ;; (setq max-lisp-eval-depth 10000)
  27. ;; in your .emacs file. (Replace 10000 with some larger number if necessary)
  28. ;; "Author": gowen+usenet@ma.man.ac.uk
  29. ;; URL : http://www.ma.man.ac.uk/~gowen/lisp/
  30. ;;; Bugs
  31. ;;
  32. ;; If your local server is called `dribble' it won't work, since
  33. ;; `.newsrc-dribble' is a special buffer in gnus.
  34. ;;
  35. (defvar netscape-news-nuke-buffers t
  36. "Should netscape-news-create-newsrc-buffers overwrite existing buffers?")
  37. (defun netscape-news-parse (newsrc-tmp)
  38. "Do all that jazz."
  39. (if newsrc-tmp
  40. (progn
  41. (let (newsrc-list-element)
  42. (setq newsrc-list-element (car newsrc-tmp))
  43. (let (select-method)
  44. (progn
  45. (setq
  46. select-method (car (cdr (cdr (cdr (cdr newsrc-list-element))))))
  47. (if select-method
  48. (netscape-news-write-buffer
  49. newsrc-list-element select-method))
  50. (netscape-news-parse (cdr newsrc-tmp))))))))
  51. (defun netscape-news-write-buffer (list-element method)
  52. "Write newsrc style entries into a suitably named buffer."
  53. (let ((name (concat ".newsrc-" (car (cdr method)))))
  54. (get-buffer-create name)
  55. (set-buffer name)
  56. (insert-string
  57. (concat (netscape-news-get-group-name (car list-element)) ": "
  58. (netscape-news-get-read-string (car (cdr (cdr list-element))))))))
  59. (defun netscape-news-get-group-name (string)
  60. "Return newsgroup name from a previously found foreign group name."
  61. (string-match "[^:]*$" string)
  62. (match-string 0 string))
  63. (defun netscape-news-get-read-string (read-list)
  64. "Convert the read list into a string for newsrc-files."
  65. (let (read-string)
  66. (while read-list
  67. (if (listp (car read-list))
  68. (setq read-string
  69. (concat read-string
  70. (car (car read-list)) "-" (cdr (car read-list)) ","))
  71. ;; else
  72. (setq read-string (concat read-string (car read-list) ",")))
  73. (setq read-list (cdr read-list)))
  74. (concat read-string "\n")))
  75. (defun netscape-news-create-newsrc-buffers ()
  76. "Parse the variable gnus-newsrc-alist and create buffers with .newsrc files."
  77. (interactive)
  78. (netscape-news-nuke-newsrc-buffers)
  79. (netscape-news-parse gnus-newsrc-alist))
  80. (defun netscape-news-nuke-newsrc-buffers ()
  81. "Delete the present contents of all .newsrc buffers"
  82. (let ((buffers (buffer-list)))
  83. (while buffers
  84. (if (and (string-match ".newsrc-"(buffer-name (car buffers)))
  85. (not (string-match ".newsrc-dribble"
  86. (buffer-name (car buffers)))))
  87. (netscape-news-nuke-this-buffer (car buffers)))
  88. (setq buffers (cdr buffers)))))
  89. (defun netscape-news-nuke-this-buffer (buf)
  90. (set-buffer buf) (widen) (delete-region (point-min) (point-max)))
  91. Path: news.cis.ohio-state.edu!news.ems.psu.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!nntp.news.xara.net!xara.net!gxn.net!server6.netnews.ja.net!news.keele.ac.uk!not-for-mail
  92. Message-ID: <84r97s88lv.fsf@orr.maths.keele.ac.uk>
  93. From: Gareth Owen <usenet@gwowen.freeserve.co.uk>
  94. Newsgroups: gnu.emacs.sources
  95. Subject: news-hack.el --- create newsrc buffers for foreign groups
  96. Date: 14 Aug 2000 11:01:16 +0100
  97. Lines: 111
  98. Organization: Sirius Cybernetics Corp.
  99. Distribution: world
  100. NNTP-Posting-Host: orr.maths.keele.ac.uk
  101. Mime-Version: 1.0
  102. Content-Type: text/plain; charset=us-ascii
  103. X-Trace: www1.kis.keele.ac.uk 966247314 17116 160.5.82.202 (14 Aug 2000 10:01:54 GMT)
  104. X-Complaints-To: usenet@news.keele.ac.uk
  105. NNTP-Posting-Date: 14 Aug 2000 10:01:54 GMT
  106. x-no-productlinks: Yes
  107. Microsoft: Making the world a better place... for Microsoft.
  108. User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5
  109. Xref: neutral.verbum.org gnu.emacs.sources:464
  110. I upgraded to Gnus 5.8.3 and this broke, so I unbroke it again...
  111. I'm sure there must be a built in way to do this, but I don't know what it is,
  112. and this works just fine for me...
  113. ;;; news-hack.el --- create newsrc buffers for foreign groups
  114. ;; This file is not part of GNU Emacs
  115. ;; This is released under the GNU Public License
  116. ;; This program is free software; you can redistribute it and/or modify
  117. ;; it under the terms of the GNU General Public License as published by
  118. ;; the Free Software Foundation; either version 2, or (at your option)
  119. ;; any later version.
  120. ;;
  121. ;; This program is distributed in the hope that it will be useful,
  122. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  123. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  124. ;; GNU General Public License for more details.
  125. ;;
  126. ;; You should have received a copy of the GNU General Public License
  127. ;; along with this GNU Emacs; if not, write to the Free Software
  128. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  129. ;;; This is poorly documented, and is likely to stay that way for the
  130. ;; forseeable future. Any help appreciated.
  131. ;; Mail me for help, with comments etc. I like getting mail (that is
  132. ;; actually to me, spam I can't stand.)
  133. ;; Instructions i) Run netscape-news-create-newsrc-buffers
  134. ;; ii) Save the buffers
  135. ;; This uses *a lot* of recursive functions. If you get errors, you may need
  136. ;; to increase max-lisp-eval-depth to something higher.
  137. ;; Put
  138. ;; (setq max-lisp-eval-depth 10000)
  139. ;; in your .emacs file. (Replace 10000 with some larger number if necessary)
  140. ;; "Author": usenet@gwowen.freeserve.co.uk
  141. ;; URL : http://www.ma.man.ac.uk/~gowen/lisp/
  142. ;;; Bugs
  143. ;;
  144. ;; If your local server is called `dribble' it won't work, since
  145. ;; `.newsrc-dribble' is a special buffer in gnus.
  146. ;;
  147. (defvar netscape-news-nuke-buffers t
  148. "Should netscape-news-create-newsrc-buffers overwrite existing buffers?")
  149. (defun netscape-news-parse (newsrc-tmp)
  150. "Do all that jazz."
  151. (if newsrc-tmp
  152. (progn
  153. (let (newsrc-list-element)
  154. (setq newsrc-list-element (car newsrc-tmp))
  155. (let (select-method)
  156. (progn
  157. (setq
  158. select-method (car (cdr (cdr (cdr (cdr newsrc-list-element))))))
  159. (if select-method
  160. (netscape-news-write-buffer
  161. newsrc-list-element select-method))
  162. (netscape-news-parse (cdr newsrc-tmp))))))))
  163. (defun netscape-news-write-buffer (list-element method)
  164. "Write newsrc style entries into a suitably named buffer."
  165. (let ((name (concat ".newsrc-"
  166. (if (listp method) (car (cdr method))
  167. method))))
  168. (get-buffer-create name)
  169. (set-buffer name)
  170. (insert-string
  171. (concat (netscape-news-get-group-name (car list-element)) ": "
  172. (netscape-news-get-read-string (car (cdr (cdr list-element))))))))
  173. (defun netscape-news-get-group-name (string)
  174. "Return newsgroup name from a previously found foreign group name."
  175. (string-match "[^:]*$" string)
  176. (match-string 0 string))
  177. (defun netscape-news-get-read-string (read-list)
  178. "Convert the read list into a string for newsrc-files."
  179. (let (read-string)
  180. (while read-list
  181. (if (listp (car read-list))
  182. (setq read-string
  183. (concat read-string
  184. (car (car read-list)) "-" (cdr (car read-list)) ","))
  185. ;; else
  186. (setq read-string (concat read-string (car read-list) ",")))
  187. (setq read-list (cdr read-list)))
  188. (concat read-string "\n")))
  189. (defun netscape-news-create-newsrc-buffers ()
  190. "Parse the variable gnus-newsrc-alist and create buffers with .newsrc files."
  191. (interactive)
  192. (netscape-news-nuke-newsrc-buffers)
  193. (netscape-news-parse gnus-newsrc-alist))
  194. (defun netscape-news-nuke-newsrc-buffers ()
  195. "Delete the present contents of all .newsrc buffers"
  196. (let ((buffers (buffer-list)))
  197. (while buffers
  198. (if (and (string-match ".newsrc-"(buffer-name (car buffers)))
  199. (not (string-match ".newsrc-dribble"
  200. (buffer-name (car buffers)))))
  201. (netscape-news-nuke-this-buffer (car buffers)))
  202. (setq buffers (cdr buffers)))))
  203. (defun netscape-news-nuke-this-buffer (buf)
  204. (set-buffer buf) (widen) (delete-region (point-min) (point-max)))