;;; nnml.el --- mail spool access for Gnus
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Authors: Didier Verna <didier@xemacs.org> (adding compaction)
;; Simon Josefsson <simon@josefsson.org> (adding MARKS)
"If non-nil, allow using compressed message files.
If it is a string, use it as the file extension which specifies
-the comression program. You can set it to \".bz2\" if your Emacs
+the compression program. You can set it to \".bz2\" if your Emacs
supports auto-compression using the bzip2 program. A value of t
is equivalent to \".gz\".")
(nnml-possibly-change-directory nil server)
(nnmail-activate 'nnml)
(cond
+ ((let ((file (directory-file-name
+ (nnmail-group-pathname group nnml-directory))))
+ (and (file-exists-p file)
+ (not (file-directory-p file))))
+ (nnheader-report 'nnml "%s is a file"
+ (directory-file-name
+ (let ((nnmail-pathname-coding-system nil))
+ (nnmail-group-pathname group nnml-directory)))))
((assoc group nnml-group-alist)
t)
- ((and (file-exists-p (nnmail-group-pathname group nnml-directory))
- (not (file-directory-p (nnmail-group-pathname group nnml-directory))))
- (nnheader-report 'nnml "%s is a file"
- (nnmail-group-pathname group nnml-directory)))
(t
(let (active)
(push (list group (setq active (cons 1 0)))
(let ((active-articles
(nnml-directory-articles nnml-current-directory))
(is-old t)
- article rest mod-time number)
+ article rest mod-time number target)
(nnmail-activate 'nnml)
(setq active-articles (sort active-articles '<))
nnml-inhibit-expiry)))
(progn
;; Allow a special target group.
- (unless (eq nnmail-expiry-target 'delete)
+ (setq target nnmail-expiry-target)
+ (unless (eq target 'delete)
(with-temp-buffer
(nnml-request-article number group server (current-buffer))
(let (nnml-current-directory
nnml-current-group
nnml-article-file-alist)
- (nnmail-expiry-target-group nnmail-expiry-target group)))
+ (when (functionp target)
+ (setq target (funcall target group)))
+ (if (and target
+ (or (gnus-request-group target)
+ (gnus-request-create-group target)))
+ (nnmail-expiry-target-group target group)
+ (setq target nil))))
;; Maybe directory is changed during nnmail-expiry-target-group.
(nnml-possibly-change-directory group server))
- (nnheader-message 5 "Deleting article %s in %s"
- number group)
- (condition-case ()
- (funcall nnmail-delete-file-function article)
- (file-error
- (push number rest)))
- (setq active-articles (delq number active-articles))
- (nnml-nov-delete-article group number))
+ (if target
+ (progn
+ (nnheader-message 5 "Deleting article %s in %s"
+ number group)
+ (condition-case ()
+ (funcall nnmail-delete-file-function article)
+ (file-error
+ (push number rest)))
+ (setq active-articles (delq number active-articles))
+ (nnml-nov-delete-article group number))
+ (push number rest)))
(push number rest)))
(let ((active (nth 1 (assoc group nnml-group-alist))))
(when active
(nnml-open-server server))
(setq nnml-directory (expand-file-name nnml-directory))
;; Recurse down the directories.
- (nnml-generate-nov-databases-1 nnml-directory nil t)
+ (nnml-generate-nov-databases-directory nnml-directory nil t)
;; Save the active file.
(nnmail-save-active nnml-group-alist nnml-active-file))
-(defun nnml-generate-nov-databases-1 (dir &optional seen no-active)
- "Regenerate the NOV database in DIR."
+(defun nnml-generate-nov-databases-directory (dir &optional seen no-active)
+ "Regenerate the NOV database in DIR.
+
+Unless no-active is non-nil, update the active file too."
(interactive "DRegenerate NOV in: ")
(setq dir (file-name-as-directory dir))
;; Only scan this sub-tree if we haven't been here yet.
(dolist (dir (directory-files dir t nil t))
(when (and (not (string-match "^\\." (file-name-nondirectory dir)))
(file-directory-p dir))
- (nnml-generate-nov-databases-1 dir seen)))
+ (nnml-generate-nov-databases-directory dir seen)))
;; Do this directory.
(let ((files (sort (nnheader-article-to-file-alist dir)
'car-less-than-car)))
;; #### other backends get a compaction feature. Also, note that invalidating
;; #### the "original article buffer" is already done at an upper level.
+;; Shouldn't `nnml-request-compact-group' be interactive? --rsteib
+
(defun nnml-request-compact-group (group &optional server save)
(nnml-possibly-change-directory group server)
(unless nnml-article-file-alist
(let* ((oldfile (nnml-article-to-file old-number))
(newfile
(gnus-replace-in-string
- oldfile (concat "\\("
- old-number-string
- "\\)\\(\\(\\.gz\\)?\\)$")
+ oldfile
+ ;; nnml-use-compressed-files might be any string, but
+ ;; probably it's sufficient to take into account only
+ ;; "\\.[a-z0-9]+". Note that we can't only use the
+ ;; value of nnml-use-compressed-files because old
+ ;; articles might have been saved with a different
+ ;; value.
+ (concat
+ "\\(" old-number-string "\\)\\(\\(\\.[a-z0-9]+\\)?\\)$")
(concat new-number-string "\\2"))))
(with-current-buffer nntp-server-buffer
(nnmail-find-file oldfile)