*** empty log message ***
[gnus] / lisp / nnsoup.el
index fcf2c62..8c280b5 100644 (file)
@@ -231,7 +231,7 @@ The SOUP packet file name will be inserted at the %s.")
          (nnheader-report 'nnsoup "No such group: %s" group)
        (nnheader-insert 
         "211 %d %d %d %s\n" 
-        (max (1+ (- (cdr active) (car active))) 0) 
+        (max (1+ (- (cdr active) (car active))) 0)
         (car active) (cdr active) group)))))
 
 (deffoo nnsoup-request-type (group &optional article)
@@ -310,20 +310,18 @@ The SOUP packet file name will be inserted at the %s.")
               ;; This file is old enough. 
               (nnmail-expired-article-p group mod-time force))
        ;; Ok, we delete this file.
-       (when (condition-case nil
-                 (progn
-                   (nnheader-message 
-                    5 "Deleting %s in group %s..." (nnsoup-file prefix)
-                    group)
-                   (when (file-exists-p (nnsoup-file prefix))
-                     (delete-file (nnsoup-file prefix)))
-                   (nnheader-message 
-                    5 "Deleting %s in group %s..." (nnsoup-file prefix t)
-                    group)
-                   (when (file-exists-p (nnsoup-file prefix t))
-                     (delete-file (nnsoup-file prefix t)))
-                   t)
-               (error nil))
+       (when (ignore-errors
+               (nnheader-message 
+                5 "Deleting %s in group %s..." (nnsoup-file prefix)
+                group)
+               (when (file-exists-p (nnsoup-file prefix))
+                 (delete-file (nnsoup-file prefix)))
+               (nnheader-message 
+                5 "Deleting %s in group %s..." (nnsoup-file prefix t)
+                group)
+               (when (file-exists-p (nnsoup-file prefix t))
+                 (delete-file (nnsoup-file prefix t)))
+               t)
          (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
          (setq articles (gnus-sorted-complement articles range-list))))
       (when (not mod-time)
@@ -346,9 +344,8 @@ The SOUP packet file name will be inserted at the %s.")
 (defun nnsoup-read-active-file ()
   (setq nnsoup-group-alist nil)
   (when (file-exists-p nnsoup-active-file)
-    (condition-case ()
-       (load nnsoup-active-file t t t)
-      (error nil))
+    (ignore-errors
+      (load nnsoup-active-file t t t))
     ;; Be backwards compatible.
     (when (and nnsoup-group-alist
               (not (atom (caadar nnsoup-group-alist))))
@@ -386,42 +383,43 @@ The SOUP packet file name will be inserted at the %s.")
     prefix))
 
 (defun nnsoup-read-areas ()
-  (save-excursion
-    (set-buffer nntp-server-buffer)
-    (let ((areas (gnus-soup-parse-areas (concat nnsoup-tmp-directory "AREAS")))
-         entry number area lnum cur-prefix file)
-      ;; Go through all areas in the new AREAS file.
-      (while (setq area (pop areas))
-       ;; Change the name to the permanent name and move the files.
-       (setq cur-prefix (nnsoup-next-prefix))
-       (message "Incorporating file %s..." cur-prefix)
-       (when (file-exists-p 
-              (setq file (concat nnsoup-tmp-directory
-                                 (gnus-soup-area-prefix area) ".IDX")))
-         (rename-file file (nnsoup-file cur-prefix)))
-       (when (file-exists-p 
-              (setq file (concat nnsoup-tmp-directory 
-                                 (gnus-soup-area-prefix area) ".MSG")))
-         (rename-file file (nnsoup-file cur-prefix t))
-         (gnus-soup-set-area-prefix area cur-prefix)
-         ;; Find the number of new articles in this area.
-         (setq number (nnsoup-number-of-articles area))
-         (if (not (setq entry (assoc (gnus-soup-area-name area)
-                                     nnsoup-group-alist)))
-             ;; If this is a new area (group), we just add this info to
-             ;; the group alist. 
-             (push (list (gnus-soup-area-name area)
-                         (cons 1 number)
-                         (list (cons 1 number) area))
-                   nnsoup-group-alist)
-           ;; There are already articles in this group, so we add this
-           ;; info to the end of the entry.
-           (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
-                                          (+ lnum number))
-                                    area)))
-           (setcdr (cadr entry) (+ lnum number))))))
-    (nnsoup-write-active-file t)
-    (delete-file (concat nnsoup-tmp-directory "AREAS"))))
+  (when (file-exists-p (concat nnsoup-tmp-directory "AREAS"))
+    (save-excursion
+      (set-buffer nntp-server-buffer)
+      (let ((areas (gnus-soup-parse-areas (concat nnsoup-tmp-directory "AREAS")))
+           entry number area lnum cur-prefix file)
+       ;; Go through all areas in the new AREAS file.
+       (while (setq area (pop areas))
+         ;; Change the name to the permanent name and move the files.
+         (setq cur-prefix (nnsoup-next-prefix))
+         (message "Incorporating file %s..." cur-prefix)
+         (when (file-exists-p 
+                (setq file (concat nnsoup-tmp-directory
+                                   (gnus-soup-area-prefix area) ".IDX")))
+           (rename-file file (nnsoup-file cur-prefix)))
+         (when (file-exists-p 
+                (setq file (concat nnsoup-tmp-directory 
+                                   (gnus-soup-area-prefix area) ".MSG")))
+           (rename-file file (nnsoup-file cur-prefix t))
+           (gnus-soup-set-area-prefix area cur-prefix)
+           ;; Find the number of new articles in this area.
+           (setq number (nnsoup-number-of-articles area))
+           (if (not (setq entry (assoc (gnus-soup-area-name area)
+                                       nnsoup-group-alist)))
+               ;; If this is a new area (group), we just add this info to
+               ;; the group alist. 
+               (push (list (gnus-soup-area-name area)
+                           (cons 1 number)
+                           (list (cons 1 number) area))
+                     nnsoup-group-alist)
+             ;; There are already articles in this group, so we add this
+             ;; info to the end of the entry.
+             (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
+                                            (+ lnum number))
+                                      area)))
+             (setcdr (cadr entry) (+ lnum number))))))
+      (nnsoup-write-active-file t)
+      (delete-file (concat nnsoup-tmp-directory "AREAS")))))
 
 (defun nnsoup-number-of-articles (area)
   (save-excursion
@@ -454,7 +452,7 @@ The SOUP packet file name will be inserted at the %s.")
            (set-buffer (get-buffer-create buffer-name))
            (buffer-disable-undo (current-buffer))
            (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
-           (insert-file-contents (concat nnsoup-directory file))
+           (nnheader-insert-file-contents (concat nnsoup-directory file))
            (current-buffer))))))
 
 (defun nnsoup-file (prefix &optional message)
@@ -470,7 +468,7 @@ The SOUP packet file name will be inserted at the %s.")
                  nnsoup-packet-directory t nnsoup-packet-regexp))
        packet)
     (while (setq packet (pop packets))
-      (message (format "nnsoup: unpacking %s..." packet))
+      (message "nnsoup: unpacking %s..." packet)
       (if (not (gnus-soup-unpack-packet 
                nnsoup-tmp-directory nnsoup-unpacker packet))
          (message "Couldn't unpack %s" packet)
@@ -509,8 +507,8 @@ The SOUP packet file name will be inserted at the %s.")
                (let ((format (gnus-soup-encoding-format
                               (gnus-soup-area-encoding (nth 1 area)))))
                  (goto-char end)
-                 (if (or (= format ?n) (= format ?m))
-                     (setq end (progn (forward-line -1) (point))))))
+                 (when (or (= format ?n) (= format ?m))
+                   (setq end (progn (forward-line -1) (point))))))
            (set-buffer msg-buf))
          (widen)
          (narrow-to-region beg (or end (point-max))))
