Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / nnrss.el
index 204e31f..9581e0f 100644 (file)
@@ -1,5 +1,5 @@
 ;;; nnrss.el --- interfacing with RSS
-;; Copyright (C) 2001  Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002  Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: RSS
@@ -39,7 +39,6 @@
 (eval-when-compile
   (ignore-errors
     (require 'xml)))
-;; Report failure to find w3 at load time if appropriate.
 (eval '(require 'xml))
 
 (nnoo-declare nnrss)
@@ -174,6 +173,12 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
   "Field name used for URL.
 To use the description in headers, put this name into `nnmail-extra-headers'.")
 
+(defvar nnrss-content-function nil
+  "A function which is called in `nnrss-request-article'.
+The arguments are (ENTRY GROUP ARTICLE).
+ENTRY is the record of the current headline. GROUP is the group name.
+ARTICLE is the article number of the current headline.")
+
 (nnoo-define-basics nnrss)
 
 ;;; Interface functions
@@ -265,7 +270,9 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
                (insert "\n\n")
                (fill-region point (point))))
          (if (nth 2 e)
-             (insert (nth 2 e) "\n")))))
+             (insert (nth 2 e) "\n"))
+         (if nnrss-content-function
+             (funcall nnrss-content-function e group article)))))
     (cond
      (err
       (nnheader-report 'nnrss err))
@@ -371,6 +378,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
     (when (file-exists-p file)
       (with-temp-buffer
        (let ((coding-system-for-read 'binary)
+             (input-coding-system 'binary)
              emacs-lisp-mode-hook)
          (insert-file-contents file)
          (emacs-lisp-mode)
@@ -387,8 +395,12 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
                        server ".el"))
               nnrss-directory)))
     (let ((coding-system-for-write 'binary)
+         (output-coding-system 'binary)
          print-level print-length)
       (with-temp-file file
+       (insert "(setq nnrss-group-alist '"
+               (prin1-to-string nnrss-group-alist)
+               ")\n")
        (insert "(setq nnrss-server-data '"
                (prin1-to-string nnrss-server-data)
                ")\n")))))
@@ -409,6 +421,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
     (when (file-exists-p file)
       (with-temp-buffer
        (let ((coding-system-for-read 'binary)
+             (input-coding-system 'binary)
              emacs-lisp-mode-hook)
          (insert-file-contents file)
          (emacs-lisp-mode)
@@ -431,6 +444,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
                        server ".el"))
               nnrss-directory)))
     (let ((coding-system-for-write 'binary)
+         (output-coding-system 'binary)
          print-level print-length)
       (with-temp-file file
        (insert "(setq nnrss-group-data '"
@@ -449,7 +463,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
 (defun nnrss-decode-entities-unibyte-string (string)
   (mm-with-unibyte-buffer
     (insert string)
-    (mm-url-decode-entities)
+    (mm-url-decode-entities-nbsp)
     (buffer-substring (point-min) (point-max))))
 
 (defalias 'nnrss-insert 'nnrss-insert-w3)
@@ -461,8 +475,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
 ;;; Snarf functions
 
 (defun nnrss-check-group (group server)
-  (let ((mm-url-html-entities (cons '(nbsp . 32) mm-url-html-entities))
-       file xml subject url extra changed author date)
+  (let (file xml subject url extra changed author date)
     (condition-case err
        (mm-with-unibyte-buffer
          (if (and nnrss-use-local
@@ -492,8 +505,9 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
       (error
        (nnheader-message 1 "Error in group %s: %s" group (cadr err))))
     (while (and xml (not (assq 'item xml)))
-      (unless (listp (car (setq xml (cddar xml))))
-       (setq xml nil)))
+      (setq xml (cddar xml))
+      (while (not (listp (car xml)))
+       (setq xml (cdr xml))))
     (dolist (item (nreverse xml))
       (when (and (listp item)
                 (eq 'item (car item))
@@ -572,13 +586,8 @@ It is useful when `(setq nnrss-use-local t)'."
     (if changed
        (nnrss-save-server-data ""))))
 
-(defun nnrss-replace-in-string (string match newtext)
-  (while (string-match match string)
-    (setq string (replace-match newtext t t string)))
-  string)
-
 (defun nnrss-format-string (string)
-  (nnrss-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
+  (gnus-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
 
 (defun nnrss-node-text (node)
   (if (and node (listp node))