Mercurial > emacs
annotate lisp/gnus/nnslashdot.el @ 65888:6706ae85af7d
Add arch tagline
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 07 Oct 2005 06:46:05 +0000 |
parents | fafd692d1e40 |
children | 9082bf778ad8 2d92f5c9d6ae |
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, |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
4 ;; 2005 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 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
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 | |
145 "<a name=\"\\([0-9]+\\)\"><\\(b\\|H4\\)>\\([^<]+\\)</\\(b\\|H4\\)>.*score:\\([^)]+\\))" | |
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) |
31717 | 148 subject (match-string 3) |
149 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
|
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))))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
155 (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
|
156 (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
|
157 (cond |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
158 ((looking-at |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
159 "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
|
160 (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
|
161 (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
|
162 (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
|
163 " <" (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
|
164 ((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
|
165 (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
|
166 (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
|
167 (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
|
168 " <" (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
|
169 ((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
|
170 (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
|
171 (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
|
172 (t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
173 (setq from ""))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
174 (search-forward "on ") |
31717 | 175 (setq date |
176 (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
|
177 (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
|
178 (setq lines (/ (abs (- (search-forward "<td") |
31717 | 179 (search-forward "</td>"))) |
180 70)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
181 (if (not |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
182 (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
|
183 (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
|
184 (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
|
185 (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
|
186 (setq parent nil))) |
31717 | 187 (push |
188 (cons | |
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 (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
|
191 article |
31717 | 192 (concat subject " (" score ")") |
193 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
|
194 (concat "<" sid "%" cid "@slashdot>") |
31717 | 195 (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
|
196 (concat "<" sid "%" parent "@slashdot>") |
31717 | 197 "") |
198 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
|
199 headers) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
200 (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
|
201 (pop articles)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
202 (setq article (1+ article))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
203 (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
|
204 (progn |
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 startats)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
206 (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
|
207 (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
|
208 (if changed (nnslashdot-write-groups)) |
31717 | 209 (setq nnslashdot-headers (sort headers 'car-less-than-car)) |
210 (save-excursion | |
211 (set-buffer nntp-server-buffer) | |
212 (erase-buffer) | |
213 (mm-with-unibyte-current-buffer | |
214 (dolist (header nnslashdot-headers) | |
215 (nnheader-insert-nov (cdr header))))) | |
216 'nov)) | |
217 | |
218 (deffoo nnslashdot-request-group (group &optional server dont-check) | |
219 (nnslashdot-possibly-change-server nil server) | |
220 (let ((elem (assoc group nnslashdot-groups))) | |
221 (cond | |
222 ((not elem) | |
223 (nnheader-report 'nnslashdot "Group does not exist")) | |
224 (t | |
225 (nnheader-report 'nnslashdot "Opened group %s" group) | |
226 (nnheader-insert | |
227 "211 %d %d %d %s\n" (cadr elem) 1 (cadr elem) | |
228 (prin1-to-string group)))))) | |
229 | |
230 (deffoo nnslashdot-close-group (group &optional server) | |
231 (nnslashdot-possibly-change-server group server) | |
232 (when (gnus-buffer-live-p nnslashdot-buffer) | |
233 (save-excursion | |
234 (set-buffer nnslashdot-buffer) | |
235 (kill-buffer nnslashdot-buffer))) | |
236 t) | |
237 | |
238 (deffoo nnslashdot-request-article (article &optional group server buffer) | |
239 (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
|
240 (let (contents cid) |
31717 | 241 (condition-case why |
242 (save-excursion | |
243 (set-buffer nnslashdot-buffer) | |
244 (let ((case-fold-search t)) | |
245 (goto-char (point-min)) | |
246 (when (and (stringp article) | |
247 (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
|
248 (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
|
249 (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
|
250 (while map |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
251 (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
|
252 (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
|
253 map nil) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
254 (setq map (cdr map)))))) |
31717 | 255 (when (numberp article) |
256 (if (= article 1) | |
257 (progn | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
258 (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
|
259 "Posted by") |
31717 | 260 (search-forward "<BR>") |
261 (setq contents | |
262 (buffer-substring | |
263 (point) | |
264 (progn | |
265 (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
|
266 "<IFRAME\\|<SCRIPT LANGUAGE=\"JAVASCRIPT\">\\|<!-- no ad 6 -->\\|< [ \t\r\n]*<A HREF=\"\\(\\(http:\\)?//slashdot\\.org\\)?/article") |
31717 | 267 (match-beginning 0))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
40542
diff
changeset
|
268 (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
|
269 (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
|
270 (search-forward (format "<a name=\"%s\">" cid)) |
31717 | 271 (setq contents |
272 (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
|
273 (re-search-forward "<td[^>]*>") |
31717 | 274 (search-forward "</td>"))))))) |
275 (search-failed (nnslashdot-lose why))) | |
276 | |
277 (when contents | |
278 (save-excursion | |
279 (set-buffer (or buffer nntp-server-buffer)) | |
280 (erase-buffer) | |
281 (mm-with-unibyte-current-buffer | |
282 (insert contents) | |
283 (goto-char (point-min)) | |
284 (while (re-search-forward "\\(<br>\r?\\)+" nil t) | |
285 (replace-match "<p>" t t)) | |
286 (goto-char (point-min)) | |
287 (insert "Content-Type: text/html\nMIME-Version: 1.0\n") | |
288 (insert "Newsgroups: " (caddr (assoc group nnslashdot-groups)) | |
289 "\n") | |
290 (let ((header (cdr (assq article nnslashdot-headers)))) | |
291 (nnheader-insert-header header)) | |
292 (nnheader-report 'nnslashdot "Fetched article %s" article)) | |
293 (cons group article))))) | |
294 | |
295 (deffoo nnslashdot-close-server (&optional server) | |
296 (when (and (nnslashdot-server-opened server) | |
297 (gnus-buffer-live-p nnslashdot-buffer)) | |
298 (save-excursion | |
299 (set-buffer nnslashdot-buffer) | |
300 (kill-buffer nnslashdot-buffer))) | |
301 (nnoo-close-server 'nnslashdot server)) | |
302 | |
303 (deffoo nnslashdot-request-list (&optional server) | |
304 (nnslashdot-possibly-change-server nil server) | |
305 (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
|
306 (first nnslashdot-use-front-page) |
31717 | 307 sid elem description articles gname) |
308 (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
|
309 ;; 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
|
310 (progn |
31717 | 311 (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
|
312 (mm-url-insert nnslashdot-backslash-url t) |
31717 | 313 (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
|
314 (if (eobp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
315 (error "Couldn't open connection to slashdot")) |
31717 | 316 (while (search-forward "<story>" nil t) |
317 (narrow-to-region (point) (search-forward "</story>")) | |
318 (goto-char (point-min)) | |
319 (re-search-forward "<title>\\([^<]+\\)</title>") | |
320 (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
|
321 (mm-url-decode-entities-string (match-string 1))) |
31717 | 322 (re-search-forward "<url>\\([^<]+\\)</url>") |
323 (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
|
324 (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
|
325 (setq sid (match-string 1 sid)) |
31717 | 326 (re-search-forward "<comments>\\([^<]+\\)</comments>") |
327 (setq articles (string-to-number (match-string 1))) | |
328 (setq gname (concat description " (" sid ")")) | |
329 (if (setq elem (assoc gname nnslashdot-groups)) | |
330 (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
|
331 (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
|
332 nnslashdot-groups)) |
31717 | 333 (goto-char (point-max)) |
334 (widen))) | |
335 ;; 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
|
336 (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
|
337 (> (- 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
|
338 (setq first nil) |
31717 | 339 (mm-with-unibyte-buffer |
340 (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
|
341 (mm-url-insert (format nnslashdot-active-url number) t) |
31717 | 342 (goto-char (point-min)) |
343 (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
|
344 "article.pl\\?sid=\\([^&]+\\).*>\\([^<]+\\)</a>" |
31717 | 345 nil t) |
346 (setq sid (match-string 1) | |
347 description | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
348 (mm-url-decode-entities-string (match-string 2))) |
31717 | 349 (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
|
350 (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
|
351 (setq articles (1+ (string-to-number (match-string 1))))) |
31717 | 352 (setq gname (concat description " (" sid ")")) |
353 (if (setq elem (assoc gname nnslashdot-groups)) | |
354 (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
|
355 (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
|
356 nnslashdot-groups))))) |
31717 | 357 (incf number 30))) |
358 (search-failed (nnslashdot-lose why))) | |
359 (nnslashdot-write-groups) | |
360 (nnslashdot-generate-active) | |
361 t)) | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
362 |
31717 | 363 (deffoo nnslashdot-request-newgroups (date &optional server) |
364 (nnslashdot-possibly-change-server nil server) | |
365 (nnslashdot-generate-active) | |
366 t) | |
367 | |
368 (deffoo nnslashdot-request-post (&optional server) | |
369 (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
|
370 (let ((sid (message-fetch-field "newsgroups")) |
31717 | 371 (subject (message-fetch-field "subject")) |
372 (references (car (last (split-string | |
373 (message-fetch-field "references"))))) | |
374 body quoted pid) | |
375 (string-match "%\\([0-9]+\\)@slashdot" references) | |
376 (setq pid (match-string 1 references)) | |
377 (message-goto-body) | |
378 (narrow-to-region (point) (progn (message-goto-signature) (point))) | |
379 (goto-char (point-min)) | |
380 (while (not (eobp)) | |
381 (if (looking-at "> ") | |
382 (progn | |
383 (delete-region (point) (+ (point) 2)) | |
384 (unless quoted | |
385 (insert "<blockquote>\n")) | |
386 (setq quoted t)) | |
387 (when quoted | |
388 (insert "</blockquote>\n") | |
389 (setq quoted nil))) | |
390 (forward-line 1)) | |
391 (goto-char (point-min)) | |
392 (while (re-search-forward "^ *\n" nil t) | |
393 (replace-match "<p>\n")) | |
394 (widen) | |
395 (when (message-goto-signature) | |
396 (forward-line -1) | |
397 (insert "<p>\n") | |
398 (while (not (eobp)) | |
399 (end-of-line) | |
400 (insert "<br>") | |
401 (forward-line 1))) | |
402 (message-goto-body) | |
403 (setq body (buffer-substring (point) (point-max))) | |
404 (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
|
405 (mm-url-fetch-form |
31717 | 406 "http://slashdot.org/comments.pl" |
407 `(("sid" . ,sid) | |
408 ("pid" . ,pid) | |
409 ("rlogin" . "userlogin") | |
410 ("unickname" . ,nnslashdot-login-name) | |
411 ("upasswd" . ,nnslashdot-password) | |
412 ("postersubj" . ,subject) | |
413 ("op" . "Submit") | |
414 ("postercomment" . ,body) | |
415 ("posttype" . "html"))))) | |
416 | |
417 (deffoo nnslashdot-request-delete-group (group &optional force server) | |
418 (nnslashdot-possibly-change-server group server) | |
419 (setq nnslashdot-groups (delq (assoc group nnslashdot-groups) | |
420 nnslashdot-groups)) | |
421 (nnslashdot-write-groups)) | |
422 | |
423 (deffoo nnslashdot-request-close () | |
424 (setq nnslashdot-headers nil | |
425 nnslashdot-groups nil)) | |
426 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
427 (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
|
428 (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
|
429 (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
|
430 (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
|
431 (when item |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
432 (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
|
433 (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
|
434 (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
|
435 group |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
436 (fourth item) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
437 force)) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
438 (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
|
439 (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
|
440 (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
|
441 (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
|
442 (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
|
443 articles) |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
444 |
31717 | 445 (nnoo-define-skeleton nnslashdot) |
446 | |
447 ;;; Internal functions | |
448 | |
449 (defun nnslashdot-possibly-change-server (&optional group server) | |
450 (nnslashdot-init server) | |
451 (when (and server | |
452 (not (nnslashdot-server-opened server))) | |
453 (nnslashdot-open-server server)) | |
454 (unless nnslashdot-groups | |
455 (nnslashdot-read-groups))) | |
456 | |
40542
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
457 (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
|
458 (prog1 |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
459 tuple |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
460 (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
|
461 (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
|
462 (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
|
463 (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
|
464 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
|
465 |
31717 | 466 (defun nnslashdot-read-groups () |
467 (let ((file (expand-file-name "groups" nnslashdot-directory))) | |
468 (when (file-exists-p file) | |
469 (mm-with-unibyte-buffer | |
470 (insert-file-contents file) | |
471 (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
|
472 (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
|
473 (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
|
474 (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
|
475 (while groups |
93f6c74a2f60
* mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
476 (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
|
477 (setq groups (cdr groups)))))))) |
31717 | 478 |
479 (defun nnslashdot-write-groups () | |
480 (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
|
481 (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
|
482 |
31717 | 483 (defun nnslashdot-init (server) |
484 "Initialize buffers and such." | |
485 (unless (file-exists-p nnslashdot-directory) | |
486 (gnus-make-directory nnslashdot-directory)) | |
487 (unless (gnus-buffer-live-p nnslashdot-buffer) | |
488 (setq nnslashdot-buffer | |
489 (save-excursion | |
490 (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
|
491 (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
|
492 (push nnslashdot-buffer gnus-buffers))) |
31717 | 493 |
494 (defun nnslashdot-date-to-date (sdate) | |
495 (condition-case err | |
496 (let ((elem (delete "" (split-string sdate)))) | |
497 (concat (substring (nth 0 elem) 0 3) " " | |
498 (substring (nth 1 elem) 0 3) " " | |
499 (substring (nth 2 elem) 0 2) " " | |
500 (substring (nth 3 elem) 1 6) " " | |
501 (format-time-string "%Y") " " | |
502 (nth 4 elem))) | |
503 (error ""))) | |
504 | |
505 (defun nnslashdot-generate-active () | |
506 (save-excursion | |
507 (set-buffer nntp-server-buffer) | |
508 (erase-buffer) | |
509 (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
|
510 (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
|
511 (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
|
512 " " (number-to-string (cadr elem)) " 1 y\n"))))) |
31717 | 513 |
514 (defun nnslashdot-lose (why) | |
515 (error "Slashdot HTML has changed; please get a new version of nnslashdot")) | |
516 | |
517 (provide 'nnslashdot) | |
518 | |
52401 | 519 ;;; arch-tag: aa73df7a-f7e6-4eef-bdea-5ce2f8c691b3 |
31717 | 520 ;;; nnslashdot.el ends here |