*** /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)