From: Eric Marsden <emarsden@mail.dotcom.fr>
Subject: Re: problem with nnslashdot
Date: 24 Nov 1999 17:31:38 +0100 [thread overview]
Message-ID: <wzin1s3x34l.fsf@mail.dotcom.fr> (raw)
In-Reply-To: "Sorgum Vargus"'s message of "Wed, 24 Nov 1999 10:21:15 EST"
To protect against changes in the slashdot HTML, I think it would be
useful to use `condition-case' to trap `search-failed' errors.
--- nnslashdot.el.orig Sat Nov 20 17:05:39 1999
+++ nnslashdot.el Wed Nov 24 17:26:59 1999
@@ -90,10 +90,12 @@
(deffoo nnslashdot-retrieve-headers (articles &optional group server fetch-old)
(nnslashdot-possibly-change-server group server)
- (unless gnus-nov-is-evil
- (if nnslashdot-threaded
- (nnslashdot-threaded-retrieve-headers articles group)
- (nnslashdot-sane-retrieve-headers articles group))))
+ (condition-case why
+ (unless gnus-nov-is-evil
+ (if nnslashdot-threaded
+ (nnslashdot-threaded-retrieve-headers articles group)
+ (nnslashdot-sane-retrieve-headers articles group)))
+ (search-failed (nnslashdot-lose why))))
(deffoo nnslashdot-threaded-retrieve-headers (articles group)
(let ((last (car (last articles)))
@@ -310,47 +312,49 @@
(deffoo nnslashdot-request-article (article &optional group server buffer)
(nnslashdot-possibly-change-server group server)
(let (contents)
- (save-excursion
- (set-buffer nnslashdot-buffer)
- (let ((case-fold-search t))
- (goto-char (point-min))
- (when (and (stringp article)
- (string-match "%\\([0-9]+\\)@" article))
- (setq article (string-to-number (match-string 1 article))))
- (when (numberp article)
- (if (= article 1)
- (progn
- (re-search-forward "Posted by .* on ")
- (forward-line 1)
- (setq contents
- (buffer-substring
- (point)
- (progn
- (re-search-forward
- "<p>.*A href=http://slashdot.org/article.pl")
- (match-beginning 0)))))
- (search-forward (format "<a name=\"%d\">" (1- article)))
- (setq contents
- (buffer-substring
- (re-search-forward "<td[^>]+>")
- (search-forward "</td>")))))))
+ (condition-case why
+ (save-excursion
+ (set-buffer nnslashdot-buffer)
+ (let ((case-fold-search t))
+ (goto-char (point-min))
+ (when (and (stringp article)
+ (string-match "%\\([0-9]+\\)@" article))
+ (setq article (string-to-number (match-string 1 article))))
+ (when (numberp article)
+ (if (= article 1)
+ (progn
+ (re-search-forward "Posted by .* on ")
+ (forward-line 1)
+ (setq contents
+ (buffer-substring
+ (point)
+ (progn
+ (re-search-forward
+ "<p>.*A href=http://slashdot.org/article.pl")
+ (match-beginning 0)))))
+ (search-forward (format "<a name=\"%d\">" (1- article)))
+ (setq contents
+ (buffer-substring
+ (re-search-forward "<td[^>]+>")
+ (search-forward "</td>")))))))
+ (search-failed (nnslashdot-lose why)))
(when contents
(save-excursion
- (set-buffer (or buffer nntp-server-buffer))
- (erase-buffer)
- (insert contents)
- (goto-char (point-min))
- (insert "Content-Type: text/html\nMIME-Version: 1.0\n")
- (insert "Newsgroups: " (caddr (assoc group nnslashdot-groups))
- "\n")
- (let ((header (cdr (assq article nnslashdot-headers))))
- (nnheader-insert-header header))
- (nnheader-report 'nnslashdot "Fetched article %s" article)
- (cons group article)))))
+ (set-buffer (or buffer nntp-server-buffer))
+ (erase-buffer)
+ (insert contents)
+ (goto-char (point-min))
+ (insert "Content-Type: text/html\nMIME-Version: 1.0\n")
+ (insert "Newsgroups: " (caddr (assoc group nnslashdot-groups))
+ "\n")
+ (let ((header (cdr (assq article nnslashdot-headers))))
+ (nnheader-insert-header header))
+ (nnheader-report 'nnslashdot "Fetched article %s" article)
+ (cons group article)))))
(deffoo nnslashdot-close-server (&optional server)
(when (and (nnslashdot-server-opened server)
- (gnus-buffer-live-p nnslashdot-buffer))
+ (gnus-buffer-live-p nnslashdot-buffer))
(save-excursion
(set-buffer nnslashdot-buffer)
(kill-buffer nnslashdot-buffer)))
@@ -360,49 +364,51 @@
(nnslashdot-possibly-change-server nil server)
(let ((number 0)
sid elem description articles gname)
- ;; First we do the Ultramode to get info on all the latest groups.
- (with-temp-buffer
- (nnweb-insert "http://slashdot.org/slashdot.xml")
- (goto-char (point-min))
- (while (search-forward "<story>" nil t)
- (narrow-to-region (point) (search-forward "</story>"))
- (goto-char (point-min))
- (re-search-forward "<title>\\([^<]+\\)</title>")
- (setq description (match-string 1))
- (re-search-forward "<url>\\([^<]+\\)</url>")
- (setq sid (match-string 1))
- (string-match "/\\([0-9/]+\\).shtml" sid)
- (setq sid (match-string 1 sid))
- (re-search-forward "<comments>\\([^<]+\\)</comments>")
- (setq articles (string-to-number (match-string 1)))
- (setq gname (concat description " (" sid ")"))
- (if (setq elem (assoc gname nnslashdot-groups))
- (setcar (cdr elem) articles)
- (push (list gname articles sid) nnslashdot-groups))
- (goto-char (point-max))
- (widen)))
- ;; Then do the older groups.
- (while (> (- nnslashdot-group-number number) 0)
- (with-temp-buffer
- (let ((case-fold-search t))
- (nnweb-insert (format nnslashdot-active-url number))
- (goto-char (point-min))
- (while (re-search-forward
- "article.pl\\?sid=\\([^&]+\\).*<b>\\([^<]+\\)</b>" nil t)
- (setq sid (match-string 1)
- description (match-string 2))
- (forward-line 1)
- (when (re-search-forward "<b>\\([0-9]+\\)</b>" nil t)
- (setq articles (string-to-number (match-string 1))))
- (setq gname (concat description " (" sid ")"))
- (if (setq elem (assoc gname nnslashdot-groups))
- (setcar (cdr elem) articles)
- (push (list gname articles sid) nnslashdot-groups)))))
- (incf number 30))
+ (condition-case why
+ ;; First we do the Ultramode to get info on all the latest groups.
+ (with-temp-buffer
+ (nnweb-insert "http://slashdot.org/slashdot.xml")
+ (goto-char (point-min))
+ (while (search-forward "<story>" nil t)
+ (narrow-to-region (point) (search-forward "</story>"))
+ (goto-char (point-min))
+ (re-search-forward "<title>\\([^<]+\\)</title>")
+ (setq description (match-string 1))
+ (re-search-forward "<url>\\([^<]+\\)</url>")
+ (setq sid (match-string 1))
+ (string-match "/\\([0-9/]+\\).shtml" sid)
+ (setq sid (match-string 1 sid))
+ (re-search-forward "<comments>\\([^<]+\\)</comments>")
+ (setq articles (string-to-number (match-string 1)))
+ (setq gname (concat description " (" sid ")"))
+ (if (setq elem (assoc gname nnslashdot-groups))
+ (setcar (cdr elem) articles)
+ (push (list gname articles sid) nnslashdot-groups))
+ (goto-char (point-max))
+ (widen)))
+ ;; Then do the older groups.
+ (while (> (- nnslashdot-group-number number) 0)
+ (with-temp-buffer
+ (let ((case-fold-search t))
+ (nnweb-insert (format nnslashdot-active-url number))
+ (goto-char (point-min))
+ (while (re-search-forward
+ "article.pl\\?sid=\\([^&]+\\).*<b>\\([^<]+\\)</b>" nil t)
+ (setq sid (match-string 1)
+ description (match-string 2))
+ (forward-line 1)
+ (when (re-search-forward "<b>\\([0-9]+\\)</b>" nil t)
+ (setq articles (string-to-number (match-string 1))))
+ (setq gname (concat description " (" sid ")"))
+ (if (setq elem (assoc gname nnslashdot-groups))
+ (setcar (cdr elem) articles)
+ (push (list gname articles sid) nnslashdot-groups)))))
+ (incf number 30))
+ (search-failed (nnslashdot-lose why)))
(nnslashdot-write-groups)
(nnslashdot-generate-active)
t))
-
+
(deffoo nnslashdot-request-newgroups (date &optional server)
(nnslashdot-possibly-change-server nil server)
(nnslashdot-generate-active)
@@ -504,6 +510,10 @@
(dolist (elem nnslashdot-groups)
(insert (prin1-to-string (car elem))
" " (number-to-string (cadr elem)) " 1 y\n"))))
+
+(defun nnslashdot-lose (why)
+ (error "Slashdot HTML has changed; please get a new version of nnslashdot"))
+
(provide 'nnslashdot)
next prev parent reply other threads:[~1999-11-24 16:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-24 15:21 Sorgum Vargus
1999-11-24 16:31 ` Eric Marsden [this message]
1999-12-01 20:44 ` Lars Magne Ingebrigtsen
1999-12-01 20:47 ` Lars Magne Ingebrigtsen
2000-03-13 6:50 Problem " Niels Olof Bouvin
2000-03-14 0:47 ` Jack Vinson
2000-03-16 0:37 ` Jack Vinson
2000-03-16 10:11 ` Niels Olof Bouvin
2000-03-17 23:11 ` Bjorn Halvor Solberg
2000-03-16 1:31 ` Bjorn Halvor Solberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wzin1s3x34l.fsf@mail.dotcom.fr \
--to=emarsden@mail.dotcom.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).