2004-05-02 Steve Youngs <steve@youngs.au.com>
[gnus] / lisp / nnmbox.el
index 02e1a27..8afd19a 100644 (file)
@@ -1,8 +1,10 @@
 ;;; nnmbox.el --- mail mbox access for Gnus
-;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
+
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+;;     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.
 (defvoo nnmbox-current-group nil
   "Current nnmbox news group directory.")
 
-(defconst nnmbox-mbox-buffer nil)
+(defvar nnmbox-mbox-buffer nil)
 
 (defvoo nnmbox-status-string "")
 
 (defvoo nnmbox-group-alist nil)
 (defvoo nnmbox-active-timestamp nil)
 
-(defvoo nnmbox-file-coding-system mm-text-coding-system)
+(defvoo nnmbox-file-coding-system mm-binary-coding-system)
 (defvoo nnmbox-file-coding-system-for-write nil)
-(defvoo nnmbox-active-file-coding-system mm-text-coding-system)
+(defvoo nnmbox-active-file-coding-system mm-binary-coding-system)
 (defvoo nnmbox-active-file-coding-system-for-write nil)
 
 (defvar nnmbox-group-building-active-articles nil)
                       (car active) (cdr active) group)))))
 
 (defun nnmbox-save-buffer ()
-  (let ((coding-system-for-write 
+  (let ((coding-system-for-write
         (or nnmbox-file-coding-system-for-write
             nnmbox-file-coding-system)))
     (save-buffer)))
              (progn
                (unless (eq nnmail-expiry-target 'delete)
                  (with-temp-buffer
-                   (nnmbox-request-article (car articles) 
-                                            newsgroup server 
+                   (nnmbox-request-article (car articles)
+                                            newsgroup server
                                             (current-buffer))
                    (let ((nnml-current-directory nil))
                      (nnmail-expiry-target-group
-                      nnmail-expiry-target newsgroup))))
+                      nnmail-expiry-target newsgroup)))
+                 (nnmbox-possibly-change-newsgroup newsgroup server))
                (nnheader-message 5 "Deleting article %d in %s..."
                                  (car articles) newsgroup)
                (nnmbox-delete-mail))
        (while (re-search-forward
               "^X-Gnus-Newsgroup:"
               (save-excursion (search-forward "\n\n" nil t) (point)) t)
-        (delete-region (progn (beginning-of-line) (point))
-                       (progn (forward-line 1) (point))))
+        (gnus-delete-line))
        (setq result (eval accept-form))
        (kill-buffer buf)
        result)
        (while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
         (delete-region (point) (progn (forward-line 1) (point))))
        (when nnmail-cache-accepted-message-ids
-        (nnmail-cache-insert (nnmail-fetch-field "message-id")))
+        (nnmail-cache-insert (nnmail-fetch-field "message-id") 
+                             group
+                             (nnmail-fetch-field "subject")
+                             (nnmail-fetch-field "from")))
        (setq result (if (stringp group)
                        (list (cons group (nnmbox-active-number group)))
                      (nnmail-article-group 'nnmbox-active-number)))
   (if (not force)
       (nnmbox-record-deleted-article (nnmbox-article-group-number t)))
   (or force
-      (delete-region
-       (progn (beginning-of-line) (point))
-       (progn (forward-line 1) (point))))
+      (gnus-delete-line))
   ;; Beginning of the article.
   (save-excursion
     (save-restriction
               (nnmbox-in-header-p (point)))
          (progn
            (goto-char (point-min))
-           (while (not found)
-             (setq found (and (search-forward art-string nil t)
-                              (nnmbox-in-header-p (point)))))
+           (while (and (not found)
+                       (search-forward art-string nil t))
+             (setq found (nnmbox-in-header-p (point))))
            found)))))
 
 (defun nnmbox-record-active-article (group-art)
   (when (not (file-exists-p nnmbox-mbox-file))
     (let ((nnmail-file-coding-system
           (or nnmbox-file-coding-system-for-write
-              nnmbox-file-coding-system)))
-      (nnmail-write-region 1 1 nnmbox-mbox-file t 'nomesg))))
+              nnmbox-file-coding-system))
+         (dir (file-name-directory nnmbox-mbox-file)))
+      (and dir (gnus-make-directory dir))
+      (nnmail-write-region (point-min) (point-min)
+                          nnmbox-mbox-file t 'nomesg))))
 
 (defun nnmbox-read-mbox ()
   (nnmail-activate 'nnmbox)
                          (let ((nnheader-file-coding-system
                                 nnmbox-file-coding-system))
                            (nnheader-find-file-noselect
-                            nnmbox-mbox-file nil t))))
+                            nnmbox-mbox-file t t))))
        (mm-enable-multibyte)
        (buffer-disable-undo)