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
35 (eval-when-compile (require 'cl))
37 (defvar nnml-directory "~/Mail/"
38 "Mail spool directory.")
40 (defvar nnml-active-file
41 (concat (file-name-as-directory nnml-directory) "active")
44 (defvar nnml-newsgroups-file
45 (concat (file-name-as-directory nnml-directory) "newsgroups")
46 "Mail newsgroups description file.")
48 (defvar nnml-get-new-mail t
49 "If non-nil, nnml will check the incoming mail file and split the mail.")
51 (defvar nnml-nov-is-evil nil
52 "If non-nil, Gnus will never generate and use nov databases for mail groups.
53 Using nov databases will speed up header fetching considerably.
54 This variable shouldn't be flipped much. If you have, for some reason,
55 set this to t, and want to set it to nil again, you should always run
56 the `nnml-generate-nov-databases' command. The function will go
57 through all nnml directories and generate nov databases for them
58 all. This may very well take some time.")
60 (defvar nnml-prepare-save-mail-hook nil
61 "Hook run narrowed to an article before saving.")
63 (defvar nnml-inhibit-expiry nil
64 "If non-nil, inhibit expiry.")
69 (defconst nnml-version "nnml 1.0"
72 (defvar nnml-nov-file-name ".overview")
74 (defvar nnml-current-directory nil)
75 (defvar nnml-current-group nil)
76 (defvar nnml-status-string "")
77 (defvar nnml-nov-buffer-alist nil)
78 (defvar nnml-group-alist nil)
79 (defvar nnml-active-timestamp nil)
80 (defvar nnml-article-file-alist nil)
82 (defvar nnml-generate-active-function 'nnml-generate-active-info)
88 (defvar nnml-current-server nil)
89 (defvar nnml-server-alist nil)
90 (defvar nnml-server-variables
91 `((nnml-directory ,nnml-directory)
92 (nnml-active-file ,nnml-active-file)
93 (nnml-newsgroups-file ,nnml-newsgroups-file)
94 (nnml-get-new-mail ,nnml-get-new-mail)
95 (nnml-nov-is-evil ,nnml-nov-is-evil)
96 (nnml-nov-file-name ,nnml-nov-file-name)
97 (nnml-current-directory nil)
98 (nnml-generate-active-function ,nnml-generate-active-function)
99 (nnml-article-file-alist nil)
100 (nnml-prepare-save-mail-hook ,nnml-prepare-save-mail-hook)
101 (nnml-current-group nil)
102 (nnml-inhibit-expiry ,nnml-inhibit-expiry)
103 (nnml-status-string "")
104 (nnml-nov-buffer-alist nil)
105 (nnml-group-alist nil)
106 (nnml-active-timestamp nil)))
110 ;;; Interface functions.
112 (defun nnml-retrieve-headers (sequence &optional newsgroup server fetch-old)
114 (set-buffer nntp-server-buffer)
117 (number (length sequence))
120 (if (stringp (car sequence))
122 (nnml-possibly-change-directory newsgroup server)
123 (unless nnml-article-file-alist
124 (setq nnml-article-file-alist
125 (nnheader-article-to-file-alist nnml-current-directory)))
126 (if (nnml-retrieve-headers-with-nov sequence fetch-old)
129 (setq article (car sequence))
131 (concat nnml-current-directory
132 (or (cdr (assq article nnml-article-file-alist))
134 (if (and (file-exists-p file)
135 (not (file-directory-p file)))
137 (insert (format "221 %d Article retrieved.\n" article))
139 (nnheader-insert-head file)
141 (if (search-forward "\n\n" nil t)
143 (goto-char (point-max))
146 (delete-region (point) (point-max))))
147 (setq sequence (cdr sequence))
148 (setq count (1+ count))
149 (and (numberp nnmail-large-newsgroup)
150 (> number nnmail-large-newsgroup)
152 (nnheader-message 6 "nnml: Receiving headers... %d%%"
153 (/ (* count 100) number))))
155 (and (numberp nnmail-large-newsgroup)
156 (> number nnmail-large-newsgroup)
157 (nnheader-message 6 "nnml: Receiving headers...done"))
159 (nnheader-fold-continuation-lines)
162 (defun nnml-open-server (server &optional defs)
163 (nnheader-change-server 'nnml server defs)
164 (when (not (file-exists-p nnml-directory))
166 (make-directory nnml-directory t)
169 ((not (file-exists-p nnml-directory))
171 (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory))
172 ((not (file-directory-p (file-truename nnml-directory)))
174 (nnheader-report 'nnml "Not a directory: %s" nnml-directory))
176 (nnheader-report 'nnml "Opened server %s using directory %s"
177 server nnml-directory)
180 (defun nnml-close-server (&optional server)
181 (setq nnml-current-server nil
182 nnml-group-alist nil)
185 (defun nnml-server-opened (&optional server)
186 (and (equal server nnml-current-server)
188 (buffer-name nntp-server-buffer)))
190 (defun nnml-status-message (&optional server)
193 (defun nnml-request-article (id &optional newsgroup server buffer)
194 (nnml-possibly-change-directory newsgroup server)
195 (let* ((nntp-server-buffer (or buffer nntp-server-buffer))
196 file path gpath group-num)
198 (when (and (setq group-num (nnml-find-group-number id))
200 (assq (cdr group-num)
201 (nnheader-article-to-file-alist
203 (nnmail-group-pathname
205 nnml-directory)))))))
206 (setq path (concat gpath (int-to-string (cdr group-num)))))
207 (unless nnml-article-file-alist
208 (setq nnml-article-file-alist
209 (nnheader-article-to-file-alist nnml-current-directory)))
210 (when (setq file (cdr (assq id nnml-article-file-alist)))
211 (setq path (concat nnml-current-directory file))))
214 (nnheader-report 'nnml "No such article: %s" id))
215 ((not (file-exists-p path))
216 (nnheader-report 'nnml "No such file: %s" path))
217 ((file-directory-p path)
218 (nnheader-report 'nnml "File is a directory: %s" path))
219 ((not (save-excursion (nnmail-find-file path)))
220 (nnheader-report 'nnml "Couldn't read file: %s" path))
222 (nnheader-report 'nnml "Article %s retrieved" id)
223 ;; We return the article number.
224 (cons newsgroup (string-to-int (file-name-nondirectory path)))))))
226 (defun nnml-request-group (group &optional server dont-check)
228 ((not (nnml-possibly-change-directory group server))
229 (nnheader-report 'nnml "Invalid group (no such directory)"))
231 (nnheader-report 'nnml "Group %s selected" group)
234 (nnmail-activate 'nnml)
235 (let ((active (nth 1 (assoc group nnml-group-alist))))
237 (nnheader-report 'nnml "No such group: %s" group)
238 (nnheader-report 'nnml "Selected group %s" group)
239 (nnheader-insert "211 %d %d %d %s\n"
240 (max (1+ (- (cdr active) (car active))) 0)
241 (car active) (cdr active) group))))))
243 (defun nnml-request-scan (&optional group server)
244 (setq nnml-article-file-alist nil)
245 (nnmail-get-new-mail 'nnml 'nnml-save-nov nnml-directory group))
247 (defun nnml-close-group (group &optional server)
248 (setq nnml-article-file-alist nil)
251 (defun nnml-request-close ()
252 (setq nnml-current-server nil
253 nnml-article-file-alist nil
254 nnml-server-alist nil)
257 (defun nnml-request-create-group (group &optional server)
258 (nnmail-activate 'nnml)
259 (or (assoc group nnml-group-alist)
261 (setq nnml-group-alist (cons (list group (setq active (cons 1 0)))
263 (nnml-possibly-create-directory group)
264 (nnml-possibly-change-directory group server)
266 (nnheader-directory-articles nnml-current-directory )))
269 (setcar active (apply 'min articles))
270 (setcdr active (apply 'max articles)))))
271 (nnmail-save-active nnml-group-alist nnml-active-file)))
274 (defun nnml-request-list (&optional server)
276 (nnmail-find-file nnml-active-file)
277 (setq nnml-group-alist (nnmail-get-active))))
279 (defun nnml-request-newgroups (date &optional server)
280 (nnml-request-list server))
282 (defun nnml-request-list-newsgroups (&optional server)
284 (nnmail-find-file nnml-newsgroups-file)))
286 (defun nnml-request-expire-articles (articles newsgroup &optional server force)
287 (nnml-possibly-change-directory newsgroup server)
288 (let* ((active-articles
289 (nnheader-directory-articles nnml-current-directory))
291 article rest mod-time number)
292 (nnmail-activate 'nnml)
294 (unless nnml-article-file-alist
295 (setq nnml-article-file-alist
296 (nnheader-article-to-file-alist nnml-current-directory)))
298 (while (and articles is-old)
299 (setq article (concat nnml-current-directory
301 (setq number (pop articles)))))
302 (when (setq mod-time (nth 5 (file-attributes article)))
303 (if (and (nnml-deletable-article-p newsgroup number)
305 (nnmail-expired-article-p newsgroup mod-time force
306 nnml-inhibit-expiry)))
308 (nnheader-message 5 "Deleting article %s in %s..."
311 (funcall nnmail-delete-file-function article)
314 (setq active-articles (delq number active-articles))
315 (nnml-nov-delete-article newsgroup number))
316 (push number rest))))
317 (let ((active (nth 1 (assoc newsgroup nnml-group-alist))))
319 (setcar active (or (and active-articles
320 (apply 'min active-articles))
322 (nnmail-save-active nnml-group-alist nnml-active-file))
325 (nconc rest articles)))
327 (defun nnml-request-move-article
328 (article group server accept-form &optional last)
329 (let ((buf (get-buffer-create " *nnml move*"))
331 (nnml-possibly-change-directory group server)
332 (unless nnml-article-file-alist
333 (setq nnml-article-file-alist
334 (nnheader-article-to-file-alist nnml-current-directory)))
336 (nnml-deletable-article-p group article)
337 (nnml-request-article article group server)
340 (insert-buffer-substring nntp-server-buffer)
341 (setq result (eval accept-form))
342 (kill-buffer (current-buffer))
346 (funcall nnmail-delete-file-function
347 (concat nnml-current-directory
348 (int-to-string article)))
350 (nnml-nov-delete-article group article)
351 (and last (nnml-save-nov))))
354 (defun nnml-request-accept-article (group &optional server last)
355 (nnml-possibly-change-directory group server)
359 (nnmail-activate 'nnml)
360 ;; We trick the choosing function into believing that only one
361 ;; group is available.
362 (let ((nnmail-split-methods (list (list group ""))))
363 (setq result (car (nnml-save-mail))))
365 (nnmail-save-active nnml-group-alist nnml-active-file)
366 (and last (nnml-save-nov))))
368 (nnmail-activate 'nnml)
369 (setq result (car (nnml-save-mail)))
371 (nnmail-save-active nnml-group-alist nnml-active-file)
372 (and last (nnml-save-nov)))))
375 (defun nnml-request-replace-article (article group buffer)
376 (nnml-possibly-change-directory group)
379 (nnml-possibly-create-directory group)
380 (if (not (condition-case ()
382 (write-region (point-min) (point-max)
383 (concat nnml-current-directory
384 (int-to-string article))
385 nil (if (nnheader-be-verbose 5) nil 'nomesg))
389 (let ((chars (nnmail-insert-lines))
390 (art (concat (int-to-string article) "\t"))
392 (setq nov-line (nnml-make-nov-line chars))
393 ;; Replace the NOV line in the NOV file.
395 (set-buffer (nnml-open-nov group))
396 (goto-char (point-min))
397 (if (or (looking-at art)
398 (search-forward (concat "\n" art) nil t))
399 ;; Delete the old NOV line.
400 (delete-region (progn (beginning-of-line) (point))
401 (progn (forward-line 1) (point)))
402 ;; The line isn't here, so we have to find out where
403 ;; we should insert it. (This situation should never
404 ;; occur, but one likes to make sure...)
405 (while (and (looking-at "[0-9]+\t")
408 (match-beginning 0) (match-end 0)))
410 (zerop (forward-line 1)))))
412 (insert (int-to-string article) nov-line)
416 (defun nnml-request-delete-group (group &optional force server)
417 (nnml-possibly-change-directory group server)
419 ;; Delete all articles in GROUP.
422 nnml-current-directory t
423 (concat nnheader-numerical-short-files
424 "\\|" (regexp-quote nnml-nov-file-name) "$")))
427 (setq article (pop articles))
428 (when (file-writable-p article)
429 (nnheader-message 5 "Deleting article %s in %s..." article group)
430 (funcall nnmail-delete-file-function article))))
431 ;; Try to delete the directory itself.
433 (delete-directory nnml-current-directory)
435 ;; Remove the group from all structures.
436 (setq nnml-group-alist
437 (delq (assoc group nnml-group-alist) nnml-group-alist)
438 nnml-current-group nil
439 nnml-current-directory nil)
440 ;; Save the active file.
441 (nnmail-save-active nnml-group-alist nnml-active-file)
444 (defun nnml-request-rename-group (group new-name &optional server)
445 (nnml-possibly-change-directory group server)
447 (and (file-writable-p nnml-current-directory)
452 (nnmail-group-pathname new-name nnml-directory)))))
453 (unless (file-exists-p parent)
454 (make-directory parent t))
456 (directory-file-name nnml-current-directory)
458 (nnmail-group-pathname new-name nnml-directory)))
461 ;; That went ok, so we change the internal structures.
462 (let ((entry (assoc group nnml-group-alist)))
463 (and entry (setcar entry new-name))
464 (setq nnml-current-directory nil
465 nnml-current-group nil)
466 ;; Save the new group alist.
467 (nnmail-save-active nnml-group-alist nnml-active-file)
471 ;;; Internal functions.
473 (defun nnml-deletable-article-p (group article)
474 "Say whether ARTICLE in GROUP can be deleted."
476 (when (setq file (cdr (assq article nnml-article-file-alist)))
477 (setq path (concat nnml-current-directory file))
478 (and (file-writable-p path)
479 (or (not nnmail-keep-last-article)
480 (not (eq (cdr (nth 1 (assoc group nnml-group-alist)))
483 ;; Find an article number in the current group given the Message-ID.
484 (defun nnml-find-group-number (id)
486 (set-buffer (get-buffer-create " *nnml id*"))
487 (buffer-disable-undo (current-buffer))
488 (let ((alist nnml-group-alist)
490 ;; We want to look through all .overview files, but we want to
491 ;; start with the one in the current directory. It seems most
492 ;; likely that the article we are looking for is in that group.
493 (if (setq number (nnml-find-id nnml-current-group id))
494 (cons nnml-current-group number)
495 ;; It wasn't there, so we look through the other groups as well.
496 (while (and (not number)
498 (or (string= (caar alist) nnml-current-group)
499 (setq number (nnml-find-id (caar alist) id)))
501 (setq alist (cdr alist))))
503 (cons (caar alist) number))))))
505 (defun nnml-find-id (group id)
507 (let ((nov (concat (nnmail-group-pathname group nnml-directory)
510 (when (file-exists-p nov)
511 (insert-file-contents nov)
512 (while (and (not found)
513 (search-forward id nil t)) ; We find the ID.
514 ;; And the id is in the fourth field.
516 "\t" (save-excursion (beginning-of-line) (point)) t 4)
520 ;; We return the article number.
523 (read (current-buffer))
527 (defun nnml-retrieve-headers-with-nov (articles &optional fetch-old)
528 (if (or gnus-nov-is-evil nnml-nov-is-evil)
530 (let ((first (car articles))
531 (last (progn (while (cdr articles) (setq articles (cdr articles)))
533 (nov (concat nnml-current-directory nnml-nov-file-name)))
534 (when (file-exists-p nov)
536 (set-buffer nntp-server-buffer)
538 (insert-file-contents nov)
540 (not (numberp fetch-old)))
541 t ; Don't remove anything.
543 (setq first (max 1 (- first fetch-old))))
544 (goto-char (point-min))
545 (while (and (not (eobp)) (> first (read (current-buffer))))
548 (if (not (eobp)) (delete-region 1 (point)))
549 (while (and (not (eobp)) (>= last (read (current-buffer))))
552 (if (not (eobp)) (delete-region (point) (point-max)))
555 (defun nnml-possibly-change-directory (group &optional server)
557 (not (nnml-server-opened server)))
558 (nnml-open-server server))
560 (let ((pathname (nnmail-group-pathname group nnml-directory)))
561 (when (not (equal pathname nnml-current-directory))
562 (setq nnml-current-directory pathname
563 nnml-current-group group
564 nnml-article-file-alist nil))))
567 (defun nnml-possibly-create-directory (group)
569 (setq dir (nnmail-group-pathname group nnml-directory))
570 (while (not (file-directory-p dir))
571 (setq dirs (cons dir dirs))
572 (setq dir (file-name-directory (directory-file-name dir))))
574 (make-directory (directory-file-name (car dirs)))
575 (nnheader-message 5 "Creating mail directory %s" (car dirs))
576 (setq dirs (cdr dirs)))))
578 (defun nnml-save-mail ()
579 "Called narrowed to an article."
580 (let ((group-art (nreverse (nnmail-article-group 'nnml-active-number)))
582 (setq chars (nnmail-insert-lines))
583 (nnmail-insert-xref group-art)
584 (run-hooks 'nnml-prepare-save-mail-hook)
585 (goto-char (point-min))
586 (while (looking-at "From ")
587 (replace-match "X-From-Line: ")
589 ;; We save the article in all the newsgroups it belongs in.
593 (nnml-possibly-create-directory (caar ga))
594 (let ((file (concat (nnmail-group-pathname
595 (caar ga) nnml-directory)
596 (int-to-string (cdar ga)))))
598 ;; It was already saved, so we just make a hard link.
599 (funcall nnmail-crosspost-link-function first file t)
601 (write-region (point-min) (point-max) file nil
602 (if (nnheader-be-verbose 5) nil 'nomesg))
605 ;; Generate a nov line for this article. We generate the nov
606 ;; line after saving, because nov generation destroys the
608 (setq nov-line (nnml-make-nov-line chars))
609 ;; Output the nov line to all nov databases that should have it.
610 (let ((ga group-art))
612 (nnml-add-nov (caar ga) (cdar ga) nov-line)
616 (defun nnml-active-number (group)
617 "Compute the next article number in GROUP."
618 (let ((active (cadr (assoc group nnml-group-alist))))
619 ;; The group wasn't known to nnml, so we just create an active
623 (setq active (cons 1 0))
624 (setq nnml-group-alist (cons (list group active) nnml-group-alist))))
625 (setcdr active (1+ (cdr active)))
626 (while (file-exists-p
627 (concat (nnmail-group-pathname group nnml-directory)
628 (int-to-string (cdr active))))
629 (setcdr active (1+ (cdr active))))
632 (defun nnml-add-nov (group article line)
633 "Add a nov line for the GROUP base."
635 (set-buffer (nnml-open-nov group))
636 (goto-char (point-max))
637 (insert (int-to-string article) line)))
639 (defsubst nnml-header-value ()
640 (buffer-substring (match-end 0) (progn (end-of-line) (point))))
642 (defun nnml-make-nov-line (chars)
643 "Create a nov from the current headers."
644 (let ((case-fold-search t)
645 subject from date id references lines xref in-reply-to char)
648 (goto-char (point-min))
651 (1- (or (search-forward "\n\n" nil t) (point-max))))
652 ;; Fold continuation lines.
653 (goto-char (point-min))
654 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
655 (replace-match " " t t))
656 (subst-char-in-region (point-min) (point-max) ?\t ? )
657 ;; [number subject from date id references chars lines xref]
659 (goto-char (point-min))
660 (while (re-search-forward "^\\(from\\|subject\\|message-id\\|date\\|lines\\|xref\\|references\\|in-reply-to\\): "
663 (setq char (downcase (following-char)))
666 (setq subject (nnml-header-value)))
668 (setq from (nnml-header-value)))
670 (setq xref (buffer-substring (match-beginning 0)
671 (progn (end-of-line) (point)))))
673 (setq lines (nnml-header-value)))
675 (setq date (nnml-header-value)))
677 (setq id (setq id (nnml-header-value))))
679 (setq references (nnml-header-value)))
681 (setq in-reply-to (nnml-header-value))))
684 (and (not references)
686 (string-match "<[^>]+>" in-reply-to)
688 (substring in-reply-to (match-beginning 0)
690 ;; [number subject from date id references chars lines xref]
691 (format "\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\t\n"
692 (or subject "(none)") (or from "(nobody)") (or date "")
693 (or id (nnmail-message-id))
694 (or references "") (or chars 0) (or lines "0")
697 (defun nnml-open-nov (group)
698 (or (cdr (assoc group nnml-nov-buffer-alist))
699 (let ((buffer (find-file-noselect
700 (concat (nnmail-group-pathname group nnml-directory)
701 nnml-nov-file-name))))
704 (buffer-disable-undo (current-buffer)))
705 (setq nnml-nov-buffer-alist
706 (cons (cons group buffer) nnml-nov-buffer-alist))
709 (defun nnml-save-nov ()
711 (while nnml-nov-buffer-alist
712 (when (buffer-name (cdar nnml-nov-buffer-alist))
713 (set-buffer (cdar nnml-nov-buffer-alist))
714 (and (buffer-modified-p)
716 1 (point-max) (buffer-file-name) nil 'nomesg))
717 (set-buffer-modified-p nil)
718 (kill-buffer (current-buffer)))
719 (setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist)))))
722 (defun nnml-generate-nov-databases ()
723 "Generate nov databases in all nnml directories."
725 ;; Read the active file to make sure we don't re-use articles
726 ;; numbers in empty groups.
727 (nnmail-activate 'nnml)
728 (nnml-open-server (or nnml-current-server ""))
729 (setq nnml-directory (expand-file-name nnml-directory))
730 ;; Recurse down the directories.
731 (nnml-generate-nov-databases-1 nnml-directory)
732 ;; Save the active file.
733 (nnmail-save-active nnml-group-alist nnml-active-file))
735 (defun nnml-generate-nov-databases-1 (dir)
736 (setq dir (file-name-as-directory dir))
737 ;; We descend recursively
738 (let ((dirs (directory-files dir t nil t))
741 (setq dir (pop dirs))
742 (when (and (not (string-match "/\\.\\.?$" dir))
743 (file-directory-p dir))
744 (nnml-generate-nov-databases-1 dir))))
745 ;; Do this directory.
748 (lambda (name) (string-to-int name))
749 (directory-files dir nil "^[0-9]+$" t))
752 (funcall nnml-generate-active-function dir)
753 ;; Generate the nov file.
754 (nnml-generate-nov-file dir files))))
756 (defun nnml-generate-active-info (dir)
757 ;; Update the active info for this group.
758 (let ((group (nnheader-file-to-group
759 (directory-file-name dir) nnml-directory)))
760 (setq nnml-group-alist
761 (delq (assoc group nnml-group-alist) nnml-group-alist))
765 (while (cdr f) (setq f (cdr f)))
769 (defun nnml-generate-nov-file (dir files)
770 (let* ((dir (file-name-as-directory dir))
771 (nov (concat dir nnml-nov-file-name))
772 (nov-buffer (get-buffer-create " *nov*"))
775 ;; Init the nov buffer.
776 (set-buffer nov-buffer)
777 (buffer-disable-undo (current-buffer))
779 (set-buffer nntp-server-buffer)
780 ;; Delete the old NOV file.
781 (when (file-exists-p nov)
782 (funcall nnmail-delete-file-function nov))
784 (unless (file-directory-p
785 (setq file (concat dir (int-to-string (car files)))))
787 (insert-file-contents file)
789 (goto-char (point-min))
791 (search-forward "\n\n" nil t)
792 (setq chars (- (point-max) (point)))
793 (max 1 (1- (point)))))
794 (when (and (not (= 0 chars)) ; none of them empty files...
795 (not (= (point-min) (point-max))))
796 (goto-char (point-min))
797 (setq nov-line (nnml-make-nov-line chars))
799 (set-buffer nov-buffer)
800 (goto-char (point-max))
801 (insert (int-to-string (car files)) nov-line)))
803 (setq files (cdr files)))
805 (set-buffer nov-buffer)
806 (write-region 1 (point-max) (expand-file-name nov) nil
808 (kill-buffer (current-buffer))))))
810 (defun nnml-nov-delete-article (group article)
812 (set-buffer (nnml-open-nov group))
813 (goto-char (point-min))
814 (if (re-search-forward (concat "^" (int-to-string article) "\t") nil t)
815 (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
820 ;;; nnml.el ends here