X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fnnwarchive.el;h=8802594cada15c140ef9fc4d2dcf3f459ac018f6;hb=ca101d0305c3ff2ecc44dade2025c974ffc7168a;hp=e48f9df39c57f7d909f9be077348d04c8d76fde2;hpb=3ad5943c4ad67b4f8d556436b31c3ca8bc4b5064;p=elisp%2Fgnus.git- diff --git a/lisp/nnwarchive.el b/lisp/nnwarchive.el index e48f9df..8802594 100644 --- a/lisp/nnwarchive.el +++ b/lisp/nnwarchive.el @@ -1,5 +1,5 @@ ;;; nnwarchive.el --- interfacing with web archives -;; Copyright (C) 1999 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. ;; Author: Shenghuo Zhu ;; Keywords: news egroups mail-archive @@ -24,9 +24,9 @@ ;;; Commentary: ;; Note: You need to have `url' (w3 0.46) or greater version -;; installed for this backend to work. +;; installed for some functions of this backend to work. -;; Todo: +;; Todo: ;; 1. To support more web archives. ;; 2. Generalize webmail to other MHonArc archive. @@ -41,39 +41,27 @@ (require 'gnus-bcklg) (require 'nnmail) (require 'mm-util) -(require 'mail-source) -(eval-when-compile - (ignore-errors - (require 'w3) - (require 'url) - (require 'w3-forms) - (require 'nnweb))) -;; Report failure to find w3 at load time if appropriate. -(eval '(progn - (require 'w3) - (require 'url) - (require 'w3-forms) - (require 'nnweb))) +(require 'mm-url) (nnoo-declare nnwarchive) (defvar nnwarchive-type-definition '((egroups (address . "www.egroups.com") - (open-url - "http://www.egroups.com/login.cgi?&login_email=%s&login_password=%s" + (open-url + "http://www.egroups.com/login.cgi?&login_email=%s&login_password=%s" nnwarchive-login nnwarchive-passwd) - (list-url + (list-url "http://www.egroups.com/mygroups") (list-dissect . nnwarchive-egroups-list) (list-groups . nnwarchive-egroups-list-groups) - (xover-url - "http://www.egroups.com/message/%s/%d" group aux) - (xover-last-url - "http://www.egroups.com/message/%s/" group) + (xover-url + "http://www.egroups.com/messages/%s/%d" group aux) + (xover-last-url + "http://www.egroups.com/messages/%s/" group) (xover-page-size . 13) (xover-dissect . nnwarchive-egroups-xover) - (article-url + (article-url "http://www.egroups.com/message/%s/%d?source=1" group article) (article-dissect . nnwarchive-egroups-article) (authentication . t) @@ -82,17 +70,17 @@ (mail-archive (address . "www.mail-archive.com") (open-url) - (list-url + (list-url "http://www.mail-archive.com/lists.html") (list-dissect . nnwarchive-mail-archive-list) (list-groups . nnwarchive-mail-archive-list-groups) - (xover-url + (xover-url "http://www.mail-archive.com/%s/mail%d.html" group aux) - (xover-last-url + (xover-last-url "http://www.mail-archive.com/%s/maillist.html" group) (xover-page-size) (xover-dissect . nnwarchive-mail-archive-xover) - (article-url + (article-url "http://www.mail-archive.com/%s/msg%05d.html" group article1) (article-dissect . nnwarchive-mail-archive-article) (xover-files . nnwarchive-mail-archive-xover-files) @@ -163,12 +151,12 @@ (let ((defs (cdr (assq type nnwarchive-type-definition))) def) (dolist (def defs) - (set (intern (concat "nnwarchive-" (symbol-name (car def)))) + (set (intern (concat "nnwarchive-" (symbol-name (car def)))) (cdr def))))) (defmacro nnwarchive-backlog (&rest form) `(let ((gnus-keep-backlog nnwarchive-keep-backlog) - (gnus-backlog-buffer + (gnus-backlog-buffer (format " *nnwarchive backlog %s*" nnwarchive-address)) (gnus-backlog-articles nnwarchive-backlog-articles) (gnus-backlog-hashtb nnwarchive-backlog-hashtb)) @@ -183,10 +171,10 @@ (nnwarchive-backlog (gnus-backlog-enter-article group number buffer))) -(defun nnwarchive-get-article (article &optional group server buffer) +(defun nnwarchive-get-article (article &optional group server buffer) (if (numberp article) (if (nnwarchive-backlog - (gnus-backlog-request-article group article + (gnus-backlog-request-article group article (or buffer nntp-server-buffer))) (cons group article) (let (contents) @@ -297,8 +285,8 @@ user-mail-address))) (setq nnwarchive-passwd (or nnwarchive-passwd - (mail-source-read-passwd - (format "Password for %s at %s: " + (read-passwd + (format "Password for %s at %s: " nnwarchive-login server))))) (unless nnwarchive-groups (nnwarchive-read-groups)) @@ -322,7 +310,7 @@ (nnwarchive-open-server server))) (defun nnwarchive-read-groups () - (let ((file (expand-file-name (concat "groups-" nnwarchive-address) + (let ((file (expand-file-name (concat "groups-" nnwarchive-address) nnwarchive-directory))) (when (file-exists-p file) (with-temp-buffer @@ -331,14 +319,14 @@ (setq nnwarchive-groups (read (current-buffer))))))) (defun nnwarchive-write-groups () - (with-temp-file (expand-file-name (concat "groups-" nnwarchive-address) + (with-temp-file (expand-file-name (concat "groups-" nnwarchive-address) nnwarchive-directory) (prin1 nnwarchive-groups (current-buffer)))) (defun nnwarchive-init (server) "Initialize buffers and such." (let ((type (intern server)) (defs nnwarchive-type-definition) def) - (cond + (cond ((equal server "") (setq type nnwarchive-default-type)) ((assq type nnwarchive-type-definition) t) @@ -360,23 +348,6 @@ (format " *nnwarchive %s %s*" nnwarchive-type server))))) (nnwarchive-set-default nnwarchive-type)) -(defun nnwarchive-encode-www-form-urlencoded (pairs) - "Return PAIRS encoded for forms." - (mapconcat - (function - (lambda (data) - (concat (w3-form-encode-xwfu (car data)) "=" - (w3-form-encode-xwfu (cdr data))))) - pairs "&")) - -(defun nnwarchive-fetch-form (url pairs) - (let ((url-request-data (nnwarchive-encode-www-form-urlencoded pairs)) - (url-request-method "POST") - (url-request-extra-headers - '(("Content-type" . "application/x-www-form-urlencoded")))) - (nnweb-insert url)) - t) - (defun nnwarchive-eval (expr) (cond ((consp expr) @@ -388,15 +359,15 @@ (defun nnwarchive-url (xurl) (mm-with-unibyte-current-buffer - (let ((url-confirmation-func 'identity) + (let ((url-confirmation-func 'identity) ;; Some hacks. (url-cookie-multiple-line nil)) - (cond + (cond ((eq (car xurl) 'post) (pop xurl) - (nnwarchive-fetch-form (car xurl) (nnwarchive-eval (cdr xurl)))) + (mm-url-fetch-form (car xurl) (nnwarchive-eval (cdr xurl)))) (t - (nnweb-insert (apply 'format (nnwarchive-eval xurl)))))))) - + (mm-url-insert (apply 'format (nnwarchive-eval xurl)))))))) + (defun nnwarchive-generate-active () (save-excursion (set-buffer nntp-server-buffer) @@ -420,12 +391,12 @@ (save-excursion (let (articles) (set-buffer nnwarchive-buffer) - (dolist (group groups) + (dolist (group groups) (erase-buffer) (nnwarchive-url nnwarchive-xover-last-url) (goto-char (point-min)) (when (re-search-forward "of \\([0-9]+\\)[ \t\n\r]*" nil t) - (setq articles (string-to-number (match-string 1)))) + (setq articles (string-to-number (match-string 1)))) (let ((elem (assoc group nnwarchive-groups))) (if elem (setcar (cdr elem) articles) @@ -441,7 +412,7 @@ (let ((case-fold-search t) group description elem articles) (goto-char (point-min)) - (while + (while (re-search-forward "href=\"/group/\\([^/\"\> ]+\\)" nil t) (setq group (match-string 1) description (match-string 2)) @@ -469,12 +440,12 @@ (push (cons article (make-full-mail-header - article - (nnweb-decode-entities-string subject) - (nnweb-decode-entities-string from) + article + (mm-url-decode-entities-string subject) + (mm-url-decode-entities-string from) date (concat "<" group "%" - (number-to-string article) + (number-to-string article) "@egroup.com>") "" 0 0 "")) nnwarchive-headers)))) @@ -489,8 +460,8 @@ (delete-region (point) (point-max))) (goto-char (point-min)) (while (re-search-forward "]+>\\([^<]+\\)" nil t) - (replace-match "<\\1>")) - (nnweb-decode-entities) + (replace-match "\\1")) + (mm-url-decode-entities) (buffer-string)) (defun nnwarchive-egroups-xover-files (group articles) @@ -523,7 +494,7 @@ (let ((elem (assoc group nnwarchive-headers-cache))) (if elem (setcdr elem nnwarchive-headers) - (push (cons group nnwarchive-headers) + (push (cons group nnwarchive-headers) nnwarchive-headers-cache))))))) (defun nnwarchive-mail-archive-list () @@ -550,7 +521,7 @@ subject (match-string 2)) (forward-line 1) (unless (assq article nnwarchive-headers) - (if (looking-at "