Revision: miles@gnu.org--gnu-2005/gnus--devo--0--patch-182
[gnus] / lisp / nnmbox.el
index 983dcc3..5f854da 100644 (file)
@@ -1,10 +1,10 @@
 ;;; nnmbox.el --- mail mbox access for Gnus
 
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
-;;     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.
@@ -16,8 +16,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:
 
@@ -55,7 +55,7 @@
 (defvoo nnmbox-current-group nil
   "Current nnmbox news group directory.")
 
-(defconst nnmbox-mbox-buffer nil)
+(defvar nnmbox-mbox-buffer nil)
 
 (defvoo nnmbox-status-string "")
 
                       (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))
       (nconc rest articles))))
 
 (deffoo nnmbox-request-move-article
-    (article group server accept-form &optional last)
+    (article group server accept-form &optional last move-is-internal)
   (let ((buf (get-buffer-create " *nnmbox move*"))
        result)
     (and
        (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
     (when (re-search-forward "^X-Gnus-Newsgroup: +\\([^:]+\\):\\([0-9]+\\) "
                             nil t)
       (cons (buffer-substring (match-beginning 1) (match-end 1))
-           (string-to-int
+           (string-to-number
             (buffer-substring (match-beginning 2) (match-end 2)))))))
 
 (defun nnmbox-in-header-p (pos)
               (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)
 
                    (let (alist)
                      (while (re-search-forward " \\([^:]+\\):\\([0-9]+\\)" end-header t)
                        (push (cons (match-string 1)
-                                   (string-to-int (match-string 2))) alist))
+                                   (string-to-number (match-string 2))) alist))
                      (nnmbox-insert-newsgroup-line alist))
                  ;; this is really a new article
                  (nnmbox-save-mail
 
 (provide 'nnmbox)
 
+;;; arch-tag: 611dd95f-be37-413a-b3ae-8b059ba93659
 ;;; nnmbox.el ends here