(mm-codepage-setup): New helper function.
[gnus] / lisp / nnsoup.el
index 306235b..e64b93a 100644 (file)
@@ -1,10 +1,10 @@
 ;;; nnsoup.el --- SOUP access for Gnus
 
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
-;;     Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
-;;     Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
+;;     Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
 ;; Keywords: news, mail
 
 ;; This file is part of GNU Emacs.
@@ -21,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -114,7 +114,7 @@ backend for the messages.")
        ;; articles in SEQUENCE come from.
        (while (and areas sequence)
          ;; Peel off areas that are below sequence.
-         (while (and areas (< (cdaar areas) (car sequence)))
+         (while (and areas (< (cdar (car areas)) (car sequence)))
            (setq areas (cdr areas)))
          (when areas
            ;; This is a useful area.
@@ -130,7 +130,7 @@ backend for the messages.")
              (setq use-nov nil))
            ;; We assign the portion of `sequence' that is relevant to
            ;; this MSG packet to this packet.
-           (while (and sequence (<= (car sequence) (cdaar areas)))
+           (while (and sequence (<= (car sequence) (cdar (car areas))))
              (push (car sequence) this-area-seq)
              (setq sequence (cdr sequence)))
            (setcar useful-areas (cons (nreverse this-area-seq)
@@ -158,7 +158,7 @@ backend for the messages.")
                  (when index-buffer
                    (insert-buffer-substring index-buffer)
                    (goto-char b)
-                   ;; We have to remove the index number entires and
+                   ;; We have to remove the index number entries and
                    ;; insert article numbers instead.
                    (while (looking-at "[0-9]+")
                      (replace-match (int-to-string number) t t)
@@ -249,7 +249,7 @@ backend for the messages.")
   ;; Try to guess the type based on the first article in the group.
   (when (not article)
     (setq article
-         (cdaar (cddr (assoc group nnsoup-group-alist)))))
+         (cdar (car (cddr (assoc group nnsoup-group-alist))))))
   (if (not article)
       'unknown
     (let ((kind (gnus-soup-encoding-kind
@@ -369,9 +369,7 @@ backend for the messages.")
            entry e min max)
        (while (setq e (cdr (setq entry (pop alist))))
          (setq min (caaar e))
-         (while (cdr e)
-           (setq e (cdr e)))
-         (setq max (cdaar e))
+         (setq max (cdar (car (last e))))
          (setcdr entry (cons (cons min max) (cdr entry)))))
       (setq nnsoup-group-alist-touched t))
     nnsoup-group-alist))
@@ -399,7 +397,7 @@ backend for the messages.")
     prefix))
 
 (defun nnsoup-file-name (dir file)
-  "Return the full path of FILE (in any case) in DIR."
+  "Return the full name of FILE (in any case) in DIR."
   (let* ((case-fold-search t)
         (files (directory-files dir t))
         (regexp (concat (regexp-quote file) "$")))
@@ -556,9 +554,8 @@ backend for the messages.")
 (defun nnsoup-unpack-packets ()
   "Unpack all packets in `nnsoup-packet-directory'."
   (let ((packets (directory-files
-                 nnsoup-packet-directory t nnsoup-packet-regexp))
-       packet)
-    (while (setq packet (pop packets))
+                 nnsoup-packet-directory t nnsoup-packet-regexp)))
+    (dolist (packet packets)
       (nnheader-message 5 "nnsoup: unpacking %s..." packet)
       (if (not (gnus-soup-unpack-packet
                nnsoup-tmp-directory nnsoup-unpacker packet))
@@ -651,7 +648,7 @@ backend for the messages.")
 (defun nnsoup-article-to-area (article group)
   "Return the area that ARTICLE in GROUP is located in."
   (let ((areas (cddr (assoc group nnsoup-group-alist))))
-    (while (and areas (< (cdaar areas) article))
+    (while (and areas (< (cdar (car areas)) article))
       (setq areas (cdr areas)))
     (and areas (car areas))))
 
@@ -752,25 +749,23 @@ backend for the messages.")
   (let ((files (sort (directory-files nnsoup-directory t "IDX$")
                     (lambda (f1 f2)
                       (< (progn (string-match "/\\([0-9]+\\)\\." f1)
-                                (string-to-int (match-string 1 f1)))
+                                (string-to-number (match-string 1 f1)))
                          (progn (string-match "/\\([0-9]+\\)\\." f2)
-                                (string-to-int (match-string 1 f2)))))))
+                                (string-to-number (match-string 1 f2)))))))
        active group lines ident elem min)
     (set-buffer (get-buffer-create " *nnsoup work*"))
-    (while files
-      (nnheader-message 5 "Doing %s..." (car files))
+    (dolist (file files)
+      (nnheader-message 5 "Doing %s..." file)
       (erase-buffer)
-      (nnheader-insert-file-contents (car files))
+      (nnheader-insert-file-contents file)
       (goto-char (point-min))
       (if (not (re-search-forward "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t *\\(Xref: \\)? *[^ ]* \\([^ ]+\\):[0-9]" nil t))
          (setq group "unknown")
        (setq group (match-string 2)))
       (setq lines (count-lines (point-min) (point-max)))
       (setq ident (progn (string-match
-                         "/\\([0-9]+\\)\\." (car files))
-                        (substring
-                         (car files) (match-beginning 1)
-                         (match-end 1))))
+                         "/\\([0-9]+\\)\\." file)
+                        (match-string 1 file)))
       (if (not (setq elem (assoc group active)))
          (push (list group (cons 1 lines)
                      (list (cons 1 lines)
@@ -781,8 +776,7 @@ backend for the messages.")
                (list (cons (1+ (setq min (cdadr elem)))
                            (+ min lines))
                      (vector ident group "ucm" "" lines))))
-       (setcdr (cadr elem) (+ min lines)))
-      (setq files (cdr files)))
+       (setcdr (cadr elem) (+ min lines))))
     (nnheader-message 5 "")
     (setq nnsoup-group-alist active)
     (nnsoup-write-active-file t)))
@@ -799,9 +793,9 @@ backend for the messages.")
                               nnsoup-group-alist)))
         (regexp "\\.MSG$\\|\\.IDX$")
         (files (directory-files nnsoup-directory nil regexp))
-        non-files file)
+        non-files)
     ;; Find all files that aren't known by nnsoup.
-    (while (setq file (pop files))
+    (dolist (file files)
       (string-match regexp file)
       (unless (member (substring file 0 (match-beginning 0)) known)
        (push file non-files)))
@@ -814,4 +808,5 @@ backend for the messages.")
 
 (provide 'nnsoup)
 
+;;; arch-tag: b0451389-5703-4450-9425-f66f6b38c828
 ;;; nnsoup.el ends here