*** empty log message ***
[gnus] / lisp / nnml.el
1 ;;; nnml.el --- mail spool access for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;;      Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Keywords: news, mail
7
8 ;; This file is part of GNU Emacs.
9
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)
13 ;; any later version.
14
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.
19
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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
27 ;; For an overview of what the interface functions do, please see the
28 ;; Gnus sources.  
29
30 ;;; Code:
31
32 (require 'nnheader)
33 (require 'nnmail)
34
35 (defvar nnml-directory "~/Mail/"
36   "Mail spool directory.")
37
38 (defvar nnml-active-file (concat nnml-directory "active")
39   "Mail active file.")
40
41 (defvar nnml-newsgroups-file (concat nnml-directory "newsgroups")
42   "Mail newsgroups description file.")
43
44 (defvar nnml-get-new-mail t
45   "If non-nil, nnml will check the incoming mail file and split the mail.")
46
47 (defvar nnml-nov-is-evil nil
48   "If non-nil, Gnus will never generate and use nov databases for mail groups.
49 Using nov databases will speed up header fetching considerably.
50 This variable shouldn't be flipped much. If you have, for some reason,
51 set this to t, and want to set it to nil again, you should always run
52 the `nnml-generate-nov-databases' command. The function will go
53 through all nnml directories and generate nov databases for them
54 all. This may very well take some time.")
55
56 \f
57
58 (defconst nnml-version "nnml 0.2"
59   "nnml version.")
60
61 (defvar nnml-nov-file-name ".overview")
62
63 (defvar nnml-current-directory nil)
64 (defvar nnml-status-string "")
65 (defvar nnml-nov-buffer-alist nil)
66 (defvar nnml-group-alist nil)
67 (defvar nnml-active-timestamp nil)
68
69 \f
70
71 ;; Server variables.
72
73 (defvar nnml-current-server nil)
74 (defvar nnml-server-alist nil)
75 (defvar nnml-server-variables 
76   (list 
77    (list 'nnml-directory nnml-directory)
78    (list 'nnml-active-file nnml-active-file)
79    (list 'nnml-newsgroups-file nnml-newsgroups-file)
80    (list 'nnml-get-new-mail nnml-get-new-mail)
81    (list 'nnml-nov-is-evil nnml-nov-is-evil)
82    (list 'nnml-nov-file-name nnml-nov-file-name)
83    '(nnml-current-directory nil)
84    '(nnml-status-string "")
85    '(nnml-nov-buffer-alist nil)
86    '(nnml-group-alist nil)
87    '(nnml-active-timestamp nil)))
88
89 \f
90
91 ;;; Interface functions.
92
93 (defun nnml-retrieve-headers (sequence &optional newsgroup server)
94   (save-excursion
95     (set-buffer nntp-server-buffer)
96     (erase-buffer)
97     (let ((file nil)
98           (number (length sequence))
99           (count 0)
100           beg article)
101       (nnml-possibly-change-directory newsgroup)
102       (if (nnml-retrieve-headers-with-nov sequence)
103           'nov
104         (while sequence
105           (setq article (car sequence))
106           (setq file
107                 (concat nnml-current-directory (prin1-to-string article)))
108           (if (and (file-exists-p file)
109                    (not (file-directory-p file)))
110               (progn
111                 (insert (format "221 %d Article retrieved.\n" article))
112                 (setq beg (point))
113                 (insert-file-contents file)
114                 (goto-char beg)
115                 (if (search-forward "\n\n" nil t)
116                     (forward-char -1)
117                   (goto-char (point-max))
118                   (insert "\n\n"))
119                 (insert ".\n")
120                 (delete-region (point) (point-max))))
121           (setq sequence (cdr sequence))
122           (setq count (1+ count))
123           (and (numberp nnmail-large-newsgroup)
124                (> number nnmail-large-newsgroup)
125                (zerop (% count 20))
126                gnus-verbose-backends
127                (message "nnml: Receiving headers... %d%%"
128                         (/ (* count 100) number))))
129
130         (and (numberp nnmail-large-newsgroup)
131              (> number nnmail-large-newsgroup)
132              gnus-verbose-backends
133              (message "nnml: Receiving headers... done"))
134
135         ;; Fold continuation lines.
136         (goto-char 1)
137         (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
138           (replace-match " " t t))
139         'headers))))
140
141 (defun nnml-open-server (server &optional defs)
142   (nnheader-init-server-buffer)
143   (if (equal server nnml-current-server)
144       t
145     (if nnml-current-server
146         (setq nnml-server-alist 
147               (cons (list nnml-current-server
148                           (nnheader-save-variables nnml-server-variables))
149                     nnml-server-alist)))
150     (let ((state (assoc server nnml-server-alist)))
151       (if state 
152           (progn
153             (nnheader-restore-variables (nth 1 state))
154             (setq nnml-server-alist (delq state nnml-server-alist)))
155         (nnheader-set-init-variables nnml-server-variables defs)))
156     (setq nnml-current-server server)))
157
158 (defun nnml-close-server (&optional server)
159   t)
160
161 (defun nnml-server-opened (&optional server)
162   (and (equal server nnml-current-server)
163        nntp-server-buffer
164        (buffer-name nntp-server-buffer)))
165
166 (defun nnml-status-message (&optional server)
167   nnml-status-string)
168
169 (defun nnml-request-article (id &optional newsgroup server buffer)
170   (nnml-possibly-change-directory newsgroup)
171   (let ((file (if (stringp id)
172                   nil
173                 (concat nnml-current-directory (prin1-to-string id))))
174         (nntp-server-buffer (or buffer nntp-server-buffer)))
175     (if (and (stringp file)
176              (file-exists-p file)
177              (not (file-directory-p file)))
178         (save-excursion
179           (nnmail-find-file file)))))
180
181 (defun nnml-request-group (group &optional server dont-check)
182   (if (not (nnml-possibly-change-directory group))
183       (progn
184         (setq nnml-status-string "Invalid group (no such directory)")
185         nil)
186     (if dont-check 
187         t
188       (nnml-get-new-mail)
189       (let ((timestamp (nth 5 (file-attributes nnml-active-file))))
190         (if (or (not nnml-active-timestamp)
191                 (> (nth 0 timestamp) (nth 0 nnml-active-timestamp))
192                 (> (nth 1 timestamp) (nth 1 nnml-active-timestamp)))
193             (progn
194               (setq nnml-active-timestamp timestamp)
195               (nnml-request-list)
196               (setq nnml-group-alist (nnmail-get-active))))
197         (let ((active (nth 1 (assoc group nnml-group-alist))))
198           (save-excursion
199             (set-buffer nntp-server-buffer)
200             (erase-buffer)
201             (if (not active)
202                 ()
203               (insert (format "211 %d %d %d %s\n" 
204                               (max (1+ (- (cdr active) (car active))) 0)
205                               (car active) (cdr active) group))
206               t)))))))
207
208 (defun nnml-close-group (group &optional server)
209   t)
210
211 (defun nnml-request-create-group (group &optional server) 
212   (nnml-request-list)
213   (setq nnml-group-alist (nnmail-get-active))
214   (or (assoc group nnml-group-alist)
215       (let (active)
216         (setq nnml-group-alist (cons (list group (setq active (cons 0 0)))
217                                      nnml-group-alist))
218         (nnml-possibly-create-directory group)
219         (nnml-possibly-change-directory group)
220         (let ((articles (mapcar
221                          (lambda (file)
222                            (int-to-string file))
223                          (directory-files 
224                           nnml-current-directory nil "^[0-9]+$"))))
225           (and articles
226                (progn
227                  (setcar active (apply 'min articles))
228                  (setcdr active (apply 'max articles)))))
229         (nnmail-save-active nnml-group-alist nnml-active-file)))
230   t)
231
232 (defun nnml-request-list (&optional server)
233   (if server (nnml-get-new-mail))
234   (save-excursion
235     (nnmail-find-file nnml-active-file)))
236
237 (defun nnml-request-newgroups (date &optional server)
238   (nnml-request-list server))
239
240 (defun nnml-request-list-newsgroups (&optional server)
241   (save-excursion
242     (nnmail-find-file nnml-newsgroups-file)))
243
244 (defun nnml-request-post (&optional server)
245   (mail-send-and-exit nil))
246
247 (fset 'nnml-request-post-buffer 'nnmail-request-post-buffer)
248
249 (defun nnml-request-expire-articles (articles newsgroup &optional server force)
250   (nnml-possibly-change-directory newsgroup)
251   (let* ((days (or (and nnmail-expiry-wait-function
252                         (funcall nnmail-expiry-wait-function newsgroup))
253                    nnmail-expiry-wait))
254          (active-articles 
255           (mapcar
256            (function
257             (lambda (name)
258               (string-to-int name)))
259            (directory-files nnml-current-directory nil "^[0-9]+$" t)))
260          (max-article (and active-articles (apply 'max active-articles)))
261          article rest mod-time)
262     (while articles
263       (setq article (concat nnml-current-directory (int-to-string
264                                                       (car articles))))
265       (if (setq mod-time (nth 5 (file-attributes article)))
266           (if (and (or (not nnmail-keep-last-article)
267                        (not max-article)
268                        (not (= (car articles) max-article)))
269                    (or force
270                        (> (nnmail-days-between
271                            (current-time-string)
272                            (current-time-string mod-time))
273                           days)))
274               (progn
275                 (and gnus-verbose-backends (message "Deleting %s..." article))
276                 (condition-case ()
277                     (delete-file article)
278                   (file-error nil))
279                 (setq active-articles (delq (car articles) active-articles))
280                 (nnml-nov-delete-article newsgroup (car articles)))
281             (setq rest (cons (car articles) rest))))
282       (setq articles (cdr articles)))
283     (let ((active (nth 1 (assoc newsgroup nnml-group-alist))))
284       (and active
285            (setcar active (or (and active-articles
286                                    (apply 'min active-articles))
287                               0)))
288       (nnmail-save-active nnml-group-alist nnml-active-file))
289     (nnml-save-nov)
290     (message "")
291     rest))
292
293 (defun nnml-request-move-article 
294   (article group server accept-form &optional last)
295   (let ((buf (get-buffer-create " *nnml move*"))
296         result)
297     (and 
298      (nnml-request-article article group server)
299      (save-excursion
300        (set-buffer buf)
301        (insert-buffer-substring nntp-server-buffer)
302        (setq result (eval accept-form))
303        (kill-buffer (current-buffer))
304        result)
305      (progn
306        (condition-case ()
307            (delete-file (concat nnml-current-directory 
308                                 (int-to-string article)))
309          (file-error nil))
310        (nnml-nov-delete-article group article)
311        (and last (nnml-save-nov))))
312     result))
313
314 (defun nnml-request-accept-article (group &optional last)
315   (let (result)
316     (if (stringp group)
317         (and 
318          (nnml-request-list)
319          (setq nnml-group-alist (nnmail-get-active))
320          ;; We trick the choosing function into believing that only one
321          ;; group is availiable.  
322          (let ((nnmail-split-methods (list (list group ""))))
323            (setq result (car (nnml-save-mail))))
324          (progn
325            (nnmail-save-active nnml-group-alist nnml-active-file)
326            (and last (nnml-save-nov))))
327       (and
328        (nnml-request-list)
329        (setq nnml-group-alist (nnmail-get-active))
330        (setq result (car (nnml-save-mail)))
331        (progn
332          (nnmail-save-active nnml-group-alist nnml-active-file)
333          (and last (nnml-save-nov)))))
334     result))
335
336 (defun nnml-request-replace-article (article group buffer)
337   (nnml-possibly-change-directory group)
338   (save-excursion
339     (set-buffer buffer)
340     (nnml-possibly-create-directory group)
341     (if (not (condition-case ()
342                  (progn
343                    (write-region (point-min) (point-max)
344                                  (concat nnml-current-directory 
345                                          (int-to-string article))
346                                  nil (if gnus-verbose-backends nil 'nomesg))
347                    t)
348                (error nil)))
349         ()
350       (let ((chars (nnmail-insert-lines))
351             (art (concat (int-to-string article) "\t"))
352             nov-line)
353         (setq nov-line (nnml-make-nov-line chars))
354         (save-excursion 
355           (set-buffer (nnml-open-nov group))
356           (goto-char (point-min))
357           (if (or (looking-at art)
358                   (search-forward (concat "\n" art)))
359               (progn
360                 (delete-region (progn (beginning-of-line) (point))
361                                (progn (forward-line 1) (point)))
362                 (insert (int-to-string article) nov-line)
363                 (nnml-save-nov))
364             (kill-buffer (current-buffer)))
365           t)))))
366
367
368 \f
369 ;;; Internal functions
370
371 (defun nnml-retrieve-headers-with-nov (articles)
372   (if (or gnus-nov-is-evil nnml-nov-is-evil)
373       nil
374     (let ((first (car articles))
375           (last (progn (while (cdr articles) (setq articles (cdr articles)))
376                        (car articles)))
377           (nov (concat nnml-current-directory nnml-nov-file-name)))
378       (if (file-exists-p nov)
379           (save-excursion
380             (set-buffer nntp-server-buffer)
381             (erase-buffer)
382             (insert-file-contents nov)
383             (goto-char 1)
384             (while (and (not (eobp)) (< first (read (current-buffer))))
385               (forward-line 1))
386             (beginning-of-line)
387             (if (not (eobp)) (delete-region 1 (point)))
388             (while (and (not (eobp)) (>= last (read (current-buffer))))
389               (forward-line 1))
390             (beginning-of-line)
391             (if (not (eobp)) (delete-region (point) (point-max)))
392             t)))))
393
394 (defun nnml-possibly-change-directory (newsgroup &optional force)
395   (if newsgroup
396       (let ((pathname (nnmail-article-pathname newsgroup nnml-directory)))
397         (and (or force (file-directory-p pathname))
398              (setq nnml-current-directory pathname)))
399     t))
400
401 (defun nnml-possibly-create-directory (group)
402   (let (dir dirs)
403     (setq dir (nnmail-article-pathname group nnml-directory))
404     (while (not (file-directory-p dir))
405       (setq dirs (cons dir dirs))
406       (setq dir (file-name-directory (directory-file-name dir))))
407     (while dirs
408       (if (make-directory (directory-file-name (car dirs)))
409           (error "Could not create directory %s" (car dirs)))
410       (and gnus-verbose-backends 
411            (message "Creating mail directory %s" (car dirs)))
412       (setq dirs (cdr dirs)))))
413              
414 (defun nnml-save-mail ()
415   "Called narrowed to an article."
416   (let ((group-art (nreverse (nnmail-article-group 'nnml-active-number)))
417         chars nov-line)
418     (setq chars (nnmail-insert-lines))
419     (nnmail-insert-xref group-art)
420     (goto-char (point-min))
421     (while (looking-at "From ")
422       (replace-match "X-From-Line: ")
423       (forward-line 1))
424     ;; We save the article in all the newsgroups it belongs in.
425     (let ((ga group-art)
426           first)
427       (while ga
428         (nnml-possibly-create-directory (car (car ga)))
429         (let ((file (concat (nnmail-article-pathname 
430                              (car (car ga)) nnml-directory)
431                             (int-to-string (cdr (car ga))))))
432           (if first
433               ;; It was already saved, so we just make a hard link.
434               (add-name-to-file first file t)
435             ;; Save the article.
436             (write-region (point-min) (point-max) file nil 
437                           (if gnus-verbose-backends nil 'nomesg))
438             (setq first file)))
439         (setq ga (cdr ga))))
440     ;; Generate a nov line for this article. We generate the nov
441     ;; line after saving, because nov generation destroys the
442     ;; header. 
443     (setq nov-line (nnml-make-nov-line chars))
444     ;; Output the nov line to all nov databases that should have it.
445     (let ((ga group-art))
446       (while ga
447         (nnml-add-nov (car (car ga)) (cdr (car ga)) nov-line)
448         (setq ga (cdr ga))))
449     group-art))
450
451 (defun nnml-active-number (group)
452   "Compute the next article number in GROUP."
453   (let ((active (car (cdr (assoc group nnml-group-alist)))))
454     (or active
455         (progn
456           (setq active (cons 1 0))
457           (setq nnml-group-alist (cons (list group active) nnml-group-alist))))
458     (setcdr active (1+ (cdr active)))
459     (let (file)
460       (while (file-exists-p
461               (setq file (concat (nnmail-article-pathname 
462                                   group nnml-directory)
463                                  (int-to-string (cdr active)))))
464         (setcdr active (1+ (cdr active)))))
465     (cdr active)))
466
467 (defun nnml-get-new-mail ()
468   "Read new incoming mail."
469   (let (incoming)
470     (if (and nnml-get-new-mail nnmail-spool-file
471              (file-exists-p nnmail-spool-file)
472              (> (nth 7 (file-attributes nnmail-spool-file)) 0))
473         (progn
474           (and gnus-verbose-backends 
475                (message "nnml: Reading incoming mail..."))
476           (setq incoming 
477                 (nnmail-move-inbox nnmail-spool-file 
478                                    (concat nnml-directory "Incoming")))
479           (nnml-request-list)
480           (setq nnml-group-alist (nnmail-get-active))
481           (nnmail-split-incoming incoming 'nnml-save-mail)
482           (nnmail-save-active nnml-group-alist nnml-active-file)
483           (nnml-save-nov)
484           (run-hooks 'nnmail-read-incoming-hook)
485           ;; The following has been commented away, just to make sure
486           ;; that nobody ever loses any mail. If you feel safe that
487           ;; nnml will never do anything strange, just remove those
488           ;; two semicolons, and avoid having lots of "Incoming*"
489           ;; files. 
490 ;;         (delete-file incoming)
491           (and gnus-verbose-backends
492                (message "nnml: Reading incoming mail...done"))))))
493
494
495 (defun nnml-add-nov (group article line)
496   "Add a nov line for the GROUP base."
497   (save-excursion 
498     (set-buffer (nnml-open-nov group))
499     (goto-char (point-max))
500     (insert (int-to-string article) line)))
501
502 (defsubst nnml-header-value ()
503   (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
504
505 (defun nnml-make-nov-line (chars)
506   "Create a nov from the current headers."
507   (let ((case-fold-search t)
508         subject from date id references lines xref in-reply-to char)
509     (save-excursion
510       (save-restriction
511         (goto-char (point-min))
512         (narrow-to-region 
513          (point)
514          (1- (or (search-forward "\n\n" nil t) (point-max))))
515         ;; Fold continuation lines.
516         (goto-char (point-min))
517         (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
518           (replace-match " " t t))
519         (subst-char-in-region (point-min) (point-max) ?\t ? )
520         ;; [number subject from date id references chars lines xref]
521         (save-excursion
522           (goto-char (point-min))
523           (while (re-search-forward "^\\(from\\|subject\\|message-id\\|date\\|lines\\|xref\\|references\\|in-reply-to\\): "
524                                     nil t)
525             (beginning-of-line)
526             (setq char (downcase (following-char))) 
527             (cond
528              ((eq char ?s)
529               (setq subject (nnml-header-value)))
530              ((eq char ?f)
531               (setq from (nnml-header-value)))
532              ((eq char ?x)
533               (setq xref (nnml-header-value)))
534              ((eq char ?l)
535               (setq lines (nnml-header-value)))
536              ((eq char ?d)
537               (setq date (nnml-header-value)))
538              ((eq char ?m)
539               (setq id (setq id (nnml-header-value))))
540              ((eq char ?r)
541               (setq references (nnml-header-value)))
542              ((eq char ?i)
543               (setq in-reply-to (nnml-header-value))))
544             (forward-line 1))
545       
546           (and (not references)
547                in-reply-to
548                (string-match "<[^>]+>" in-reply-to)
549                (setq references
550                      (substring in-reply-to (match-beginning 0)
551                                 (match-end 0)))))
552         ;; [number subject from date id references chars lines xref]
553         (format "\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\t\n"
554                 (or subject "(none)")
555                 (or from "(nobody)") (or date "")
556                 (or id (concat "nnml-dummy-id-" 
557                                (mapconcat 
558                                 (lambda (time) (int-to-string time))
559                                 (current-time) "-")))
560                 (or references "")
561                 (or chars 0) (or lines "0") (or xref ""))))))
562
563 (defun nnml-open-nov (group)
564   (or (cdr (assoc group nnml-nov-buffer-alist))
565       (let ((buffer (find-file-noselect 
566                      (concat (nnmail-article-pathname 
567                               group nnml-directory) nnml-nov-file-name))))
568         (save-excursion
569           (set-buffer buffer)
570           (buffer-disable-undo (current-buffer)))
571         (setq nnml-nov-buffer-alist 
572               (cons (cons group buffer) nnml-nov-buffer-alist))
573         buffer)))
574
575 (defun nnml-save-nov ()
576   (save-excursion
577     (while nnml-nov-buffer-alist
578       (if (buffer-name (cdr (car nnml-nov-buffer-alist)))
579           (progn
580             (set-buffer (cdr (car nnml-nov-buffer-alist)))
581             (and (buffer-modified-p)
582                  (write-region 
583                   1 (point-max) (buffer-file-name) nil 'nomesg))
584             (set-buffer-modified-p nil)
585             (kill-buffer (current-buffer))))
586       (setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist)))))
587
588 ;;;###autoload
589 (defun nnml-generate-nov-databases (dir)
590   "Generate nov databases in all nnml mail newsgroups."
591   (interactive 
592    (progn   
593      (setq nnml-group-alist nil)
594      (list nnml-directory)))
595   (nnml-open-server (system-name))
596   (let ((dirs (directory-files dir t nil t)))
597     (while dirs 
598       (if (and (not (string-match "/\\.\\.$" (car dirs)))
599                (not (string-match "/\\.$" (car dirs)))
600                (file-directory-p (car dirs)))
601           (nnml-generate-nov-databases (car dirs)))
602       (setq dirs (cdr dirs))))
603   (let ((files (sort
604                 (mapcar
605                  (function
606                   (lambda (name)
607                     (string-to-int name)))
608                  (directory-files dir nil "^[0-9]+$" t))
609                 (function <)))
610         (nov (concat dir "/" nnml-nov-file-name))
611         (nov-buffer (get-buffer-create "*nov*"))
612         nov-line chars)
613     (if files
614         (setq nnml-group-alist 
615               (cons (list (nnmail-replace-chars-in-string 
616                            (substring (expand-file-name dir)
617                                       (length (expand-file-name 
618                                                nnml-directory)))
619                            ?/ ?.)
620                           (cons (car files)
621                                 (let ((f files))
622                                   (while (cdr f) (setq f (cdr f)))
623                                   (car f))))
624                     nnml-group-alist)))
625     (if files
626         (save-excursion
627           (set-buffer nntp-server-buffer)
628           (if (file-exists-p nov)
629               (delete-file nov))
630           (save-excursion
631             (set-buffer nov-buffer)
632             (buffer-disable-undo (current-buffer))
633             (erase-buffer))
634           (while files
635             (erase-buffer)
636             (insert-file-contents (concat dir "/" (int-to-string (car files))))
637             (goto-char 1)
638             (narrow-to-region 1 (save-excursion (search-forward "\n\n" nil t)
639                                                 (setq chars (- (point-max) 
640                                                                (point)))
641                                                 (point)))
642             (if (not (= 0 chars)) ; none of them empty files...
643                 (progn
644                   (setq nov-line (nnml-make-nov-line chars))
645                   (save-excursion
646                     (set-buffer nov-buffer)
647                     (goto-char (point-max))
648                     (insert (int-to-string (car files)) nov-line))))
649             (widen)
650             (setq files (cdr files)))
651           (save-excursion
652             (set-buffer nov-buffer)
653             (write-region 1 (point-max) (expand-file-name nov) nil
654                           'nomesg)
655             (kill-buffer (current-buffer)))))
656     (nnmail-save-active nnml-group-alist nnml-active-file)))
657
658 (defun nnml-nov-delete-article (group article)
659   (save-excursion
660     (set-buffer (nnml-open-nov group))
661     (goto-char 1)
662     (if (re-search-forward (concat "^" (int-to-string article) "\t") nil t)
663         (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
664     t))
665
666 (provide 'nnml)
667
668 ;;; nnml.el ends here