@@ -552,12 +550,17 @@ The SOUP packet file name will be inserted at the %s.")
 (defun nnsoup-pack-replies ()
   "Make an outbound package of SOUP replies."
   (interactive)
+  (unless (file-exists-p nnsoup-replies-directory)
+    (message "No such directory: %s" nnsoup-replies-directory))
   ;; Write all data buffers.
   (gnus-soup-save-areas)
   ;; Write the active file.
   (nnsoup-write-active-file)
   ;; Write the REPLIES file.
   (nnsoup-write-replies)
+  ;; Check whether there is anything here.
+  (when (null (directory-files nnsoup-replies-directory nil "\\.MSG$"))
+    (error "No files to pack."))
   ;; Pack all these files into a SOUP packet.
   (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
 
@@ -657,15 +660,14 @@ The SOUP packet file name will be inserted at the %s.")
       (setq replies (cdr replies)))
     (if replies
        (gnus-soup-reply-prefix (car replies))
-      (setq nnsoup-replies-list
-           (cons (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
-                         kind 
-                         (format "%c%c%c"
-                                 nnsoup-replies-format-type
-                                 nnsoup-replies-index-type
-                                 (if (string= kind "news")
-                                     ?n ?m)))
-                 nnsoup-replies-list))
+      (push (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
+                   kind 
+                   (format "%c%c%c"
+                           nnsoup-replies-format-type
+                           nnsoup-replies-index-type
+                           (if (string= kind "news")
+                               ?n ?m)))
+           nnsoup-replies-list)
       (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
 
 (defun nnsoup-make-active ()
@@ -683,7 +685,7 @@ The SOUP packet file name will be inserted at the %s.")
     (while files
       (message "Doing %s..." (car files))
       (erase-buffer)
-      (insert-file-contents (car files))
+      (nnheader-insert-file-contents (car files))
       (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")
@@ -696,7 +698,7 @@ The SOUP packet file name will be inserted at the %s.")
                          (match-end 1))))
       (if (not (setq elem (assoc group active)))
          (push (list group (cons 1 lines)
-                     (list (cons 1 lines) 
+                     (list (cons 1 lines)
                            (vector ident group "ncm" "" lines)))
                active)
        (nconc elem