1 ;;; nnml.el --- mail spool access for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
28 ;; For an overview of what the interface functions do, please see the
40 (defvoo nnml-directory message-directory
41 "Mail spool directory.")
43 (defvoo nnml-active-file
44 (concat (file-name-as-directory nnml-directory) "active")
47 (defvoo nnml-newsgroups-file
48 (concat (file-name-as-directory nnml-directory) "newsgroups")
49 "Mail newsgroups description file.")
51 (defvoo nnml-get-new-mail t
52 "If non-nil, nnml will check the incoming mail file and split the mail.")
54 (defvoo nnml-nov-is-evil nil
55 "If non-nil, Gnus will never generate and use nov databases for mail groups.
56 Using nov databases will speed up header fetching considerably.
57 This variable shouldn't be flipped much. If you have, for some reason,
58 set this to t, and want to set it to nil again, you should always run
59 the `nnml-generate-nov-databases' command. The function will go
60 through all nnml directories and generate nov databases for them
61 all. This may very well take some time.")
63 (defvoo nnml-prepare-save-mail-hook nil
64 "Hook run narrowed to an article before saving.")
66 (defvoo nnml-inhibit-expiry nil
67 "If non-nil, inhibit expiry.")
72 (defconst nnml-version "nnml 1.0"
75 (defvoo nnml-nov-file-name ".overview")
77 (defvoo nnml-current-directory nil)
78 (defvoo nnml-current-group nil)
79 (defvoo nnml-status-string "")
80 (defvoo nnml-nov-buffer-alist nil)
81 (defvoo nnml-group-alist nil)
82 (defvoo nnml-active-timestamp nil)
83 (defvoo nnml-article-file-alist nil)
85 (defvoo nnml-generate-active-function 'nnml-generate-active-info)
89 ;;; Interface functions.
91 (nnoo-define-basics nnml)
93 (deffoo nnml-retrieve-headers (sequence &optional newsgroup server fetch-old)
95 (set-buffer nntp-server-buffer)
98 (number (length sequence))
101 (if (stringp (car sequence))
103 (nnml-possibly-change-directory newsgroup server)
104 (unless nnml-article-file-alist
105 (setq nnml-article-file-alist
106 (nnheader-article-to-file-alist nnml-current-directory)))
107 (if (nnml-retrieve-headers-with-nov sequence fetch-old)
110 (setq article (car sequence))
112 (concat nnml-current-directory
113 (or (cdr (assq article nnml-article-file-alist))
115 (when (and (file-exists-p file)
116 (not (file-directory-p file)))
117 (insert (format "221 %d Article retrieved.\n" article))
119 (nnheader-insert-head file)
121 (if (search-forward "\n\n" nil t)
123 (goto-char (point-max))
126 (delete-region (point) (point-max)))
127 (setq sequence (cdr sequence))
128 (setq count (1+ count))
129 (and (numberp nnmail-large-newsgroup)
130 (> number nnmail-large-newsgroup)
132 (nnheader-message 6 "nnml: Receiving headers... %d%%"
133 (/ (* count 100) number))))
135 (and (numberp nnmail-large-newsgroup)
136 (> number nnmail-large-newsgroup)
137 (nnheader-message 6 "nnml: Receiving headers...done"))
139 (nnheader-fold-continuation-lines)
142 (deffoo nnml-open-server (server &optional defs)
143 (nnoo-change-server 'nnml server defs)
144 (when (not (file-exists-p nnml-directory))
146 (make-directory nnml-directory t)
149 ((not (file-exists-p nnml-directory))
151 (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory))
152 ((not (file-directory-p (file-truename nnml-directory)))
154 (nnheader-report 'nnml "Not a directory: %s" nnml-directory))
156 (nnheader-report 'nnml "Opened server %s using directory %s"
157 server nnml-directory)
160 (defun nnml-request-regenerate (server)
161 (nnml-possibly-change-directory nil server)
162 (nnml-generate-nov-databases))
164 (deffoo nnml-request-article (id &optional newsgroup server buffer)
165 (nnml-possibly-change-directory newsgroup server)
166 (let* ((nntp-server-buffer (or buffer nntp-server-buffer))
167 path gpath group-num)
169 (when (and (setq group-num (nnml-find-group-number id))
171 (assq (cdr group-num)
172 (nnheader-article-to-file-alist
174 (nnmail-group-pathname
177 (setq path (concat gpath (int-to-string (cdr group-num)))))
178 (setq path (nnml-article-to-file id)))