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