*** 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-close ()
212   (setq nnml-current-server nil)
213   (setq nnml-server-alist nil)
214   t)
215
216 (defun nnml-request-create-group (group &optional server) 
217   (nnml-request-list)
218   (setq nnml-group-alist (nnmail-get-active))
219   (or (assoc group nnml-group-alist)
220       (let (active)
221         (setq nnml-group-alist (cons (list group (setq active (cons 0 0)))
222                                      nnml-group-alist))
223         (nnml-possibly-create-directory group)
224         (nnml-possibly-change-directory group)
225         (let ((articles (mapcar
226                          (lambda (file)
227                            (int-to-string file))
228                          (directory-files 
229                           nnml-current-directory nil "^[0-9]+$"))))
230           (and articles
231                (progn
232                  (setcar active (apply 'min articles))
233                  (setcdr active (apply 'max articles)))))
234         (nnmail-save-active nnml-group-alist nnml-active-file)))
235   t)
236
237 (defun nnml-request-list (&optional server)
238   (if server (nnml-get-new-mail))
239   (save-excursion
240     (nnmail-find-file nnml-active-file)
241     (setq nnml-group-alist (nnmail-get-active))))
242
243 (defun nnml-request-newgroups (date &optional server)
244   (nnml-request-list server))
245
246 (defun nnml-request-list-newsgroups (&optional server)
247   (save-excursion
248     (nnmail-find-file nnml-newsgroups-file)))
249
250 (defun nnml-request-post (&optional server)
251   (mail-send-and-exit nil))
252
253 (fset 'nnml-request-post-buffer 'nnmail-request-post-buffer)
254
255 (defun nnml-request-expire-articles (articles newsgroup &optional server force)
256   (nnml-possibly-change-directory newsgroup)
257   (let* ((days (or (and nnmail-expiry-wait-function
258                         (funcall nnmail-expiry-wait-function newsgroup))
259                    nnmail-expiry-wait))
260          (active-articles 
261           (mapcar
262            (function
263             (lambda (name)
264               (string-to-int name)))
265            (directory-files nnml-current-directory nil "^[0-9]+$" t)))
266          (max-article (and active-articles (apply 'max active-articles)))
267          article rest mod-time)
268     (while articles
269       (setq article (concat nnml-current-directory (int-to-string
270                                                       (car articles))))
271       (if (setq mod-time (nth 5 (file-attributes article)))
272           (if (and (or (not nnmail-keep-last-article)
273                        (not max-article)
274                        (not (= (car articles) max-article)))
275                    (or force
276                        (> (nnmail-days-between
277                            (current-time-string)
278                            (current-time-string mod-time))
279                           days)))
280               (progn
281                 (and gnus-verbose-backends (message "Deleting %s..." article))
282                 (condition-case ()
283                     (delete-file article)
284                   (file-error nil))
285                 (setq active-articles (delq (car articles) active-articles))
286                 (nnml-nov-delete-article newsgroup (car articles)))
287             (setq rest (cons (car articles) rest))))
288       (setq articles (cdr articles)))
289     (let ((active (nth 1 (assoc newsgroup nnml-group-alist))))
290       (and active
291            (setcar active (or (and active-articles
292                                    (apply 'min active-articles))
293                               0)))
294       (nnmail-save-active nnml-group-alist nnml-active-file))
295     (nnml-save-nov)
296     (message "")
297     rest))
298
299 (defun nnml-request-move-article 
300   (article group server accept-form &optional last)
301   (let ((buf (get-buffer-create " *nnml move*"))
302         result)
303     (and 
304      (nnml-request-article article group server)
305      (save-excursion
306        (set-buffer buf)
307        (insert-buffer-substring nntp-server-buffer)
308        (setq result (eval accept-form))
309        (kill-buffer (current-buffer))
310        result)
311      (progn
312        (condition-case ()
313            (delete-file (concat nnml-current-directory 
314                                 (int-to-string article)))
315          (file-error nil))
316        (nnml-nov-delete-article group article)
317        (and last (nnml-save-nov))))
318     result))
319
320 (defun nnml-request-accept-article (group &optional last)
321   (let (result)
322     (if (stringp group)
323         (and 
324          (nnml-request-list)
325          (setq nnml-group-alist (nnmail-get-active))
326          ;; We trick the choosing function into believing that only one
327          ;; group is availiable.  
328          (let ((nnmail-split-methods (list (list group ""))))
329            (setq result (car (nnml-save-mail))))
330          (progn
331            (nnmail-save-active nnml-group-alist nnml-active-file)
332            (and last (nnml-save-nov))))
333       (and
334        (nnml-request-list)
335        (setq nnml-group-alist (nnmail-get-active))
336        (setq result (car (nnml-save-mail)))
337        (progn
338          (nnmail-save-active nnml-group-alist nnml-active-file)
339          (and last (nnml-save-nov)))))
340     result))
341
342 (defun nnml-request-replace-article (article group buffer)
343   (nnml-possibly-change-directory group)
344   (save-excursion
345     (set-buffer buffer)
346     (nnml-possibly-create-directory group)
347     (if (not (condition-case ()
348                  (progn
349                    (write-region (point-min) (point-max)
350                                  (concat nnml-current-directory 
351                                          (int-to-string article))
352                                  nil (if gnus-verbose-backends nil 'nomesg))
353                    t)
354                (error nil)))
355         ()
356       (let ((chars (nnmail-insert-lines))
357             (art (concat (int-to-string article) "\t"))
358             nov-line)
359         (setq nov-line (nnml-make-nov-line chars))
360         (save-excursion 
361           (set-buffer (nnml-open-nov group))
362           (goto-char (point-min))
363           (if (or (looking-at art)
364                   (search-forward (concat "\n" art)))
365               (progn
366                 (delete-region (progn (beginning-of-line) (point))
367                                (progn (forward-line 1) (point)))
368                 (insert (int-to-string article) nov-line)
369                 (nnml-save-nov))
370             (kill-buffer (current-buffer)))
371           t)))))
372
373
374 \f
375 ;;; Internal functions
376
377 (defun nnml-retrieve-headers-with-nov (articles)
378   (if (or gnus-nov-is-evil nnml-nov-is-evil)
379       nil
380     (let ((first (car articles))
381           (last (progn (while (cdr articles) (setq articles (cdr articles)))
382                        (car articles)))
383           (nov (concat nnml-current-directory nnml-nov-file-name)))
384       (if (file-exists-p nov)
385           (save-excursion
386             (set-buffer nntp-server-buffer)
387             (erase-buffer)
388             (insert-file-contents nov)
389             (goto-char 1)
390             (while (and (not (eobp)) (< first (read (current-buffer))))
391               (forward-line 1))
392             (beginning-of-line)
393             (if (not (eobp)) (delete-region 1 (point)))
394             (while (and (not (eobp)) (>= last (read (current-buffer))))
395               (forward-line 1))
396             (beginning-of-line)
397             (if (not (eobp)) (delete-region (point) (point-max)))
398             t)))))
399
400 (defun nnml-possibly-change-directory (newsgroup &optional force)
401   (if newsgroup
402       (let ((pathname (nnmail-article-pathname newsgroup nnml-directory)))
403         (and (or force (file-directory-p pathname))
404              (setq nnml-current-directory pathname)))
405     t))
406
407 (defun nnml-possibly-create-directory (group)
408   (let (dir dirs)
409     (setq dir (nnmail-article-pathname group nnml-directory))
410     (while (not (file-directory-p dir))
411       (setq dirs (cons dir dirs))
412       (setq dir (file-name-directory (directory-file-name dir))))
413     (while dirs
414       (if (make-directory (directory-file-name (car dirs)))
415           (error "Could not create directory %s" (car dirs)))
416       (and gnus-verbose-backends 
417            (message "Creating mail directory %s" (car dirs)))
418       (setq dirs (cdr dirs)))))
419              
420 (defun nnml-save-mail ()
421   "Called narrowed to an article."
422   (let ((group-art (nreverse (nnmail-article-group 'nnml-active-number)))
423         chars nov-line)
424     (setq chars (nnmail-insert-lines))
425     (nnmail-insert-xref group-art)
426     (goto-char (point-min))
427     (while (looking-at "From ")
428       (replace-match "X-From-Line: ")
429       (forward-line 1))
430     ;; We save the article in all the newsgroups it belongs in.
431     (let ((ga group-art)
432           first)
433       (while ga
434         (nnml-possibly-create-directory (car (car ga)))
435         (let ((file (concat (nnmail-article-pathname 
436                              (car (car ga)) nnml-directory)
437                             (int-to-string (cdr (car ga))))))
438           (if first
439               ;; It was already saved, so we just make a hard link.
440               (add-name-to-file first file t)
441             ;; Save the article.
442             (write-region (point-min) (point-max) file nil 
443                           (if gnus-verbose-backends nil 'nomesg))
444             (setq first file)))
445         (setq ga (cdr ga))))
446     ;; Generate a nov line for this article. We generate the nov
447     ;; line after saving, because nov generation destroys the
448     ;; header. 
449     (setq nov-line (nnml-make-nov-line chars))
450     ;; Output the nov line to all nov databases that should have it.
451     (let ((ga group-art))
452       (while ga
453         (nnml-add-nov (car (car ga)) (cdr (car ga)) nov-line)
454         (setq ga (cdr ga))))
455     group-art))
456
457 (defun nnml-active-number (group)
458   "Compute the next article number in GROUP."
459   (let ((active (car (cdr (assoc group nnml-group-alist)))))
460     (or active
461         (progn
462           (setq active (cons 1 0))
463           (setq nnml-group-alist (cons (list group active) nnml-group-alist))))
464     (setcdr active (1+ (cdr active)))
465     (let (file)
466       (while (file-exists-p
467               (setq file (concat (nnmail-article-pathname 
468                                   group nnml-directory)
469                                  (int-to-string (cdr active)))))
470         (setcdr active (1+ (cdr active)))))
471     (cdr active)))
472
473 (defun nnml-get-new-mail ()
474   "Read new incoming mail."
475   (let (incoming)
476     (if (and nnml-get-new-mail nnmail-spool-file
477              (file-exists-p nnmail-spool-file)
478              (> (nth 7 (file-attributes nnmail-spool-file)) 0))
479         (progn
480           (and gnus-verbose-backends 
481                (message "nnml: Reading incoming mail..."))
482           (setq incoming 
483                 (nnmail-move-inbox nnmail-spool-file 
484                                    (concat nnml-directory "Incoming")))
485           (nnml-request-list)
486           (setq nnml-group-alist (nnmail-get-active))
487           (nnmail-split-incoming incoming 'nnml-save-mail)
488           (nnmail-save-active nnml-group-alist nnml-active-file)
489           (nnml-save-nov)
490           (run-hooks 'nnmail-read-incoming-hook)
491           ;; The following has been commented away, just to make sure
492           ;; that nobody ever loses any mail. If you feel safe that
493           ;; nnml will never do anything strange, just remove those
494           ;; two semicolons, and avoid having lots of "Incoming*"
495           ;; files. 
496 ;;         (delete-file incoming)
497           (and gnus-verbose-backends
498                (message "nnml: Reading incoming mail...done"))))))
499
500
501 (defun nnml-add-nov (group article line)
502   "Add a nov line for the GROUP base."
503   (save-excursion 
504     (set-buffer (nnml-open-nov group))
505     (goto-char (point-max))
506     (insert (int-to-string article) line)))
507
508 (defsubst nnml-header-value ()
509   (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
510
511 (defun nnml-make-nov-line (chars)
512   "Create a nov from the current headers."
513   (let ((case-fold-search t)
514         subject from date id references lines xref in-reply-to char)
515     (save-excursion
516       (save-restriction
517         (goto-char (point-min))
518         (narrow-to-region 
519          (point)
520          (1- (or (search-forward "\n\n" nil t) (point-max))))
521         ;; Fold continuation lines.
522         (goto-char (point-min))
523         (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
524           (replace-match " " t t))
525         (subst-char-in-region (point-min) (point-max) ?\t ? )
526         ;; [number subject from date id references chars lines xref]
527         (save-excursion
528           (goto-char (point-min))
529           (while (re-search-forward "^\\(from\\|subject\\|message-id\\|date\\|lines\\|xref\\|references\\|in-reply-to\\): "
530                                     nil t)
531             (beginning-of-line)
532             (setq char (downcase (following-char))) 
533             (cond
534              ((eq char ?s)
535               (setq subject (nnml-header-value)))
536              ((eq char ?f)
537               (setq from (nnml-header-value)))
538              ((eq char ?x)
539               (setq xref (nnml-header-value)))
540              ((eq char ?l)
541               (setq lines (nnml-header-value)))
542              ((eq char ?d)
543               (setq date (nnml-header-value)))
544              ((eq char ?m)
545               (setq id (setq id (nnml-header-value))))
546              ((eq char ?r)
547               (setq references (nnml-header-value)))
548              ((eq char ?i)
549               (setq in-reply-to (nnml-header-value))))
550             (forward-line 1))
551       
552           (and (not references)
553                in-reply-to
554                (string-match "<[^>]+>" in-reply-to)
555                (setq references
556                      (substring in-reply-to (match-beginning 0)
557                                 (match-end 0)))))
558         ;; [number subject from date id references chars lines xref]
559         (format "\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\t\n"
560                 (or subject "(none)")
561                 (or from "(nobody)") (or date "")
562                 (or id (concat "nnml-dummy-id-" 
563                                (mapconcat 
564                                 (lambda (time) (int-to-string time))
565                                 (current-time) "-")))
566                 (or references "")
567                 (or chars 0) (or lines "0") (or xref ""))))))
568
569 (defun nnml-open-nov (group)
570   (or (cdr (assoc group nnml-nov-buffer-alist))
571       (let ((buffer (find-file-noselect 
572                      (concat (nnmail-article-pathname 
573                               group nnml-directory) nnml-nov-file-name))))
574         (save-excursion
575           (set-buffer buffer)
576           (buffer-disable-undo (current-buffer)))
577         (setq nnml-nov-buffer-alist 
578               (cons (cons group buffer) nnml-nov-buffer-alist))
579         buffer)))
580
581 (defun nnml-save-nov ()
582   (save-excursion
583     (while nnml-nov-buffer-alist
584       (if (buffer-name (cdr (car nnml-nov-buffer-alist)))
585           (progn
586             (set-buffer (cdr (car nnml-nov-buffer-alist)))
587             (and (buffer-modified-p)
588                  (write-region 
589                   1 (point-max) (buffer-file-name) nil 'nomesg))
590             (set-buffer-modified-p nil)
591             (kill-buffer (current-buffer))))
592       (setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist)))))
593
594 ;;;###autoload
595 (defun nnml-generate-nov-databases (dir)
596   "Generate nov databases in all nnml mail newsgroups."
597   (interactive 
598    (progn   
599      (setq nnml-group-alist nil)
600      (list nnml-directory)))
601   (nnml-open-server (or nnml-current-server ""))
602   (let ((dirs (directory-files dir t nil t)))
603     (while dirs 
604       (if (and (not (string-match "/\\.\\.$" (car dirs)))
605                (not (string-match "/\\.$" (car dirs)))
606                (file-directory-p (car dirs)))
607           (nnml-generate-nov-databases (car dirs)))
608       (setq dirs (cdr dirs))))
609   (let ((files (sort
610                 (mapcar
611                  (function
612                   (lambda (name)
613                     (string-to-int name)))
614                  (directory-files dir nil "^[0-9]+$" t))
615                 (function <)))
616         (nov (concat dir "/" nnml-nov-file-name))
617         (nov-buffer (get-buffer-create "*nov*"))
618         nov-line chars)
619     (if files
620         (setq nnml-group-alist 
621               (cons (list (nnmail-replace-chars-in-string 
622                            (substring (expand-file-name dir)
623                                       (length (expand-file-name 
624                                                nnml-directory)))
625                            ?/ ?.)
626                           (cons (car files)
627                                 (let ((f files))
628                                   (while (cdr f) (setq f (cdr f)))
629                                   (car f))))
630                     nnml-group-alist)))
631     (if files
632         (save-excursion
633           (set-buffer nntp-server-buffer)
634           (if (file-exists-p nov)
635               (delete-file nov))
636           (save-excursion
637             (set-buffer nov-buffer)
638             (buffer-disable-undo (current-buffer))
639             (erase-buffer))
640           (while files
641             (erase-buffer)
642             (insert-file-contents (concat dir "/" (int-to-string (car files))))
643             (goto-char 1)
644             (narrow-to-region 1 (save-excursion (search-forward "\n\n" nil t)
645                                                 (setq chars (- (point-max) 
646                                                                (point)))
647                                                 (point)))
648             (if (not (= 0 chars)) ; none of them empty files...
649                 (progn
650                   (setq nov-line (nnml-make-nov-line chars))
651                   (save-excursion
652                     (set-buffer nov-buffer)
653                     (goto-char (point-max))
654                     (insert (int-to-string (car files)) nov-line))))
655             (widen)
656             (setq files (cdr files)))
657           (save-excursion
658             (set-buffer nov-buffer)
659             (write-region 1 (point-max) (expand-file-name nov) nil
660                           'nomesg)
661             (kill-buffer (current-buffer)))))
662     (nnmail-save-active nnml-group-alist nnml-active-file)))
663
664 (defun nnml-nov-delete-article (group article)
665   (save-excursion
666     (set-buffer (nnml-open-nov group))
667     (goto-char 1)
668     (if (re-search-forward (concat "^" (int-to-string article) "\t") nil t)
669         (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
670     t))
671
672 (provide 'nnml)
673
674 ;;; nnml.el ends here