;;; nnml.el --- mail spool access for Gnus
;; Copyright (C) 1995 Free Software Foundation, Inc.
-;; Author: Lars Ingebrigtsen <larsi@ifi.uio.no>
+;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
;; Keywords: news, mail
(defvar nnml-nov-buffer-alist nil)
(defvar nnml-group-alist nil)
+(defvar nnml-active-timestamp nil)
\f
(and nntp-server-buffer
(get-buffer nntp-server-buffer)))
-(defun nnml-status-message ()
+(defun nnml-status-message (&optional server)
"Return server status response as string."
nnml-status-string)
(defun nnml-request-group (group &optional server dont-check)
"Select news GROUP."
- (nnml-possibly-change-directory group)
- (or dont-check (nnml-get-new-mail))
- (or nnml-group-alist
+ (if (not (nnml-possibly-change-directory group))
(progn
- (nnml-request-list)
- (setq nnml-group-alist (nnmail-get-active))))
- (let ((active (nth 1 (assoc group nnml-group-alist))))
- (save-excursion
- (set-buffer nntp-server-buffer)
- (erase-buffer)
- (if (not active)
- ()
- (insert (format "211 %d %d %d %s\n"
- (max (1+ (- (cdr active) (car active))) 0)
- (car active) (cdr active) group))
- t))))
+ (setq nnml-status-string "Invalid group (no such directory)")
+ nil)
+ (if dont-check
+ t
+ (nnml-get-new-mail)
+ (let ((timestamp (nth 5 (file-attributes nnml-active-file))))
+ (if (or (not nnml-active-timestamp)
+ (> (nth 0 timestamp) (nth 0 nnml-active-timestamp))
+ (> (nth 1 timestamp) (nth 1 nnml-active-timestamp)))
+ (progn
+ (setq nnml-active-timestamp timestamp)
+ (nnml-request-list)
+ (setq nnml-group-alist (nnmail-get-active))))
+ (let ((active (nth 1 (assoc group nnml-group-alist))))
+ (save-excursion
+ (set-buffer nntp-server-buffer)
+ (erase-buffer)
+ (if (not active)
+ ()
+ (insert (format "211 %d %d %d %s\n"
+ (max (1+ (- (cdr active) (car active))) 0)
+ (car active) (cdr active) group))
+ t)))))))
(defun nnml-close-group (group &optional server)
t)
(funcall nnmail-expiry-wait-function newsgroup))
nnmail-expiry-wait))
article rest mod-time)
+ (if nnmail-keep-last-article
+ (progn
+ (setq articles (sort articles '>))
+ (setq rest (cons (car articles) rest))
+ (setq articles (cdr articles))))
(while articles
(setq article (concat nnml-current-directory (int-to-string
(car articles))))
(nnml-save-nov)
rest))
-(defun nnml-request-move-article (article group server accept-form)
+(defun nnml-request-move-article
+ (article group server accept-form &optional last)
(let ((buf (get-buffer-create " *nnml move*"))
result)
(and
(int-to-string article)))
(file-error nil))
(nnml-nov-delete-article group article)
- (nnml-save-nov)))
+ (and last (nnml-save-nov))))
result))
-(defun nnml-request-accept-article (group)
+(defun nnml-request-accept-article (group &optional last)
(let (result)
(if (stringp group)
(and
(setq result (car (nnml-save-mail))))
(progn
(nnmail-save-active nnml-group-alist nnml-active-file)
- (nnml-save-nov)))
+ (and last (nnml-save-nov))))
(and
(nnml-request-list)
(setq nnml-group-alist (nnmail-get-active))
(setq result (car (nnml-save-mail)))
(progn
(nnmail-save-active nnml-group-alist nnml-active-file)
- (nnml-save-nov))))
+ (and last (nnml-save-nov)))))
result))
(defun nnml-request-replace-article (article group buffer)
(defun nnml-possibly-change-directory (newsgroup)
(if newsgroup
(let ((pathname (nnmail-article-pathname newsgroup nnml-directory)))
- (if (file-directory-p pathname)
- (setq nnml-current-directory pathname)
- (error "No such newsgroup: %s" newsgroup)))))
-
+ (and (file-directory-p pathname)
+ (setq nnml-current-directory pathname)))
+ t))
+
(defun nnml-create-directories ()
(let ((methods nnmail-split-methods)
dir dirs)
(if (buffer-name (cdr (car nnml-nov-buffer-alist)))
(progn
(set-buffer (cdr (car nnml-nov-buffer-alist)))
- (write-region 1 (point-max) (buffer-file-name) nil 'nomesg)
+ (and (buffer-modified-p)
+ (write-region
+ 1 (point-max) (buffer-file-name) nil 'nomesg))
(set-buffer-modified-p nil)
(kill-buffer (current-buffer))))
(setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist)))))
+;;;###autoload
(defun nnml-generate-nov-databases (dir)
"Generate nov databases in all nnml mail newsgroups."
(interactive