Mercurial > emacs
annotate lisp/gnus/nnslashdot.el @ 90400:80fff33f74f5
New file.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 06 Jun 2006 03:47:13 +0000 |
parents | c156f6a9e7b5 |
children | b5c13d1564a9 |
rev | line source |
---|---|
31717 | 1 ;;; nnslashdot.el --- interfacing with Slashdot |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
68633
1077b8039c32
Update copyright notices of all files in the gnus directory.
Romain Francoise <romain@orebokech.com>
parents:
66454
diff
changeset
|
4 ;; 2005, 2006 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
7 ;; Keywords: news | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31717 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
30 (eval-when-compile (require 'cl)) | |
31 | |
32 (require 'nnoo) | |
33 (require 'message) | |
34 (require 'gnus-util) | |
35 (require 'gnus) | |
36 (require 'nnmail) | |
37 (require 'mm-util) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
38 (require 'mm-url) |
31717 | 39 |
40 (nnoo-declare nnslashdot) | |
41 | |
42 (defvoo nnslashdot-directory (nnheader-concat gnus-directory "slashdot/") | |
43 "Where nnslashdot will save its files.") | |
44 | |
45 (defvoo nnslashdot-active-url "http://slashdot.org/search.pl?section=&min=%d" | |
46 "Where nnslashdot will fetch the active file from.") | |
47 | |
48 (defvoo nnslashdot-comments-url "http://slashdot.org/comments.pl?sid=%s&threshold=%d&commentsort=%d&mode=flat&startat=%d" | |
49 "Where nnslashdot will fetch comments from.") | |
50 | |
51 (defvoo nnslashdot-article-url | |
52 "http://slashdot.org/article.pl?sid=%s&mode=nocomment" | |
53 "Where nnslashdot will fetch the article from.") | |
54 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
55 (defvoo nnslashdot-backslash-url "http://slashdot.org/slashdot.xml" |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
56 "Where nnslashdot will fetch the stories from.") |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
57 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
58 (defvoo nnslashdot-use-front-page nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
59 "Use the front page in addition to the backslash page.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
60 |
31717 | 61 (defvoo nnslashdot-threshold -1 |
62 "The article threshold.") | |
63 | |
64 (defvoo nnslashdot-threaded t | |
65 "Whether the nnslashdot groups should be threaded or not.") | |
66 | |
67 (defvoo nnslashdot-group-number 0 | |
68 "The number of non-fresh groups to keep updated.") | |
69 | |
70 (defvoo nnslashdot-login-name "" | |
71 "The login name to use when posting.") | |
72 | |
73 (defvoo nnslashdot-password "" | |
74 "The password to use when posting.") | |
75 | |
76 ;;; Internal variables | |
77 | |
78 (defvar nnslashdot-groups nil) | |
79 (defvar nnslashdot-buffer nil) | |
80 (defvar nnslashdot-headers nil) | |
81 | |
82 ;;; Interface functions | |
83 | |
84 (nnoo-define-basics nnslashdot) | |
85 | |
86 (deffoo nnslashdot-retrieve-headers (articles &optional group server fetch-old) | |
87 (nnslashdot-possibly-change-server group server) | |
88 (condition-case why | |
89 (unless gnus-nov-is-evil | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
90 (nnslashdot-retrieve-headers-1 articles group)) |
31717 | 91 (search-failed (nnslashdot-lose why)))) |
92 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
93 (deffoo nnslashdot-retrieve-headers-1 (articles group) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
94 (let* ((last (car (last articles))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
95 (start (if nnslashdot-threaded 1 (pop articles))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
96 (entry (assoc group nnslashdot-groups)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
97 (sid (nth 2 entry)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
98 (first-comments t) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
99 headers article subject score from date lines parent point cid |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
100 s startats changed) |
31717 | 101 (save-excursion |
102 (set-buffer nnslashdot-buffer) | |
103 (let ((case-fold-search t)) | |
104 (erase-buffer) | |
105 (when (= start 1) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
106 (mm-url-insert (format nnslashdot-article-url sid) t) |
31717 | 107 (goto-char (point-min)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
108 (if (eobp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
109 (error "Couldn't open connection to slashdot")) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
110 (re-search-forward "Posted by[ \t\r\n]+") |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
111 (when (looking-at "\\(<a[^>]+>\\)?[ \t\r\n]*\\([^<\r\n]+\\)") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
112 (setq from (mm-url-decode-entities-string (match-string 2)))) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
113 (search-forward "on ") |
31717 | 114 (setq date (nnslashdot-date-to-date |
115 (buffer-substring (point) (1- (search-forward "<"))))) | |
116 (setq lines (/ (- (point) | |
117 (progn (forward-line 1) (point))) | |
118 60)) | |
119 (push | |
120 (cons | |
121 1 | |
122 (make-full-mail-header | |
123 1 group from date | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
124 (concat "<" sid "%1@slashdot>") |
31717 | 125 "" 0 lines nil nil)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
126 headers) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
127 (setq start (if nnslashdot-threaded 2 (pop articles)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
128 (while (and start (<= start last)) |
31717 | 129 (setq point (goto-char (point-max))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
130 (mm-url-insert |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
131 (format nnslashdot-comments-url sid |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
132 nnslashdot-threshold 0 (- start 2)) |
31717 | 133 t) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
134 (when (and nnslashdot-threaded first-comments) |
31717 | 135 (setq first-comments nil) |
136 (goto-char (point-max)) | |
137 (while (re-search-backward "startat=\\([0-9]+\\)" nil t) | |
138 (setq s (string-to-number (match-string 1))) | |
139 (unless (memq s startats) | |
140 (push s startats))) | |
141 (setq startats (sort startats '<))) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
142 (setq article (if (and article (< start article)) article start)) |
31717 | 143 (goto-char point) |
144 (while (re-search-forward | |
69944
a87e26272828
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-210
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
145 "<a name=\"\\([0-9]+\\)\">\\([^<]+\\)</a>.*\n.*\n.*score:\\([^)]+\\))" |
31717 | 146 nil t) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
147 (setq cid (match-string 1) |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
148 subject (match-string 2) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
149 score (match-string 3)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
150 (unless (assq article (nth 4 entry)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
151 (setcar (nthcdr 4 entry) (cons (cons article cid) (nth 4 entry))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
152 (setq changed t)) |
31717 | 153 (when (string-match "^Re: *" subject) |
154 (setq subject (concat "Re: " (substring subject (match-end 0))))) | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
155 (setq subject (mm-url-decode-entities-string subject) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
156 from "") |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
157 (when (re-search-forward "by[ \t\n]+<[^>]+>\\([^<(]+\\)" nil t) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
158 (setq from |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
159 (concat |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
160 (mm-url-decode-entities-string (match-string 1)) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
161 " <nobody@slashdot.org>"))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
162 (search-forward "on ") |
31717 | 163 (setq date |
164 (nnslashdot-date-to-date | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
165 (buffer-substring |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
166 (point) (progn (skip-chars-forward "^()<>\n\r") (point))))) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
167 (setq lines (/ (abs (- (search-forward "<div") |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
168 (search-forward "</div>"))) |
31717 | 169 70)) |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
170 (if (not |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
171 (re-search-forward ".*cid=\\([0-9]+\\)\">Parent</A>" nil t)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
172 (setq parent nil) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
173 (setq parent (match-string 1)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
174 (when (string= parent "0") |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
175 (setq parent nil))) |
31717 | 176 (push |
177 (cons | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
178 article |
31717 | 179 (make-full-mail-header |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
180 article |
31717 | 181 (concat subject " (" score ")") |
182 from date | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
183 (concat "<" sid "%" cid "@slashdot>") |
31717 | 184 (if parent |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
185 (concat "<" sid "%" parent "@slashdot>") |
31717 | 186 "") |
187 0 lines nil nil)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
188 headers) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
189 (while (and articles (<= (car articles) article)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
190 (pop articles)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
191 (setq article (1+ article))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
192 (if nnslashdot-threaded |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
193 (progn |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
194 (setq start (pop startats)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
195 (if start (setq start (+ start 2)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
196 (setq start (pop articles)))))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
197 (if changed (nnslashdot-write-groups)) |
31717 | 198 (setq nnslashdot-headers (sort headers 'car-less-than-car)) |
199 (save-excursion | |
200 (set-buffer nntp-server-buffer) | |
201 (erase-buffer) | |
202 (mm-with-unibyte-current-buffer | |
203 (dolist (header nnslashdot-headers) | |
204 (nnheader-insert-nov (cdr header))))) | |
205 'nov)) | |
206 | |
207 (deffoo nnslashdot-request-group (group &optional server dont-check) | |
208 (nnslashdot-possibly-change-server nil server) | |
209 (let ((elem (assoc group nnslashdot-groups))) | |
210 (cond | |
211 ((not elem) | |
212 (nnheader-report 'nnslashdot "Group does not exist")) | |
213 (t | |
214 (nnheader-report 'nnslashdot "Opened group %s" group) | |
215 (nnheader-insert | |
216 "211 %d %d %d %s\n" (cadr elem) 1 (cadr elem) | |
217 (prin1-to-string group)))))) | |
218 | |
219 (deffoo nnslashdot-close-group (group &optional server) | |
220 (nnslashdot-possibly-change-server group server) | |
221 (when (gnus-buffer-live-p nnslashdot-buffer) | |
222 (save-excursion | |
223 (set-buffer nnslashdot-buffer) | |
224 (kill-buffer nnslashdot-buffer))) | |
225 t) | |
226 | |
227 (deffoo nnslashdot-request-article (article &optional group server buffer) | |
228 (nnslashdot-possibly-change-server group server) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
229 (let (contents cid) |
31717 | 230 (condition-case why |
231 (save-excursion | |
232 (set-buffer nnslashdot-buffer) | |
233 (let ((case-fold-search t)) | |
234 (goto-char (point-min)) | |
235 (when (and (stringp article) | |
236 (string-match "%\\([0-9]+\\)@" article)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
237 (setq cid (match-string 1 article)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
238 (let ((map (nth 4 (assoc group nnslashdot-groups)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
239 (while map |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
240 (if (equal (cdar map) cid) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
241 (setq article (caar map) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
242 map nil) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
243 (setq map (cdr map)))))) |
31717 | 244 (when (numberp article) |
245 (if (= article 1) | |
246 (progn | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
247 (search-forward "Posted by") |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
248 (search-forward "<div class=\"intro\">") |
31717 | 249 (setq contents |
250 (buffer-substring | |
251 (point) | |
252 (progn | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
253 (search-forward "commentwrap") |
31717 | 254 (match-beginning 0))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
255 (setq cid (cdr (assq article |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
256 (nth 4 (assoc group nnslashdot-groups))))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
257 (search-forward (format "<a name=\"%s\">" cid)) |
31717 | 258 (setq contents |
259 (buffer-substring | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
260 (search-forward "<div class=\"commentBody\">") |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
261 (search-forward "</div>"))))))) |
31717 | 262 (search-failed (nnslashdot-lose why))) |
263 | |
264 (when contents | |
265 (save-excursion | |
266 (set-buffer (or buffer nntp-server-buffer)) | |
267 (erase-buffer) | |
268 (mm-with-unibyte-current-buffer | |
269 (insert contents) | |
270 (goto-char (point-min)) | |
271 (while (re-search-forward "\\(<br>\r?\\)+" nil t) | |
272 (replace-match "<p>" t t)) | |
273 (goto-char (point-min)) | |
274 (insert "Content-Type: text/html\nMIME-Version: 1.0\n") | |
275 (insert "Newsgroups: " (caddr (assoc group nnslashdot-groups)) | |
276 "\n") | |
277 (let ((header (cdr (assq article nnslashdot-headers)))) | |
278 (nnheader-insert-header header)) | |
279 (nnheader-report 'nnslashdot "Fetched article %s" article)) | |
280 (cons group article))))) | |
281 | |
282 (deffoo nnslashdot-close-server (&optional server) | |
283 (when (and (nnslashdot-server-opened server) | |
284 (gnus-buffer-live-p nnslashdot-buffer)) | |
285 (save-excursion | |
286 (set-buffer nnslashdot-buffer) | |
287 (kill-buffer nnslashdot-buffer))) | |
288 (nnoo-close-server 'nnslashdot server)) | |
289 | |
290 (deffoo nnslashdot-request-list (&optional server) | |
291 (nnslashdot-possibly-change-server nil server) | |
292 (let ((number 0) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
293 (first nnslashdot-use-front-page) |
31717 | 294 sid elem description articles gname) |
295 (condition-case why | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
296 ;; First we do the Ultramode to get info on all the latest groups. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
297 (progn |
31717 | 298 (mm-with-unibyte-buffer |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
299 (mm-url-insert nnslashdot-backslash-url t) |
31717 | 300 (goto-char (point-min)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
301 (if (eobp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
302 (error "Couldn't open connection to slashdot")) |
31717 | 303 (while (search-forward "<story>" nil t) |
304 (narrow-to-region (point) (search-forward "</story>")) | |
305 (goto-char (point-min)) | |
306 (re-search-forward "<title>\\([^<]+\\)</title>") | |
307 (setq description | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
308 (mm-url-decode-entities-string (match-string 1))) |
31717 | 309 (re-search-forward "<url>\\([^<]+\\)</url>") |
310 (setq sid (match-string 1)) | |
35453
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
31717
diff
changeset
|
311 (string-match "sid=\\([0-9/]+\\)\\(.shtml\\|$\\)" sid) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
31717
diff
changeset
|
312 (setq sid (match-string 1 sid)) |
31717 | 313 (re-search-forward "<comments>\\([^<]+\\)</comments>") |
314 (setq articles (string-to-number (match-string 1))) | |
315 (setq gname (concat description " (" sid ")")) | |
316 (if (setq elem (assoc gname nnslashdot-groups)) | |
317 (setcar (cdr elem) articles) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
318 (push (list gname articles sid (current-time) nil) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
319 nnslashdot-groups)) |
31717 | 320 (goto-char (point-max)) |
321 (widen))) | |
322 ;; Then do the older groups. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
323 (while (or first |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
324 (> (- nnslashdot-group-number number) 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
325 (setq first nil) |
31717 | 326 (mm-with-unibyte-buffer |
327 (let ((case-fold-search t)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
328 (mm-url-insert (format nnslashdot-active-url number) t) |
31717 | 329 (goto-char (point-min)) |
330 (while (re-search-forward | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
331 "article.pl\\?sid=\\([^&]+\\).*>\\([^<]+\\)</a>" |
31717 | 332 nil t) |
333 (setq sid (match-string 1) | |
334 description | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
335 (mm-url-decode-entities-string (match-string 2))) |
31717 | 336 (forward-line 1) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
337 (when (re-search-forward "with \\([0-9]+\\) comment" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
338 (setq articles (1+ (string-to-number (match-string 1))))) |
31717 | 339 (setq gname (concat description " (" sid ")")) |
340 (if (setq elem (assoc gname nnslashdot-groups)) | |
341 (setcar (cdr elem) articles) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
342 (push (list gname articles sid (current-time) nil) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
343 nnslashdot-groups))))) |
31717 | 344 (incf number 30))) |
345 (search-failed (nnslashdot-lose why))) | |
346 (nnslashdot-write-groups) | |
347 (nnslashdot-generate-active) | |
348 t)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
349 |
31717 | 350 (deffoo nnslashdot-request-newgroups (date &optional server) |
351 (nnslashdot-possibly-change-server nil server) | |
352 (nnslashdot-generate-active) | |
353 t) | |
354 | |
355 (deffoo nnslashdot-request-post (&optional server) | |
356 (nnslashdot-possibly-change-server nil server) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
357 (let ((sid (message-fetch-field "newsgroups")) |
31717 | 358 (subject (message-fetch-field "subject")) |
359 (references (car (last (split-string | |
360 (message-fetch-field "references"))))) | |
361 body quoted pid) | |
362 (string-match "%\\([0-9]+\\)@slashdot" references) | |
363 (setq pid (match-string 1 references)) | |
364 (message-goto-body) | |
365 (narrow-to-region (point) (progn (message-goto-signature) (point))) | |
366 (goto-char (point-min)) | |
367 (while (not (eobp)) | |
368 (if (looking-at "> ") | |
369 (progn | |
370 (delete-region (point) (+ (point) 2)) | |
371 (unless quoted | |
372 (insert "<blockquote>\n")) | |
373 (setq quoted t)) | |
374 (when quoted | |
375 (insert "</blockquote>\n") | |
376 (setq quoted nil))) | |
377 (forward-line 1)) | |
378 (goto-char (point-min)) | |
379 (while (re-search-forward "^ *\n" nil t) | |
380 (replace-match "<p>\n")) | |
381 (widen) | |
382 (when (message-goto-signature) | |
383 (forward-line -1) | |
384 (insert "<p>\n") | |
385 (while (not (eobp)) | |
386 (end-of-line) | |
387 (insert "<br>") | |
388 (forward-line 1))) | |
389 (message-goto-body) | |
390 (setq body (buffer-substring (point) (point-max))) | |
391 (erase-buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
392 (mm-url-fetch-form |
31717 | 393 "http://slashdot.org/comments.pl" |
394 `(("sid" . ,sid) | |
395 ("pid" . ,pid) | |
396 ("rlogin" . "userlogin") | |
397 ("unickname" . ,nnslashdot-login-name) | |
398 ("upasswd" . ,nnslashdot-password) | |
399 ("postersubj" . ,subject) | |
400 ("op" . "Submit") | |
401 ("postercomment" . ,body) | |
402 ("posttype" . "html"))))) | |
403 | |
404 (deffoo nnslashdot-request-delete-group (group &optional force server) | |
405 (nnslashdot-possibly-change-server group server) | |
406 (setq nnslashdot-groups (delq (assoc group nnslashdot-groups) | |
407 nnslashdot-groups)) | |
408 (nnslashdot-write-groups)) | |
409 | |
410 (deffoo nnslashdot-request-close () | |
411 (setq nnslashdot-headers nil | |
412 nnslashdot-groups nil)) | |
413 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
414 (deffoo nnslashdot-request-expire-articles |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
415 (articles group &optional server force) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
416 (nnslashdot-possibly-change-server group server) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
417 (let ((item (assoc group nnslashdot-groups))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
418 (when item |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
419 (if (fourth item) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
420 (when (and (>= (length articles) (cadr item)) ;; All are expirable. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
421 (nnmail-expired-article-p |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
422 group |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
423 (fourth item) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
424 force)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
425 (setq nnslashdot-groups (delq item nnslashdot-groups)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
426 (nnslashdot-write-groups) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
427 (setq articles nil)) ;; all expired. |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
428 (setcdr (cddr item) (list (current-time))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
429 (nnslashdot-write-groups)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
430 articles) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
431 |
31717 | 432 (nnoo-define-skeleton nnslashdot) |
433 | |
434 ;;; Internal functions | |
435 | |
436 (defun nnslashdot-possibly-change-server (&optional group server) | |
437 (nnslashdot-init server) | |
438 (when (and server | |
439 (not (nnslashdot-server-opened server))) | |
440 (nnslashdot-open-server server)) | |
441 (unless nnslashdot-groups | |
442 (nnslashdot-read-groups))) | |
443 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
444 (defun nnslashdot-make-tuple (tuple n) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
445 (prog1 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
446 tuple |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
447 (while (> n 1) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
448 (unless (cdr tuple) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
449 (setcdr tuple (list nil))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
450 (setq tuple (cdr tuple) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
451 n (1- n))))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
452 |
31717 | 453 (defun nnslashdot-read-groups () |
454 (let ((file (expand-file-name "groups" nnslashdot-directory))) | |
455 (when (file-exists-p file) | |
456 (mm-with-unibyte-buffer | |
457 (insert-file-contents file) | |
458 (goto-char (point-min)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
459 (setq nnslashdot-groups (read (current-buffer)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
460 (if (and nnslashdot-groups (< (length (car nnslashdot-groups)) 5)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
461 (let ((groups nnslashdot-groups)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
462 (while groups |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
463 (nnslashdot-make-tuple (car groups) 5) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
464 (setq groups (cdr groups)))))))) |
31717 | 465 |
466 (defun nnslashdot-write-groups () | |
467 (with-temp-file (expand-file-name "groups" nnslashdot-directory) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
468 (gnus-prin1 nnslashdot-groups))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
469 |
31717 | 470 (defun nnslashdot-init (server) |
471 "Initialize buffers and such." | |
472 (unless (file-exists-p nnslashdot-directory) | |
473 (gnus-make-directory nnslashdot-directory)) | |
474 (unless (gnus-buffer-live-p nnslashdot-buffer) | |
475 (setq nnslashdot-buffer | |
476 (save-excursion | |
477 (nnheader-set-temp-buffer | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
478 (format " *nnslashdot %s*" server)))) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
479 (push nnslashdot-buffer gnus-buffers))) |
31717 | 480 |
481 (defun nnslashdot-date-to-date (sdate) | |
482 (condition-case err | |
483 (let ((elem (delete "" (split-string sdate)))) | |
484 (concat (substring (nth 0 elem) 0 3) " " | |
485 (substring (nth 1 elem) 0 3) " " | |
486 (substring (nth 2 elem) 0 2) " " | |
487 (substring (nth 3 elem) 1 6) " " | |
488 (format-time-string "%Y") " " | |
489 (nth 4 elem))) | |
490 (error ""))) | |
491 | |
492 (defun nnslashdot-generate-active () | |
493 (save-excursion | |
494 (set-buffer nntp-server-buffer) | |
495 (erase-buffer) | |
496 (dolist (elem nnslashdot-groups) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
497 (when (numberp (cadr elem)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
498 (insert (prin1-to-string (car elem)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
499 " " (number-to-string (cadr elem)) " 1 y\n"))))) |
31717 | 500 |
501 (defun nnslashdot-lose (why) | |
502 (error "Slashdot HTML has changed; please get a new version of nnslashdot")) | |
503 | |
504 (provide 'nnslashdot) | |
505 | |
52401 | 506 ;;; arch-tag: aa73df7a-f7e6-4eef-bdea-5ce2f8c691b3 |
31717 | 507 ;;; nnslashdot.el ends here |