From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/19401 Path: main.gmane.org!not-for-mail From: Dale Hagglund Newsgroups: gmane.emacs.gnus.general Subject: Re: can't mark articles reached with `^' Date: 30 Nov 1998 16:45:28 -0800 Sender: owner-ding@hpc.uh.edu Message-ID: <86ww4czo47.fsf@ponoka.battleriver.com> References: <86lnkt0zz0.fsf@ponoka.battleriver.com> <86g1b029gk.fsf@ponoka.battleriver.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035157757 11404 80.91.224.250 (20 Oct 2002 23:49:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 23:49:17 +0000 (UTC) Return-Path: Original-Received: from karazm.math.uh.edu (karazm.math.uh.edu [129.7.128.1]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id TAA02914 for ; Mon, 30 Nov 1998 19:51:02 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by karazm.math.uh.edu (8.9.1/8.9.1) with ESMTP id SAB08489; Mon, 30 Nov 1998 18:50:48 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 30 Nov 1998 18:50:30 -0600 (CST) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.7.3/8.7.3) with ESMTP id SAA14210 for ; Mon, 30 Nov 1998 18:50:20 -0600 (CST) Original-Received: from proxy3.ba.best.com (root@proxy3.ba.best.com [206.184.139.14]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id TAA02892 for ; Mon, 30 Nov 1998 19:50:12 -0500 (EST) Original-Received: from best.com (dynamic22.pm01.pleasanton.best.com [204.156.131.22]) by proxy3.ba.best.com (8.9.0/8.9.0/best.out) with ESMTP id QAA12933 for ; Mon, 30 Nov 1998 16:45:32 -0800 (PST) Original-Received: (from rdh@localhost) by best.com (8.8.5/8.8.5) id QAA03209; Mon, 30 Nov 1998 16:45:29 -0800 (PST) Original-To: ding@gnus.org In-Reply-To: Lars Magne Ingebrigtsen's message of "01 Dec 1998 00:36:39 +0100" Original-Lines: 175 User-Agent: Gnus/5.070051 (Pterodactyl Gnus v0.51) Emacs/20.3 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:19401 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:19401 This is a MIME multipart message. If you are reading this, you shouldn't. --=-=-= Lars Magne Ingebrigtsen writes: > Dale Hagglund writes: > > But, isn't the article number in the Xref header information? > This is what Gnus does. (Well -- it's what Gnus is supposed to do, > but bugs have been known to exist here and there.) I've been poking around a bit in nntp.el, and I see what you're talking about, in `nntp-find-group-and-number'. However, the code only maps from article number to group name, not vice versa, which is needed when you've fetched an article via message-id. Here's a patch for 0.51 that fixes the problem, at least for me. Basically, I pass a `prefgroups' parameter that's used to choose the desired newsgroup when more than one is on the Newsgroups line. Then, if either newsgroup name or article number is unknown, I look it up from the Xref line using the known value. There's rather more comments than usual, but I needed them to keep it all straight in my head . . . . Dale. --=-=-= *** /usr/home/rdh/emacs/pgnus-0.51/lisp/nntp.el.orig Mon Nov 30 13:32:24 1998 --- /usr/home/rdh/emacs/pgnus-0.51/lisp/nntp.el Mon Nov 30 16:16:58 1998 *************** *** 633,640 **** (save-excursion (set-buffer nntp-server-buffer) (copy-to-buffer buffer (point-min) (point-max)) ! (nntp-find-group-and-number)) ! (nntp-find-group-and-number)))) (deffoo nntp-request-head (article &optional group server) (nntp-possibly-change-group group server) --- 633,640 ---- (save-excursion (set-buffer nntp-server-buffer) (copy-to-buffer buffer (point-min) (point-max)) ! (nntp-find-group-and-number group)) ! (nntp-find-group-and-number group)))) (deffoo nntp-request-head (article &optional group server) (nntp-possibly-change-group group server) *************** *** 642,648 **** "\r?\n\\.\r?\n" "HEAD" (if (numberp article) (int-to-string article) article)) (prog1 ! (nntp-find-group-and-number) (nntp-decode-text)))) (deffoo nntp-request-body (article &optional group server) --- 642,648 ---- "\r?\n\\.\r?\n" "HEAD" (if (numberp article) (int-to-string article) article)) (prog1 ! (nntp-find-group-and-number group) (nntp-decode-text)))) (deffoo nntp-request-body (article &optional group server) *************** *** 1235,1277 **** (delete-region (point-min) (point)) proc))) ! (defun nntp-find-group-and-number () (save-excursion (save-restriction (set-buffer nntp-server-buffer) (narrow-to-region (goto-char (point-min)) (or (search-forward "\n\n" nil t) (point-max))) (goto-char (point-min)) ! ;; We first find the number by looking at the status line. ! (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ") ! (string-to-int ! (buffer-substring (match-beginning 1) ! (match-end 1))))) ! group newsgroups xref) (and number (zerop number) (setq number nil)) ! ;; Then we find the group name. ! (setq group ! (cond ! ;; If there is only one group in the Newsgroups header, ! ;; then it seems quite likely that this article comes ! ;; from that group, I'd say. ! ((and (setq newsgroups (mail-fetch-field "newsgroups")) ! (not (string-match "," newsgroups))) ! newsgroups) ! ;; If there is more than one group in the Newsgroups ! ;; header, then the Xref header should be filled out. ! ;; We hazard a guess that the group that has this ! ;; article number in the Xref header is the one we are ! ;; looking for. This might very well be wrong if this ! ;; article happens to have the same number in several ! ;; groups, but that's life. ! ((and (setq xref (mail-fetch-field "xref")) ! number ! (string-match (format "\\([^ :]+\\):%d" number) xref)) ! (substring xref (match-beginning 1) (match-end 1))) ! (t ""))) (when (string-match "\r" group) (setq group (substring group 0 (match-beginning 0)))) (cons group number))))) (provide 'nntp) --- 1235,1297 ---- (delete-region (point-min) (point)) proc))) ! (defun nntp-find-group-and-number (prefgroup) ! ;; Fetch group name and number from article header. If PREFGROUP is ! ;; non-nil, choose PREFGROUP as the group, if it shows up in the ! ;; Newsgroups header. (save-excursion (save-restriction (set-buffer nntp-server-buffer) (narrow-to-region (goto-char (point-min)) (or (search-forward "\n\n" nil t) (point-max))) (goto-char (point-min)) ! (let ((number ! ;; Make a guess at article number by looking at the ! ;; status line. ! (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ") ! (string-to-int ! (buffer-substring (match-beginning 1) ! (match-end 1))))) ! (newsgroups (mail-fetch-field "newsgroups")) ! (xref (mail-fetch-field "xref")) ! group) ! ;; Reset number to nil of the server reported article `0'. (and number (zerop number) (setq number nil)) ! ;; Make first guess at right newsgroup. ! (cond ! ;; If there's no Newsgroup header, we don't know yet. ! ((not newsgroups)) ! ;; If there's just a single newsgroup, use it. ! ((not (string-match "," newsgroups)) ! (setq group newsgroups)) ! ;; If `prefgroup' is found in the list of newsgroups, use it. ! ((and (stringp prefgroup) ! (string-match ! (concat "\\<" (regexp-quote prefgroup) "\\>") ! newsgroups)) ! (setq group prefgroup) ! ;; Force article number to be looked up from the Xref header ! ;; later, so that group name and article number will be ! ;; consistent. If there's no Xref header, leave the article ! ;; number alone and hope for the best. ! (and xref (setq number nil)))) ! ;; If we don't know the article number, look in the Xref ! ;; header for the article number associated with the known ! ;; group name. ! (when (and xref group (not number)) ! (string-match (format "%s:\\([0-9]+\\)" (regexp-quote group)) xref) ! (setq number (substring xref (match-beginning 1) (match-end 1)))) ! ;; If we don't know the group, look in the Xref header for the ! ;; group name associated with the known article number. ! (when (and xref number (not group)) ! (string-match (format "\\([^ :]+\\):%d" number) xref) ! (setq group (substring xref (match-beginning 1) (match-end 1)))) ! ;; If we haven't figured out the group yet, just use the empty ! ;; string. Clean up the group name, if necessary ! (setq group (or group "")) (when (string-match "\r" group) (setq group (substring group 0 (match-beginning 0)))) + ;; Cons up the result. (cons group number))))) (provide 'nntp) --=-=-=--