lisp/ChangeLog addition:
[gnus] / lisp / nnml.el
1 ;;; nnml.el --- mail spool access for Gnus
2
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;;   2004, 2005 Free Software Foundation, Inc.
5
6 ;; Authors: Didier Verna <didier@xemacs.org> (adding compaction)
7 ;;      Simon Josefsson <simon@josefsson.org> (adding MARKS)
8 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;;      Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
10 ;; Keywords: news, mail
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
28
29 ;;; Commentary:
30
31 ;; Based on nnspool.el by Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>.
32 ;; For an overview of what the interface functions do, please see the
33 ;; Gnus sources.
34
35 ;;; Code:
36
37 (require 'gnus)
38 (require 'nnheader)
39 (require 'nnmail)
40 (require 'gnus-bcklg)
41 (require 'nnoo)
42 (eval-when-compile (require 'cl))
43
44 (eval-and-compile
45   (autoload 'gnus-article-unpropagatable-p "gnus-sum"))
46
47 (nnoo-declare nnml)
48
49 (defvoo nnml-directory message-directory
50   "Spool directory for the nnml mail backend.")
51
52 (defvoo nnml-active-file
53     (expand-file-name "active" nnml-directory)
54   "Mail active file.")
55
56 (defvoo nnml-newsgroups-file
57     (expand-file-name "newsgroups" nnml-directory)
58   "Mail newsgroups description file.")
59
60 (defvoo nnml-get-new-mail t
61   "If non-nil, nnml will check the incoming mail file and split the mail.")
62
63 (defvoo nnml-nov-is-evil nil
64   "If non-nil, Gnus will never generate and use nov databases for mail spools.
65 Using nov databases will speed up header fetching considerably.
66 This variable shouldn't be flipped much.  If you have, for some reason,
67 set this to t, and want to set it to nil again, you should always run
68 the `nnml-generate-nov-databases' command.  The function will go
69 through all nnml directories and generate nov databases for them
70 all.  This may very well take some time.")
71
72 (defvoo nnml-marks-is-evil nil
73   "If non-nil, Gnus will never generate and use marks file for mail spools.
74 Using marks files makes it possible to backup and restore mail groups
75 separately from `.newsrc.eld'.  If you have, for some reason, set this
76 to t, and want to set it to nil again, you should always remove the
77 corresponding marks file (usually named `.marks' in the nnml group
78 directory, but see `nnml-marks-file-name') for the group.  Then the
79 marks file will be regenerated properly by Gnus.")
80
81 (defvoo nnml-prepare-save-mail-hook nil
82   "Hook run narrowed to an article before saving.")
83
84 (defvoo nnml-inhibit-expiry nil
85   "If non-nil, inhibit expiry.")
86
87 (defvoo nnml-use-compressed-files nil
88   "If non-nil, allow using compressed message files.")
89
90 (defvoo nnml-compressed-files-size-threshold 1000
91   "Default size threshold for compressed message files.
92 Message files with bodies larger than that many characters will
93 be automatically compressed if `nnml-use-compressed-files' is
94 non-nil.")
95
96 \f
97
98 (defconst nnml-version "nnml 1.0"
99   "nnml version.")
100
101 (defvoo nnml-nov-file-name ".overview")
102 (defvoo nnml-marks-file-name ".marks")
103
104 (defvoo nnml-current-directory nil)
105 (defvoo nnml-current-group nil)
106 (defvoo nnml-status-string "")
107 (defvoo nnml-nov-buffer-alist nil)
108 (defvoo nnml-group-alist nil)
109 (defvoo nnml-active-timestamp nil)
110 (defvoo nnml-article-file-alist nil)
111
112 (defvoo nnml-generate-active-function 'nnml-generate-active-info)
113
114 (defvar nnml-nov-buffer-file-name nil)
115
116 (defvoo nnml-file-coding-system nnmail-file-coding-system)
117
118 (defvoo nnml-marks nil)
119
120 (defvar nnml-marks-modtime (gnus-make-hashtable))
121
122 \f
123 ;;; Interface functions.
124
125 (nnoo-define-basics nnml)
126
127 (deffoo nnml-retrieve-headers (sequence &optional group server fetch-old)
128   (when (nnml-possibly-change-directory group server)
129     (save-excursion
130       (set-buffer nntp-server-buffer)
131       (erase-buffer)
132       (let* ((file nil)
133              (number (length sequence))
134              (count 0)
135              (file-name-coding-system nnmail-pathname-coding-system)
136              beg article)
137         (if (stringp (car sequence))
138             'headers
139           (if (nnml-retrieve-headers-with-nov sequence fetch-old)
140               'nov
141             (while sequence
142               (setq article (car sequence))
143               (setq file (nnml-article-to-file article))
144               (when (and file
145                          (file-exists-p file)
146                          (not (file-directory-p file)))
147                 (insert (format "221 %d Article retrieved.\n" article))
148                 (setq beg (point))
149                 (nnheader-insert-head file)
150                 (goto-char beg)
151                 (if (re-search-forward "\n\r?\n" nil t)
152                     (forward-char -1)
153                   (goto-char (point-max))
154                   (insert "\n\n"))
155                 (insert ".\n")
156                 (delete-region (point) (point-max)))
157               (setq sequence (cdr sequence))
158               (setq count (1+ count))
159               (and (numberp nnmail-large-newsgroup)
160                    (> number nnmail-large-newsgroup)
161                    (zerop (% count 20))
162                    (nnheader-message 6 "nnml: Receiving headers... %d%%"
163                                      (/ (* count 100) number))))
164
165             (and (numberp nnmail-large-newsgroup)
166                  (> number nnmail-large-newsgroup)
167                  (nnheader-message 6 "nnml: Receiving headers...done"))
168
169             (nnheader-fold-continuation-lines)
170             'headers))))))
171
172 (deffoo nnml-open-server (server &optional defs)
173   (nnoo-change-server 'nnml server defs)
174   (when (not (file-exists-p nnml-directory))
175     (ignore-errors (make-directory nnml-directory t)))
176   (cond
177    ((not (file-exists-p nnml-directory))
178     (nnml-close-server)
179     (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory))
180    ((not (file-directory-p (file-truename nnml-directory)))
181     (nnml-close-server)
182     (nnheader-report 'nnml "Not a directory: %s" nnml-directory))
183    (t
184     (nnheader-report 'nnml "Opened server %s using directory %s"
185                      server nnml-directory)
186     t)))
187
188 (deffoo nnml-request-regenerate (server)
189   (nnml-possibly-change-directory nil server)
190   (nnml-generate-nov-databases server)
191   t)
192
193 (deffoo nnml-request-article (id &optional group server buffer)
194   (nnml-possibly-change-directory group server)
195   (let* ((nntp-server-buffer (or buffer nntp-server-buffer))
196          (file-name-coding-system nnmail-pathname-coding-system)
197          path gpath group-num)
198     (if (stringp id)
199         (when (and (setq group-num (nnml-find-group-number id))
200                    (cdr
201                     (assq (cdr group-num)
202                           (nnheader-article-to-file-alist
203                            (setq gpath
204                                  (nnmail-group-pathname
205                                   (car group-num)
206                                   nnml-directory))))))
207           (setq path (concat gpath (int-to-string (cdr group-num)))))
208       (setq path (nnml-article-to-file id)))
209     (cond
210      ((not path)
211       (nnheader-report 'nnml "No such article: %s" id))
212      ((not (file-exists-p path))
213       (nnheader-report 'nnml "No such file: %s" path))
214      ((file-directory-p path)
215       (nnheader-report 'nnml "File is a directory: %s" path))
216      ((not (save-excursion (let ((nnmail-file-coding-system
217                                   nnml-file-coding-system))
218                              (nnmail-find-file path))))
219       (nnheader-report 'nnml "Couldn't read file: %s" path))
220      (t
221       (nnheader-report 'nnml "Article %s retrieved" id)
222       ;; We return the article number.
223       (cons (if group-num (car group-num) group)
224             (string-to-number (file-name-nondirectory path)))))))
225
226 (deffoo nnml-request-group (group &optional server dont-check)
227   (let ((file-name-coding-system nnmail-pathname-coding-system))
228     (cond
229      ((not (nnml-possibly-change-directory group server))
230       (nnheader-report 'nnml "Invalid group (no such directory)"))
231      ((not (file-exists-p nnml-current-directory))
232       (nnheader-report 'nnml "Directory %s does not exist"
233                        nnml-current-directory))
234      ((not (file-directory-p nnml-current-directory))
235       (nnheader-report 'nnml "%s is not a directory" nnml-current-directory))
236      (dont-check
237       (nnheader-report 'nnml "Group %s selected" group)
238       t)
239      (t
240       (nnheader-re-read-dir nnml-current-directory)
241       (nnmail-activate 'nnml)
242       (let ((active (nth 1 (assoc group nnml-group-alist))))
243         (if (not active)
244             (nnheader-report 'nnml "No such group: %s" group)
245           (nnheader-report 'nnml "Selected group %s" group)
246           (nnheader-insert "211 %d %d %d %s\n"
247                            (max (1+ (- (cdr active) (car active))) 0)
248                            (car active) (cdr active) group)))))))
249
250 (deffoo nnml-request-scan (&optional group server)
251   (setq nnml-article-file-alist nil)
252   (nnml-possibly-change-directory group server)
253   (nnmail-get-new-mail 'nnml 'nnml-save-nov nnml-directory group))
254
255 (deffoo nnml-close-group (group &optional server)
256   (setq nnml-article-file-alist nil)
257   t)
258
259 (deffoo nnml-request-create-group (group &optional server args)
260   (nnml-possibly-change-directory nil server)
261   (nnmail-activate 'nnml)
262   (cond
263    ((assoc group nnml-group-alist)
264     t)
265    ((and (file-exists-p (nnmail-group-pathname group nnml-directory))
266          (not (file-directory-p (nnmail-group-pathname group nnml-directory))))
267     (nnheader-report 'nnml "%s is a file"
268                      (nnmail-group-pathname group nnml-directory)))
269    (t
270     (let (active)
271       (push (list group (setq active (cons 1 0)))
272             nnml-group-alist)
273       (nnml-possibly-create-directory group)
274       (nnml-possibly-change-directory group server)
275       (let ((articles (nnml-directory-articles nnml-current-directory)))
276         (when articles
277           (setcar active (apply 'min articles))
278           (setcdr active (apply 'max articles))))
279       (nnmail-save-active nnml-group-alist nnml-active-file)
280       t))))
281
282 (deffoo nnml-request-list (&optional server)
283   (save-excursion
284     (let ((nnmail-file-coding-system nnmail-active-file-coding-system)
285           (file-name-coding-system nnmail-pathname-coding-system))
286       (nnmail-find-file nnml-active-file))
287     (setq nnml-group-alist (nnmail-get-active))
288     t))
289
290 (deffoo nnml-request-newgroups (date &optional server)
291   (nnml-request-list server))
292
293 (deffoo nnml-request-list-newsgroups (&optional server)
294   (save-excursion
295     (nnmail-find-file nnml-newsgroups-file)))
296
297 (deffoo nnml-request-expire-articles (articles group &optional server force)
298   (nnml-possibly-change-directory group server)
299   (let ((active-articles
300          (nnml-directory-articles nnml-current-directory))
301         (is-old t)
302         article rest mod-time number)
303     (nnmail-activate 'nnml)
304
305     (setq active-articles (sort active-articles '<))
306     ;; Articles not listed in active-articles are already gone,
307     ;; so don't try to expire them.
308     (setq articles (gnus-sorted-intersection articles active-articles))
309
310     (while (and articles is-old)
311       (if (and (setq article (nnml-article-to-file
312                               (setq number (pop articles))))
313                (setq mod-time (nth 5 (file-attributes article)))
314                (nnml-deletable-article-p group number)
315                (setq is-old (nnmail-expired-article-p group mod-time force
316                                                       nnml-inhibit-expiry)))
317           (progn
318             ;; Allow a special target group.
319             (unless (eq nnmail-expiry-target 'delete)
320               (with-temp-buffer
321                 (nnml-request-article number group server (current-buffer))
322                 (let (nnml-current-directory
323                       nnml-current-group
324                       nnml-article-file-alist)
325                   (nnmail-expiry-target-group nnmail-expiry-target group)))
326               ;; Maybe directory is changed during nnmail-expiry-target-group.
327               (nnml-possibly-change-directory group server))
328             (nnheader-message 5 "Deleting article %s in %s"
329                               number group)
330             (condition-case ()
331                 (funcall nnmail-delete-file-function article)
332               (file-error
333                (push number rest)))
334             (setq active-articles (delq number active-articles))
335             (nnml-nov-delete-article group number))
336         (push number rest)))
337     (let ((active (nth 1 (assoc group nnml-group-alist))))
338       (when active
339         (setcar active (or (and active-articles
340                                 (apply 'min active-articles))
341                            (1+ (cdr active)))))
342       (nnmail-save-active nnml-group-alist nnml-active-file))
343     (nnml-save-nov)
344     (nconc rest articles)))
345
346 (deffoo nnml-request-move-article
347     (article group server accept-form &optional last move-is-internal)
348   (let ((buf (get-buffer-create " *nnml move*"))
349         result)
350     (nnml-possibly-change-directory group server)
351     (nnml-update-file-alist)
352     (and
353      (nnml-deletable-article-p group article)
354      (nnml-request-article article group server)
355      (let (nnml-current-directory
356            nnml-current-group
357            nnml-article-file-alist)
358        (save-excursion
359          (set-buffer buf)
360          (insert-buffer-substring nntp-server-buffer)
361          (setq result (eval accept-form))
362          (kill-buffer (current-buffer))
363          result))
364      (progn
365        (nnml-possibly-change-directory group server)
366        (condition-case ()
367            (funcall nnmail-delete-file-function
368                     (nnml-article-to-file  article))
369          (file-error nil))
370        (nnml-nov-delete-article group article)
371        (when last
372          (nnml-save-nov)
373          (nnmail-save-active nnml-group-alist nnml-active-file))))
374     result))
375
376 (deffoo nnml-request-accept-article (group &optional server last)
377   (nnml-possibly-change-directory group server)
378   (nnmail-check-syntax)
379   (let (result)
380     (when nnmail-cache-accepted-message-ids
381       (nnmail-cache-insert (nnmail-fetch-field "message-id")
382                            group
383                            (nnmail-fetch-field "subject")
384                            (nnmail-fetch-field "from")))
385     (if (stringp group)
386         (and
387          (nnmail-activate 'nnml)
388          (setq result (car (nnml-save-mail
389                             (list (cons group (nnml-active-number group))))))
390          (progn
391            (nnmail-save-active nnml-group-alist nnml-active-file)
392            (and last (nnml-save-nov))))
393       (and
394        (nnmail-activate 'nnml)
395        (if (and (not (setq result (nnmail-article-group 'nnml-active-number)))
396                 (yes-or-no-p "Moved to `junk' group; delete article? "))
397            (setq result 'junk)
398          (setq result (car (nnml-save-mail result))))
399        (when last
400          (nnmail-save-active nnml-group-alist nnml-active-file)
401          (when nnmail-cache-accepted-message-ids
402            (nnmail-cache-close))
403          (nnml-save-nov))))
404     result))
405
406 (deffoo nnml-request-post (&optional server)
407   (nnmail-do-request-post 'nnml-request-accept-article server))
408
409 (deffoo nnml-request-replace-article (article group buffer)
410   (nnml-possibly-change-directory group)
411   (save-excursion
412     (set-buffer buffer)
413     (nnml-possibly-create-directory group)
414     (let ((chars (nnmail-insert-lines))
415           (art (concat (int-to-string article) "\t"))
416           headers)
417       (when (ignore-errors
418               (nnmail-write-region
419                (point-min) (point-max)
420                (or (nnml-article-to-file article)
421                    (expand-file-name (int-to-string article)
422                                      nnml-current-directory))
423                nil (if (nnheader-be-verbose 5) nil 'nomesg))
424               t)
425         (setq headers (nnml-parse-head chars article))
426         ;; Replace the NOV line in the NOV file.
427         (save-excursion
428           (set-buffer (nnml-open-nov group))
429           (goto-char (point-min))
430           (if (or (looking-at art)
431                   (search-forward (concat "\n" art) nil t))
432               ;; Delete the old NOV line.
433               (gnus-delete-line)
434             ;; The line isn't here, so we have to find out where
435             ;; we should insert it.  (This situation should never
436             ;; occur, but one likes to make sure...)
437             (while (and (looking-at "[0-9]+\t")
438                         (< (string-to-number
439                             (buffer-substring
440                              (match-beginning 0) (match-end 0)))
441                            article)
442                         (zerop (forward-line 1)))))
443           (beginning-of-line)
444           (nnheader-insert-nov headers)
445           (nnml-save-nov)
446           t)))))
447
448 (deffoo nnml-request-delete-group (group &optional force server)
449   (nnml-possibly-change-directory group server)
450   (when force
451     ;; Delete all articles in GROUP.
452     (let ((articles
453            (directory-files
454             nnml-current-directory t
455             (concat nnheader-numerical-short-files
456                     "\\|" (regexp-quote nnml-nov-file-name) "$"
457                     "\\|" (regexp-quote nnml-marks-file-name) "$"))))
458       (dolist (article articles)
459         (when (file-writable-p article)
460           (nnheader-message 5 "Deleting article %s in %s..." article group)
461           (funcall nnmail-delete-file-function article))))
462     ;; Try to delete the directory itself.
463     (ignore-errors (delete-directory nnml-current-directory)))
464   ;; Remove the group from all structures.
465   (setq nnml-group-alist
466         (delq (assoc group nnml-group-alist) nnml-group-alist)
467         nnml-current-group nil
468         nnml-current-directory nil)
469   ;; Save the active file.
470   (nnmail-save-active nnml-group-alist nnml-active-file)
471   t)
472
473 (deffoo nnml-request-rename-group (group new-name &optional server)
474   (nnml-possibly-change-directory group server)
475   (let ((new-dir (nnmail-group-pathname new-name nnml-directory))
476         (old-dir (nnmail-group-pathname group nnml-directory)))
477     (when (ignore-errors
478             (make-directory new-dir t)
479             t)
480       ;; We move the articles file by file instead of renaming
481       ;; the directory -- there may be subgroups in this group.
482       ;; One might be more clever, I guess.
483       (dolist (file (nnheader-article-to-file-alist old-dir))
484         (rename-file
485          (concat old-dir (cdr file))
486          (concat new-dir (cdr file))))
487       ;; Move .overview file.
488       (let ((overview (concat old-dir nnml-nov-file-name)))
489         (when (file-exists-p overview)
490           (rename-file overview (concat new-dir nnml-nov-file-name))))
491       ;; Move .marks file.
492       (let ((marks (concat old-dir nnml-marks-file-name)))
493         (when (file-exists-p marks)
494           (rename-file marks (concat new-dir nnml-marks-file-name))))
495       (when (<= (length (directory-files old-dir)) 2)
496         (ignore-errors (delete-directory old-dir)))
497       ;; That went ok, so we change the internal structures.
498       (let ((entry (assoc group nnml-group-alist)))
499         (when entry
500           (setcar entry new-name))
501         (setq nnml-current-directory nil
502               nnml-current-group nil)
503         ;; Save the new group alist.
504         (nnmail-save-active nnml-group-alist nnml-active-file)
505         t))))
506
507 (deffoo nnml-set-status (article name value &optional group server)
508   (nnml-possibly-change-directory group server)
509   (let ((file (nnml-article-to-file article)))
510     (cond
511      ((not (file-exists-p file))
512       (nnheader-report 'nnml "File %s does not exist" file))
513      (t
514       (with-temp-file file
515         (nnheader-insert-file-contents file)
516         (nnmail-replace-status name value))
517       t))))
518
519 \f
520 ;;; Internal functions.
521
522 (defun nnml-article-to-file (article)
523   (nnml-update-file-alist)
524   (let (file)
525     (if (setq file
526               (if nnml-use-compressed-files
527                   (cdr (assq article nnml-article-file-alist))
528                 (number-to-string article)))
529         (expand-file-name file nnml-current-directory)
530       (when (not nnheader-directory-files-is-safe)
531         ;; Just to make sure nothing went wrong when reading over NFS --
532         ;; check once more.
533         (when (file-exists-p
534                (setq file (expand-file-name (number-to-string article)
535                                             nnml-current-directory)))
536           (nnml-update-file-alist t)
537           file)))))
538
539 (defun nnml-deletable-article-p (group article)
540   "Say whether ARTICLE in GROUP can be deleted."
541   (let (path)
542     (when (setq path (nnml-article-to-file article))
543       (when (file-writable-p path)
544         (or (not nnmail-keep-last-article)
545             (not (eq (cdr (nth 1 (assoc group nnml-group-alist)))
546                      article)))))))
547
548 ;; Find an article number in the current group given the Message-ID.
549 (defun nnml-find-group-number (id)
550   (save-excursion
551     (set-buffer (get-buffer-create " *nnml id*"))
552     (let ((alist nnml-group-alist)
553           number)
554       ;; We want to look through all .overview files, but we want to
555       ;; start with the one in the current directory.  It seems most
556       ;; likely that the article we are looking for is in that group.
557       (if (setq number (nnml-find-id nnml-current-group id))
558           (cons nnml-current-group number)
559       ;; It wasn't there, so we look through the other groups as well.
560         (while (and (not number)
561                     alist)
562           (or (string= (caar alist) nnml-current-group)
563               (setq number (nnml-find-id (caar alist) id)))
564           (or number
565               (setq alist (cdr alist))))
566         (and number
567              (cons (caar alist) number))))))
568
569 (defun nnml-find-id (group id)
570   (erase-buffer)
571   (let ((nov (expand-file-name nnml-nov-file-name
572                                (nnmail-group-pathname group nnml-directory)))
573         number found)
574     (when (file-exists-p nov)
575       (nnheader-insert-file-contents nov)
576       (while (and (not found)
577                   (search-forward id nil t)) ; We find the ID.
578         ;; And the id is in the fourth field.
579         (if (not (and (search-backward "\t" nil t 4)
580                       (not (search-backward "\t" (point-at-bol) t))))
581             (forward-line 1)
582           (beginning-of-line)
583           (setq found t)
584           ;; We return the article number.
585           (setq number
586                 (ignore-errors (read (current-buffer))))))
587       number)))
588
589 (defun nnml-retrieve-headers-with-nov (articles &optional fetch-old)
590   (if (or gnus-nov-is-evil nnml-nov-is-evil)
591       nil
592     (let ((nov (expand-file-name nnml-nov-file-name nnml-current-directory)))
593       (when (file-exists-p nov)
594         (save-excursion
595           (set-buffer nntp-server-buffer)
596           (erase-buffer)
597           (nnheader-insert-file-contents nov)
598           (if (and fetch-old
599                    (not (numberp fetch-old)))
600               t                         ; Don't remove anything.
601             (nnheader-nov-delete-outside-range
602              (if fetch-old (max 1 (- (car articles) fetch-old))
603                (car articles))
604              (car (last articles)))
605             t))))))
606
607 (defun nnml-possibly-change-directory (group &optional server)
608   (when (and server
609              (not (nnml-server-opened server)))
610     (nnml-open-server server))
611   (if (not group)
612       t
613     (let ((pathname (nnmail-group-pathname group nnml-directory))
614           (file-name-coding-system nnmail-pathname-coding-system))
615       (when (not (equal pathname nnml-current-directory))
616         (setq nnml-current-directory pathname
617               nnml-current-group group
618               nnml-article-file-alist nil))
619       (file-exists-p nnml-current-directory))))
620
621 (defun nnml-possibly-create-directory (group)
622   (let ((dir (nnmail-group-pathname group nnml-directory)))
623     (unless (file-exists-p dir)
624       (make-directory (directory-file-name dir) t)
625       (nnheader-message 5 "Creating mail directory %s" dir))))
626
627 (defun nnml-save-mail (group-art)
628   "Called narrowed to an article."
629   (let (chars headers extension)
630     (setq chars (nnmail-insert-lines))
631     (setq extension
632          (and nnml-use-compressed-files
633               (> chars nnml-compressed-files-size-threshold)
634               ".gz"))
635     (nnmail-insert-xref group-art)
636     (run-hooks 'nnmail-prepare-save-mail-hook)
637     (run-hooks 'nnml-prepare-save-mail-hook)
638     (goto-char (point-min))
639     (while (looking-at "From ")
640       (replace-match "X-From-Line: ")
641       (forward-line 1))
642     ;; We save the article in all the groups it belongs in.
643     (let ((ga group-art)
644           first)
645       (while ga
646         (nnml-possibly-create-directory (caar ga))
647         (let ((file (concat (nnmail-group-pathname
648                              (caar ga) nnml-directory)
649                             (int-to-string (cdar ga))
650                             extension)))
651           (if first
652               ;; It was already saved, so we just make a hard link.
653               (funcall nnmail-crosspost-link-function first file t)
654             ;; Save the article.
655             (nnmail-write-region (point-min) (point-max) file nil
656                                  (if (nnheader-be-verbose 5) nil 'nomesg))
657             (setq first file)))
658         (setq ga (cdr ga))))
659     ;; Generate a nov line for this article.  We generate the nov
660     ;; line after saving, because nov generation destroys the
661     ;; header.
662     (setq headers (nnml-parse-head chars))
663     ;; Output the nov line to all nov databases that should have it.
664     (let ((ga group-art))
665       (while ga
666         (nnml-add-nov (caar ga) (cdar ga) headers)
667         (setq ga (cdr ga))))
668     group-art))
669
670 (defun nnml-active-number (group)
671   "Compute the next article number in GROUP."
672   (let ((active (cadr (assoc group nnml-group-alist))))
673     ;; The group wasn't known to nnml, so we just create an active
674     ;; entry for it.
675     (unless active
676       ;; Perhaps the active file was corrupt?  See whether
677       ;; there are any articles in this group.
678       (nnml-possibly-create-directory group)
679       (nnml-possibly-change-directory group)
680       (unless nnml-article-file-alist
681         (setq nnml-article-file-alist
682               (sort
683                (nnml-current-group-article-to-file-alist)
684                'car-less-than-car)))
685       (setq active
686             (if nnml-article-file-alist
687                 (cons (caar nnml-article-file-alist)
688                       (caar (last nnml-article-file-alist)))
689               (cons 1 0)))
690       (push (list group active) nnml-group-alist))
691     (setcdr active (1+ (cdr active)))
692     (while (file-exists-p
693             (expand-file-name (int-to-string (cdr active))
694                               (nnmail-group-pathname group nnml-directory)))
695       (setcdr active (1+ (cdr active))))
696     (cdr active)))
697
698 (defun nnml-add-nov (group article headers)
699   "Add a nov line for the GROUP base."
700   (save-excursion
701     (set-buffer (nnml-open-nov group))
702     (goto-char (point-max))
703     (mail-header-set-number headers article)
704     (nnheader-insert-nov headers)))
705
706 (defsubst nnml-header-value ()
707   (buffer-substring (match-end 0) (point-at-eol)))
708
709 (defun nnml-parse-head (chars &optional number)
710   "Parse the head of the current buffer."
711   (save-excursion
712     (save-restriction
713       (unless (zerop (buffer-size))
714         (narrow-to-region
715          (goto-char (point-min))
716          (if (re-search-forward "\n\r?\n" nil t)
717              (1- (point))
718            (point-max))))
719       (let ((headers (nnheader-parse-naked-head)))
720         (mail-header-set-chars headers chars)
721         (mail-header-set-number headers number)
722         headers))))
723
724 (defun nnml-get-nov-buffer (group)
725   (let ((buffer (get-buffer-create (format " *nnml overview %s*" group))))
726     (save-excursion
727       (set-buffer buffer)
728       (set (make-local-variable 'nnml-nov-buffer-file-name)
729            (expand-file-name
730             nnml-nov-file-name
731             (nnmail-group-pathname group nnml-directory)))
732       (erase-buffer)
733       (when (file-exists-p nnml-nov-buffer-file-name)
734         (nnheader-insert-file-contents nnml-nov-buffer-file-name)))
735     buffer))
736
737 (defun nnml-open-nov (group)
738   (or (cdr (assoc group nnml-nov-buffer-alist))
739       (let ((buffer (nnml-get-nov-buffer group)))
740         (push (cons group buffer) nnml-nov-buffer-alist)
741         buffer)))
742
743 (defun nnml-save-nov ()
744   (save-excursion
745     (while nnml-nov-buffer-alist
746       (when (buffer-name (cdar nnml-nov-buffer-alist))
747         (set-buffer (cdar nnml-nov-buffer-alist))
748         (when (buffer-modified-p)
749           (nnmail-write-region (point-min) (point-max)
750                                nnml-nov-buffer-file-name nil 'nomesg))
751         (set-buffer-modified-p nil)
752         (kill-buffer (current-buffer)))
753       (setq nnml-nov-buffer-alist (cdr nnml-nov-buffer-alist)))))
754
755 ;;;###autoload
756 (defun nnml-generate-nov-databases (&optional server)
757   "Generate NOV databases in all nnml directories."
758   (interactive (list (or (nnoo-current-server 'nnml) "")))
759   ;; Read the active file to make sure we don't re-use articles
760   ;; numbers in empty groups.
761   (nnmail-activate 'nnml)
762   (unless (nnml-server-opened server)
763     (nnml-open-server server))
764   (setq nnml-directory (expand-file-name nnml-directory))
765   ;; Recurse down the directories.
766   (nnml-generate-nov-databases-1 nnml-directory nil t)
767   ;; Save the active file.
768   (nnmail-save-active nnml-group-alist nnml-active-file))
769
770 (defun nnml-generate-nov-databases-1 (dir &optional seen no-active)
771   "Regenerate the NOV database in DIR."
772   (interactive "DRegenerate NOV in: ")
773   (setq dir (file-name-as-directory dir))
774   ;; Only scan this sub-tree if we haven't been here yet.
775   (unless (member (file-truename dir) seen)
776     (push (file-truename dir) seen)
777     ;; We descend recursively
778     (dolist (dir (directory-files dir t nil t))
779       (when (and (not (string-match "^\\." (file-name-nondirectory dir)))
780                  (file-directory-p dir))
781         (nnml-generate-nov-databases-1 dir seen)))
782     ;; Do this directory.
783     (let ((files (sort (nnheader-article-to-file-alist dir)
784                        'car-less-than-car)))
785       (if (not files)
786           (let* ((group (nnheader-file-to-group
787                          (directory-file-name dir) nnml-directory))
788                  (info (cadr (assoc group nnml-group-alist))))
789             (when info
790               (setcar info (1+ (cdr info)))))
791         (funcall nnml-generate-active-function dir)
792         ;; Generate the nov file.
793         (nnml-generate-nov-file dir files)
794         (unless no-active
795           (nnmail-save-active nnml-group-alist nnml-active-file))))))
796
797 (eval-when-compile (defvar files))
798 (defun nnml-generate-active-info (dir)
799   ;; Update the active info for this group.
800   (let* ((group (nnheader-file-to-group
801                  (directory-file-name dir) nnml-directory))
802          (entry (assoc group nnml-group-alist))
803          (last (or (caadr entry) 0)))
804     (setq nnml-group-alist (delq entry nnml-group-alist))
805     (push (list group
806                 (cons (or (caar files) (1+ last))
807                       (max last
808                            (or (caar (last files))
809                                0))))
810           nnml-group-alist)))
811
812 (defun nnml-generate-nov-file (dir files)
813   (let* ((dir (file-name-as-directory dir))
814          (nov (concat dir nnml-nov-file-name))
815          (nov-buffer (get-buffer-create " *nov*"))
816          chars file headers)
817     (save-excursion
818       ;; Init the nov buffer.
819       (set-buffer nov-buffer)
820       (buffer-disable-undo)
821       (erase-buffer)
822       (set-buffer nntp-server-buffer)
823       ;; Delete the old NOV file.
824       (when (file-exists-p nov)
825         (funcall nnmail-delete-file-function nov))
826       (while files
827         (unless (file-directory-p (setq file (concat dir (cdar files))))
828           (erase-buffer)
829           (nnheader-insert-file-contents file)
830           (narrow-to-region
831            (goto-char (point-min))
832            (progn
833              (re-search-forward "\n\r?\n" nil t)
834              (setq chars (- (point-max) (point)))
835              (max (point-min) (1- (point)))))
836           (unless (zerop (buffer-size))
837             (goto-char (point-min))
838             (setq headers (nnml-parse-head chars (caar files)))
839             (save-excursion
840               (set-buffer nov-buffer)
841               (goto-char (point-max))
842               (nnheader-insert-nov headers)))
843           (widen))
844         (setq files (cdr files)))
845       (save-excursion
846         (set-buffer nov-buffer)
847         (nnmail-write-region (point-min) (point-max) nov nil 'nomesg)
848         (kill-buffer (current-buffer))))))
849
850 (defun nnml-nov-delete-article (group article)
851   (save-excursion
852     (set-buffer (nnml-open-nov group))
853     (when (nnheader-find-nov-line article)
854       (delete-region (point) (progn (forward-line 1) (point)))
855       (when (bobp)
856         (let ((active (cadr (assoc group nnml-group-alist)))
857               num)
858           (when active
859             (if (eobp)
860                 (setf (car active) (1+ (cdr active)))
861               (when (and (setq num (ignore-errors (read (current-buffer))))
862                          (numberp num))
863                 (setf (car active) num)))))))
864     t))
865
866 (defun nnml-update-file-alist (&optional force)
867   (when nnml-use-compressed-files
868     (when (or (not nnml-article-file-alist)
869               force)
870       (setq nnml-article-file-alist
871             (nnml-current-group-article-to-file-alist)))))
872
873 (defun nnml-directory-articles (dir)
874   "Return a list of all article files in a directory.
875 Use the nov database for that directory if available."
876   (if (or gnus-nov-is-evil nnml-nov-is-evil
877           (not (file-exists-p
878                 (expand-file-name nnml-nov-file-name dir))))
879       (nnheader-directory-articles dir)
880     ;; build list from .overview if available
881     ;; We would use nnml-open-nov, except that nnml-nov-buffer-alist is
882     ;; defvoo'd, and we might get called when it hasn't been swapped in.
883     (save-excursion
884       (let ((list nil)
885             art
886             (buffer (nnml-get-nov-buffer nnml-current-group)))
887         (set-buffer buffer)
888         (goto-char (point-min))
889         (while (not (eobp))
890           (setq art (read (current-buffer)))
891           (push art list)
892           (forward-line 1))
893         list))))
894
895 (defun nnml-current-group-article-to-file-alist ()
896   "Return an alist of article/file pairs in the current group.
897 Use the nov database for the current group if available."
898   (if (or nnml-use-compressed-files
899           gnus-nov-is-evil
900           nnml-nov-is-evil
901           (not (file-exists-p
902                 (expand-file-name nnml-nov-file-name
903                                   nnml-current-directory))))
904       (nnheader-article-to-file-alist nnml-current-directory)
905     ;; build list from .overview if available
906     (save-excursion
907       (let ((alist nil)
908             (buffer (nnml-get-nov-buffer nnml-current-group))
909             art)
910         (set-buffer buffer)
911         (goto-char (point-min))
912         (while (not (eobp))
913           (setq art (read (current-buffer)))
914           ;; assume file name is unadorned (ie. not compressed etc)
915           (push (cons art (int-to-string art)) alist)
916           (forward-line 1))
917         alist))))
918
919 (deffoo nnml-request-set-mark (group actions &optional server)
920   (nnml-possibly-change-directory group server)
921   (unless nnml-marks-is-evil
922     (nnml-open-marks group server)
923     (dolist (action actions)
924       (let ((range (nth 0 action))
925             (what  (nth 1 action))
926             (marks (nth 2 action)))
927         (assert (or (eq what 'add) (eq what 'del)) nil
928                 "Unknown request-set-mark action: %s" what)
929         (dolist (mark marks)
930           (setq nnml-marks (gnus-update-alist-soft
931                             mark
932                             (funcall (if (eq what 'add) 'gnus-range-add
933                                        'gnus-remove-from-range)
934                                      (cdr (assoc mark nnml-marks)) range)
935                             nnml-marks)))))
936     (nnml-save-marks group server))
937   nil)
938
939 (deffoo nnml-request-update-info (group info &optional server)
940   (nnml-possibly-change-directory group server)
941   (when (and (not nnml-marks-is-evil) (nnml-marks-changed-p group))
942     (nnheader-message 8 "Updating marks for %s..." group)
943     (nnml-open-marks group server)
944     ;; Update info using `nnml-marks'.
945     (mapc (lambda (pred)
946             (unless (memq (cdr pred) gnus-article-unpropagated-mark-lists)
947               (gnus-info-set-marks
948                info
949                (gnus-update-alist-soft
950                 (cdr pred)
951                 (cdr (assq (cdr pred) nnml-marks))
952                 (gnus-info-marks info))
953                t)))
954           gnus-article-mark-lists)
955     (let ((seen (cdr (assq 'read nnml-marks))))
956       (gnus-info-set-read info
957                           (if (and (integerp (car seen))
958                                    (null (cdr seen)))
959                               (list (cons (car seen) (car seen)))
960                             seen)))
961     (nnheader-message 8 "Updating marks for %s...done" group))
962   info)
963
964 (defun nnml-marks-changed-p (group)
965   (let ((file (expand-file-name nnml-marks-file-name
966                                 (nnmail-group-pathname group nnml-directory))))
967     (if (null (gnus-gethash file nnml-marks-modtime))
968         t ;; never looked at marks file, assume it has changed
969       (not (equal (gnus-gethash file nnml-marks-modtime)
970                   (nth 5 (file-attributes file)))))))
971
972 (defun nnml-save-marks (group server)
973   (let ((file-name-coding-system nnmail-pathname-coding-system)
974         (file (expand-file-name nnml-marks-file-name
975                                 (nnmail-group-pathname group nnml-directory))))
976     (condition-case err
977         (progn
978           (nnml-possibly-create-directory group)
979           (with-temp-file file
980             (erase-buffer)
981             (gnus-prin1 nnml-marks)
982             (insert "\n"))
983           (gnus-sethash file
984                         (nth 5 (file-attributes file))
985                         nnml-marks-modtime))
986       (error (or (gnus-yes-or-no-p
987                   (format "Could not write to %s (%s).  Continue? " file err))
988                  (error "Cannot write to %s (%s)" file err))))))
989
990 (defun nnml-open-marks (group server)
991   (let ((file (expand-file-name
992                nnml-marks-file-name
993                (nnmail-group-pathname group nnml-directory))))
994     (if (file-exists-p file)
995         (condition-case err
996             (with-temp-buffer
997               (gnus-sethash file (nth 5 (file-attributes file))
998                             nnml-marks-modtime)
999               (nnheader-insert-file-contents file)
1000               (setq nnml-marks (read (current-buffer)))
1001               (dolist (el gnus-article-unpropagated-mark-lists)
1002                 (setq nnml-marks (gnus-remassoc el nnml-marks))))
1003           (error (or (gnus-yes-or-no-p
1004                       (format "Error reading nnml marks file %s (%s).  Continuing will use marks from .newsrc.eld.  Continue? " file err))
1005                      (error "Cannot read nnml marks file %s (%s)" file err))))
1006       ;; User didn't have a .marks file.  Probably first time
1007       ;; user of the .marks stuff.  Bootstrap it from .newsrc.eld.
1008       (let ((info (gnus-get-info
1009                    (gnus-group-prefixed-name
1010                     group
1011                     (gnus-server-to-method (format "nnml:%s" server))))))
1012         (nnheader-message 7 "Bootstrapping marks for %s..." group)
1013         (setq nnml-marks (gnus-info-marks info))
1014         (push (cons 'read (gnus-info-read info)) nnml-marks)
1015         (dolist (el gnus-article-unpropagated-mark-lists)
1016           (setq nnml-marks (gnus-remassoc el nnml-marks)))
1017         (nnml-save-marks group server)
1018         (nnheader-message 7 "Bootstrapping marks for %s...done" group)))))
1019
1020
1021 ;;;
1022 ;;; Group and server compaction. -- dvl
1023 ;;;
1024
1025 ;; #### FIXME: this function handles self Xref: entry correctly, but I don't
1026 ;; #### know how to handle external cross-references. I actually don't know if
1027 ;; #### this is handled correctly elsewhere. For instance, what happens if you
1028 ;; #### move all articles to a new group (that's what people do for manual
1029 ;; #### compaction) ?
1030
1031 ;; #### NOTE: the function below handles the article backlog. This is
1032 ;; #### conceptually the wrong place to do it because the backend is at a
1033 ;; #### lower level. However, this is the only place where we have the needed
1034 ;; #### information to do the job. Ideally, this function should not handle
1035 ;; #### the backlog by itself, but return a list of moved groups / articles to
1036 ;; #### the caller. This will become important to avoid code duplication when
1037 ;; #### other backends get a compaction feature. Also, note that invalidating
1038 ;; #### the "original article buffer" is already done at an upper level.
1039
1040 (defun nnml-request-compact-group (group &optional server save)
1041   (nnml-possibly-change-directory group server)
1042   (unless nnml-article-file-alist
1043     (setq nnml-article-file-alist
1044           (sort (nnml-current-group-article-to-file-alist)
1045                 'car-less-than-car)))
1046   (if (not nnml-article-file-alist)
1047       ;; The group is empty: do nothing but return t
1048       t
1049     ;; The group is not empty:
1050     (let* ((group-full-name
1051             (gnus-group-prefixed-name
1052              group
1053              (gnus-server-to-method (format "nnml:%s" server))))
1054            (info (gnus-get-info group-full-name))
1055            (new-number 1)
1056            compacted)
1057       (let ((articles nnml-article-file-alist)
1058             article)
1059         (while (setq article (pop articles))
1060           (let ((old-number (car article)))
1061             (when (> old-number new-number)
1062               ;; There is a gap here:
1063               (let ((old-number-string (int-to-string old-number))
1064                     (new-number-string (int-to-string new-number)))
1065                 (setq compacted t)
1066                 ;; #### NOTE: `nnml-article-to-file' calls
1067                 ;; #### `nnml-update-file-alist'  (which in turn calls
1068                 ;; #### `nnml-current-group-article-to-file-alist', which
1069                 ;; #### might use the NOV database). This might turn out to be
1070                 ;; #### inefficient. In that case, we will do the work
1071                 ;; #### manually.
1072                 ;; 1/ Move the article to a new file:
1073                 (let* ((oldfile (nnml-article-to-file old-number))
1074                        (newfile
1075                         (gnus-replace-in-string
1076                          oldfile (concat "\\("
1077                                          old-number-string
1078                                          "\\)\\(\\(\\.gz\\)?\\)$")
1079                          (concat new-number-string "\\2"))))
1080                   (with-current-buffer nntp-server-buffer
1081                     (nnmail-find-file oldfile)
1082                     ;; Update the Xref header in the article itself:
1083                     (when (and (re-search-forward "^Xref: [^ ]+ " nil t)
1084                                (re-search-forward
1085                                 (concat "\\<"
1086                                         (regexp-quote
1087                                          (concat group ":" old-number-string))
1088                                         "\\>")
1089                                 (point-at-eol) t))
1090                       (replace-match
1091                        (concat group ":" new-number-string)))
1092                     ;; Save to the new file:
1093                     (nnmail-write-region (point-min) (point-max) newfile))
1094                   (funcall nnmail-delete-file-function oldfile))
1095                 ;; 2/ Update all marks for this article:
1096                 ;; #### NOTE: it is possible that the new article number
1097                 ;; #### already belongs to a range, whereas the corresponding
1098                 ;; #### article doesn't exist (for example, if you delete an
1099                 ;; #### article). For that reason, it is important to update
1100                 ;; #### the ranges (meaning remove inexistant articles) before
1101                 ;; #### doing anything on them.
1102                 ;; 2 a/ read articles:
1103                 (let ((read (gnus-info-read info)))
1104                   (setq read (gnus-remove-from-range read (list new-number)))
1105                   (when (gnus-member-of-range old-number read)
1106                     (setq read (gnus-remove-from-range read (list old-number)))
1107                     (setq read (gnus-add-to-range read (list new-number))))
1108                   (gnus-info-set-read info read))
1109                 ;; 2 b/ marked articles:
1110                 (let ((oldmarks (gnus-info-marks info))
1111                       mark newmarks)
1112                   (while (setq mark (pop oldmarks))
1113                     (setcdr mark (gnus-remove-from-range (cdr mark)
1114                                                          (list new-number)))
1115                     (when (gnus-member-of-range old-number (cdr mark))
1116                       (setcdr mark (gnus-remove-from-range (cdr mark)
1117                                                            (list old-number)))
1118                       (setcdr mark (gnus-add-to-range (cdr mark)
1119                                                       (list new-number))))
1120                     (push mark newmarks))
1121                   (gnus-info-set-marks info newmarks))
1122                 ;; 3/ Update the NOV entry for this article:
1123                 (unless nnml-nov-is-evil
1124                   (save-excursion
1125                     (set-buffer (nnml-open-nov group))
1126                     (when (nnheader-find-nov-line old-number)
1127                       ;; Replace the article number:
1128                       (looking-at old-number-string)
1129                       (replace-match new-number-string nil t)
1130                       ;; Update the Xref header:
1131                       (when (re-search-forward
1132                              (concat "\\(Xref:[^\t\n]* \\)\\<"
1133                                      (regexp-quote
1134                                       (concat group ":" old-number-string))
1135                                      "\\>")
1136                              (point-at-eol) t)
1137                         (replace-match
1138                          (concat "\\1" group ":" new-number-string))))))
1139                 ;; 4/ Possibly remove the article from the backlog:
1140                 (when gnus-keep-backlog
1141                   ;; #### NOTE: instead of removing the article, we could
1142                   ;; #### modify the backlog to reflect the numbering change,
1143                   ;; #### but I don't think it's worth it.
1144                   (gnus-backlog-remove-article group-full-name old-number)
1145                   (gnus-backlog-remove-article group-full-name new-number))))
1146             (setq new-number (1+ new-number)))))
1147       (if (not compacted)
1148           ;; No compaction had to be done:
1149           t
1150         ;; Some articles have actually been renamed:
1151         ;; 1/ Rebuild active information:
1152         (let ((entry (assoc group nnml-group-alist))
1153               (active (cons 1 (1- new-number))))
1154           (setq nnml-group-alist (delq entry nnml-group-alist))
1155           (push (list group active) nnml-group-alist)
1156           ;; Update the active hashtable to let the *Group* buffer display
1157           ;; up-to-date lines. I don't think that either gnus-newsrc-hashtb or
1158           ;; gnus-newwrc-alist are out of date, since all we did is to modify
1159           ;; the info of the group internally.
1160           (gnus-set-active group-full-name active))
1161         ;; 1 bis/
1162         ;; #### NOTE: normally, we should save the overview (NOV) file
1163         ;; #### here, just like we save the marks file. However, there is no
1164         ;; #### such function as nnml-save-nov for a single group. Only for
1165         ;; #### all groups. Gnus inconsistency is getting worse every day...
1166         ;; 2/ Rebuild marks file:
1167         (unless nnml-marks-is-evil
1168           ;; #### NOTE: this constant use of global variables everywhere is
1169           ;; #### truly disgusting. Gnus really needs a *major* cleanup.
1170           (setq nnml-marks (gnus-info-marks info))
1171           (push (cons 'read (gnus-info-read info)) nnml-marks)
1172           (dolist (el gnus-article-unpropagated-mark-lists)
1173             (setq nnml-marks (gnus-remassoc el nnml-marks)))
1174           (nnml-save-marks group server))
1175         ;; 3/ Save everything if this was not part of a bigger operation:
1176         (if (not save)
1177             ;; Nothing to save (yet):
1178             t
1179           ;; Something to save:
1180           ;; a/ Save the NOV databases:
1181           ;; #### NOTE: this should be done directory per directory in 1bis
1182           ;; #### above. See comment there.
1183           (nnml-save-nov)
1184           ;; b/ Save the active file:
1185           (nnmail-save-active nnml-group-alist nnml-active-file)
1186           t)))))
1187
1188 (defun nnml-request-compact (&optional server)
1189   "Request compaction of all SERVER nnml groups."
1190   (interactive (list (or (nnoo-current-server 'nnml) "")))
1191   (nnmail-activate 'nnml)
1192   (unless (nnml-server-opened server)
1193     (nnml-open-server server))
1194   (setq nnml-directory (expand-file-name nnml-directory))
1195   (let* ((groups (gnus-groups-from-server
1196                   (gnus-server-to-method (format "nnml:%s" server))))
1197          (first (pop groups))
1198          group)
1199     (when first
1200       (while (setq group (pop groups))
1201         (nnml-request-compact-group (gnus-group-real-name group) server))
1202       (nnml-request-compact-group (gnus-group-real-name first) server t))))
1203
1204
1205 (provide 'nnml)
1206
1207 ;;; arch-tag: 52c97dc3-9735-45de-b439-9e4d23b52004
1208 ;;; nnml.el ends here