;;; nnmbox.el --- mail mbox access for Gnus
-;; Copyright (C) 1995,96 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
;;; Commentary:
;; For an overview of what the interface functions do, please see the
-;; Gnus sources.
+;; Gnus sources.
;;; Code:
(when (or (search-forward art-string nil t)
(progn (goto-char (point-min))
(search-forward art-string nil t)))
- (setq start
+ (setq start
(save-excursion
- (re-search-backward
+ (re-search-backward
(concat "^" message-unix-mail-delimiter) nil t)
(point)))
(search-forward "\n\n" nil t)
(deffoo nnmbox-open-server (server &optional defs)
(nnoo-change-server 'nnmbox server defs)
(nnmbox-create-mbox)
- (cond
+ (cond
((not (file-exists-p nnmbox-mbox-file))
(nnmbox-close-server)
(nnheader-report 'nnmbox "No such file: %s" nnmbox-mbox-file))
(re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
(setq start (point))
(forward-line 1)
- (or (and (re-search-forward
+ (or (and (re-search-forward
(concat "^" message-unix-mail-delimiter) nil t)
(forward-line -1))
(goto-char (point-max)))
(deffoo nnmbox-request-group (group &optional server dont-check)
(let ((active (cadr (assoc group nnmbox-group-alist))))
- (cond
+ (cond
((or (null active)
(null (nnmbox-possibly-change-newsgroup group server)))
(nnheader-report 'nnmbox "No such group: %s" group))
(nnheader-insert ""))
(t
(nnheader-report 'nnmbox "Selected group %s" group)
- (nnheader-insert "211 %d %d %d %s\n"
+ (nnheader-insert "211 %d %d %d %s\n"
(1+ (- (cdr active) (car active)))
(car active) (cdr active) group)))))
(deffoo nnmbox-request-scan (&optional group server)
(nnmbox-possibly-change-newsgroup group server)
(nnmbox-read-mbox)
- (nnmail-get-new-mail
- 'nnmbox
+ (nnmail-get-new-mail
+ 'nnmbox
(lambda ()
(save-excursion
(set-buffer nnmbox-mbox-buffer)
(save-buffer)))
- nnmbox-mbox-file group
+ (file-name-directory nnmbox-mbox-file)
+ group
(lambda ()
(save-excursion
(let ((in-buf (current-buffer)))
(deffoo nnmbox-request-list-newsgroups (&optional server)
(nnheader-report 'nnmbox "LIST NEWSGROUPS is not implemented."))
-(deffoo nnmbox-request-expire-articles
+(deffoo nnmbox-request-expire-articles
(articles newsgroup &optional server force)
(nnmbox-possibly-change-newsgroup newsgroup server)
(let* ((is-old t)
rest)
(nnmail-activate 'nnmbox)
- (save-excursion
+ (save-excursion
(set-buffer nnmbox-mbox-buffer)
(while (and articles is-old)
(goto-char (point-min))
(if (setq is-old
(nnmail-expired-article-p
newsgroup
- (buffer-substring
+ (buffer-substring
(point) (progn (end-of-line) (point))) force))
(progn
(nnheader-message 5 "Deleting article %d in %s..."
(article group server accept-form &optional last)
(let ((buf (get-buffer-create " *nnmbox move*"))
result)
- (and
+ (and
(nnmbox-request-article article group server)
(save-excursion
(set-buffer buf)
(erase-buffer)
(insert-buffer-substring nntp-server-buffer)
(goto-char (point-min))
- (while (re-search-forward
- "^X-Gnus-Newsgroup:"
+ (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))))
(if (looking-at "X-From-Line: ")
(replace-match "From ")
(insert "From nobody " (current-time-string) "\n"))
- (and
+ (and
(nnmail-activate 'nnmbox)
(progn
(set-buffer buf)
(forward-line -1)
(while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
(delete-region (point) (progn (forward-line 1) (point))))
+ (nnmail-cache-insert (nnmail-fetch-field "message-id"))
(setq result (nnmbox-save-mail
(if (stringp group)
(list (cons group (nnmbox-active-number group)))
(set-buffer nnmbox-mbox-buffer)
(goto-char (point-max))
(insert-buffer-substring buf)
- (and last (save-buffer))
- result)
- (nnmail-save-active nnmbox-group-alist nnmbox-active-file))
+ (when last
+ (nnmail-cache-close)
+ (nnmail-save-active nnmbox-group-alist nnmbox-active-file)
+ (save-buffer))))
(car result)))
(deffoo nnmbox-request-replace-article (article group buffer)
(when found
(save-buffer)))))
;; Remove the group from all structures.
- (setq nnmbox-group-alist
+ (setq nnmbox-group-alist
(delq (assoc group nnmbox-group-alist) nnmbox-group-alist)
nnmbox-current-group nil)
;; Save the active file.
(delete-region (point-min) (point-max))))))
(defun nnmbox-possibly-change-newsgroup (newsgroup &optional server)
- (when (and server
+ (when (and server
(not (nnmbox-server-opened server)))
(nnmbox-open-server server))
(when (or (not nnmbox-mbox-buffer)
(not (buffer-name nnmbox-mbox-buffer)))
(save-excursion
- (set-buffer (setq nnmbox-mbox-buffer
+ (set-buffer (setq nnmbox-mbox-buffer
(nnheader-find-file-noselect
nnmbox-mbox-file nil 'raw)))
(buffer-disable-undo (current-buffer))))
(defun nnmbox-article-string (article)
(if (numberp article)
- (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"
+ (concat "\nX-Gnus-Newsgroup: " nnmbox-current-group ":"
(int-to-string article) " ")
(concat "\nMessage-ID: " article)))
(when (search-forward "\n\n" nil t)
(forward-char -1)
(while group-art
- (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
+ (insert (format "X-Gnus-Newsgroup: %s:%d %s\n"
(caar group-art) (cdar group-art)
(current-time-string)))
(setq group-art (cdr group-art))))
(let ((delim (concat "^" message-unix-mail-delimiter))
(alist nnmbox-group-alist)
start end number)
- (set-buffer (setq nnmbox-mbox-buffer
+ (set-buffer (setq nnmbox-mbox-buffer
(nnheader-find-file-noselect
nnmbox-mbox-file nil 'raw)))
(buffer-disable-undo (current-buffer))
(format "^X-Gnus-Newsgroup: %s:\\([0-9]+\\) "
(caar alist)) nil t)
(>= (setq number
- (string-to-number
+ (string-to-number
(buffer-substring
(match-beginning 1) (match-end 1))))
(cdadar alist)))
(setcdr (cadar alist) (1+ number)))
(setq alist (cdr alist)))
-
+
(goto-char (point-min))
(while (re-search-forward delim nil t)
(setq start (match-beginning 0))
- (when (not (search-forward "\nX-Gnus-Newsgroup: "
- (save-excursion
+ (when (not (search-forward "\nX-Gnus-Newsgroup: "
+ (save-excursion
(setq end
(or
(and
(save-excursion
(save-restriction
(narrow-to-region start end)
- (nnmbox-save-mail
+ (nnmbox-save-mail
(nnmail-article-group 'nnmbox-active-number)))))
(goto-char end))))))