From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/27202 Path: main.gmane.org!not-for-mail From: Eric Marsden Newsgroups: gmane.emacs.gnus.general Subject: Re: problem with nnslashdot Date: 24 Nov 1999 17:31:38 +0100 Organization: LAAS-CNRS http://www.laas.fr/ Sender: owner-ding@hpc.uh.edu Message-ID: References: <19991124152115.41502.qmail@hotmail.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1035164270 23347 80.91.224.250 (21 Oct 2002 01:37:50 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:37:50 +0000 (UTC) Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id LAA22225 for ; Wed, 24 Nov 1999 11:33:46 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id KAB18226; Wed, 24 Nov 1999 10:33:01 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 24 Nov 1999 10:33:11 -0600 (CST) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id KAA14952 for ; Wed, 24 Nov 1999 10:32:55 -0600 (CST) Original-Received: from laas.laas.fr (root@laas.laas.fr [140.93.0.15]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id LAA22203 for ; Wed, 24 Nov 1999 11:31:52 -0500 (EST) Original-Received: from dukas.laas.fr (dukas [140.93.21.58]) by laas.laas.fr (8.9.3/8.9.3) with ESMTP id RAA21930 for ; Wed, 24 Nov 1999 17:31:40 +0100 (MET) Original-Received: (from emarsden@localhost) by dukas.laas.fr (8.9.3/8.9.3) id RAA25098; Wed, 24 Nov 1999 17:31:39 +0100 (MET) Original-To: ding@gnus.org X-Eric-Conspiracy: there is no conspiracy X-Attribution: ecm X-URL: http://www.chez.com/emarsden/ In-Reply-To: "Sorgum Vargus"'s message of "Wed, 24 Nov 1999 10:21:15 EST" Original-Lines: 212 X-Mailer: Gnus v5.7/Emacs 20.4 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:27202 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:27202 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 - "

.*A href=http://slashdot.org/article.pl") - (match-beginning 0))))) - (search-forward (format "" (1- article))) - (setq contents - (buffer-substring - (re-search-forward "]+>") - (search-forward ""))))))) + (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 + "

.*A href=http://slashdot.org/article.pl") + (match-beginning 0))))) + (search-forward (format "" (1- article))) + (setq contents + (buffer-substring + (re-search-forward "]+>") + (search-forward ""))))))) + (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 "" nil t) - (narrow-to-region (point) (search-forward "")) - (goto-char (point-min)) - (re-search-forward "\\([^<]+\\)") - (setq description (match-string 1)) - (re-search-forward "\\([^<]+\\)") - (setq sid (match-string 1)) - (string-match "/\\([0-9/]+\\).shtml" sid) - (setq sid (match-string 1 sid)) - (re-search-forward "\\([^<]+\\)") - (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=\\([^&]+\\).*\\([^<]+\\)" nil t) - (setq sid (match-string 1) - description (match-string 2)) - (forward-line 1) - (when (re-search-forward "\\([0-9]+\\)" 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 "" nil t) + (narrow-to-region (point) (search-forward "")) + (goto-char (point-min)) + (re-search-forward "\\([^<]+\\)") + (setq description (match-string 1)) + (re-search-forward "\\([^<]+\\)") + (setq sid (match-string 1)) + (string-match "/\\([0-9/]+\\).shtml" sid) + (setq sid (match-string 1 sid)) + (re-search-forward "\\([^<]+\\)") + (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=\\([^&]+\\).*\\([^<]+\\)" nil t) + (setq sid (match-string 1) + description (match-string 2)) + (forward-line 1) + (when (re-search-forward "\\([0-9]+\\)" 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)