cda82ccbde9090627b3ea4561fa0a716f9c80d79
[gnus] / lisp / gnus-cache.el
1 ;;; gnus-cache.el --- cache interface for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'gnus-load)
29 (require 'gnus-int)
30 (require 'gnus-range)
31 (require 'gnus-sum)
32 (require 'gnus-start)
33 (require 'gnus)
34
35 (defvar gnus-cache-directory
36   (nnheader-concat gnus-directory "cache/")
37   "*The directory where cached articles will be stored.")
38
39 (defvar gnus-cache-active-file 
40   (concat (file-name-as-directory gnus-cache-directory) "active")
41   "*The cache active file.")
42
43 (defvar gnus-cache-enter-articles '(ticked dormant)
44   "*Classes of articles to enter into the cache.")
45
46 (defvar gnus-cache-remove-articles '(read)
47   "*Classes of articles to remove from the cache.")
48
49 (defvar gnus-uncacheable-groups nil
50   "*Groups that match this regexp will not be cached.
51
52 If you want to avoid caching your nnml groups, you could set this
53 variable to \"^nnml\".")
54
55 \f
56
57 ;;; Internal variables.
58
59 (defvar gnus-cache-removable-articles nil)
60 (defvar gnus-cache-buffer nil)
61 (defvar gnus-cache-active-hashtb nil)
62 (defvar gnus-cache-active-altered nil)
63
64 (eval-and-compile
65   (autoload 'nnml-generate-nov-databases-1 "nnml")
66   (autoload 'nnvirtual-find-group-art "nnvirtual"))
67
68 \f
69
70 ;;; Functions called from Gnus.
71
72 (defun gnus-cache-open ()
73   "Initialize the cache."
74   (when (or (file-exists-p gnus-cache-directory)
75             (and gnus-use-cache
76                  (not (eq gnus-use-cache 'passive))))
77     (gnus-cache-read-active)))
78
79 (condition-case ()
80     (gnus-add-shutdown 'gnus-cache-close 'gnus)
81   ;; Complexities of byte-compiling makes this kludge necessary.  Eeek.
82   (error nil))
83
84 (defun gnus-cache-close ()
85   "Shut down the cache."
86   (gnus-cache-write-active)
87   (gnus-cache-save-buffers)
88   (setq gnus-cache-active-hashtb nil))
89
90 (defun gnus-cache-save-buffers ()
91   ;; save the overview buffer if it exists and has been modified
92   ;; delete empty cache subdirectories
93   (if (null gnus-cache-buffer)
94       ()
95     (let ((buffer (cdr gnus-cache-buffer))
96           (overview-file (gnus-cache-file-name
97                           (car gnus-cache-buffer) ".overview")))
98       ;; write the overview only if it was modified
99       (if (buffer-modified-p buffer)
100           (save-excursion
101             (set-buffer buffer)
102             (if (> (buffer-size) 0)
103                 ;; non-empty overview, write it out
104                 (progn
105                   (unless (file-exists-p (file-name-directory overview-file))
106                     (make-directory (file-name-directory overview-file) t))
107                   (write-region (point-min) (point-max)
108                                 overview-file nil 'quietly))
109               ;; empty overview file, remove it
110               (and (file-exists-p overview-file)
111                    (delete-file overview-file))
112               ;; if possible, remove group's cache subdirectory
113               (condition-case nil
114                   ;; FIXME: we can detect the error type and warn the user
115                   ;; of any inconsistencies (articles w/o nov entries?).
116                   ;; for now, just be conservative...delete only if safe -- sj
117                   (delete-directory (file-name-directory overview-file))
118                 (error nil)))))
119       ;; kill the buffer, it's either unmodified or saved
120       (gnus-kill-buffer buffer)
121       (setq gnus-cache-buffer nil))))
122
123 (defun gnus-cache-possibly-enter-article 
124   (group article headers ticked dormant unread &optional force)
125   (when (and (or force (not (eq gnus-use-cache 'passive)))
126              (numberp article)
127              (> article 0)
128              (vectorp headers)) ; This might be a dummy article.
129     ;; If this is a virtual group, we find the real group.
130     (when (gnus-virtual-group-p group)
131       (let ((result (nnvirtual-find-group-art 
132                      (gnus-group-real-name group) article)))
133         (setq group (car result)
134               headers (copy-sequence headers))
135         (mail-header-set-number headers (cdr result))))
136     (let ((number (mail-header-number headers))
137           file dir)
138       (when (and (> number 0)           ; Reffed article.
139                  (or (not gnus-uncacheable-groups)
140                      (not (string-match gnus-uncacheable-groups group)))
141                  (or force
142                      (gnus-cache-member-of-class
143                       gnus-cache-enter-articles ticked dormant unread))
144                  (not (file-exists-p (setq file (gnus-cache-file-name
145                                                  group number)))))
146         ;; Possibly create the cache directory.
147         (or (file-exists-p (setq dir (file-name-directory file)))
148             (make-directory dir t))
149         ;; Save the article in the cache.
150         (if (file-exists-p file)
151             t                           ; The article already is saved.
152           (save-excursion
153             (set-buffer nntp-server-buffer)
154             (let ((gnus-use-cache nil))
155               (gnus-request-article-this-buffer number group))
156             (when (> (buffer-size) 0)
157               (write-region (point-min) (point-max) file nil 'quiet)
158               (gnus-cache-change-buffer group)
159               (set-buffer (cdr gnus-cache-buffer))
160               (goto-char (point-max))
161               (forward-line -1)
162               (while (condition-case ()
163                          (and (not (bobp))
164                               (> (read (current-buffer)) number))
165                        (error
166                         ;; The line was malformed, so we just remove it!!
167                         (gnus-delete-line)
168                         t))
169                 (forward-line -1))
170               (if (bobp) 
171                   (if (not (eobp))
172                       (progn
173                         (beginning-of-line)
174                         (if (< (read (current-buffer)) number)
175                             (forward-line 1)))
176                     (beginning-of-line))
177                 (forward-line 1))
178               (beginning-of-line)
179               ;; [number subject from date id references chars lines xref]
180               (insert (format "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n"
181                               (mail-header-number headers)
182                               (mail-header-subject headers)
183                               (mail-header-from headers)
184                               (mail-header-date headers)
185                               (mail-header-id headers)
186                               (or (mail-header-references headers) "")
187                               (or (mail-header-chars headers) "")
188                               (or (mail-header-lines headers) "")
189                               (or (mail-header-xref headers) "")))
190               ;; Update the active info.
191               (set-buffer gnus-summary-buffer)
192               (gnus-cache-update-active group number)
193               (push article gnus-newsgroup-cached)
194               (gnus-summary-update-secondary-mark article))
195             t))))))
196
197 (defun gnus-cache-enter-remove-article (article)
198   "Mark ARTICLE for later possible removal."
199   (when article
200     (push article gnus-cache-removable-articles)))
201
202 (defun gnus-cache-possibly-remove-articles ()
203   "Possibly remove some of the removable articles."
204   (if (not (gnus-virtual-group-p gnus-newsgroup-name))
205       (gnus-cache-possibly-remove-articles-1)
206     (let ((arts gnus-cache-removable-articles)
207           ga)
208       (while arts
209         (when (setq ga (nnvirtual-find-group-art
210                         (gnus-group-real-name gnus-newsgroup-name) (pop arts)))
211           (let ((gnus-cache-removable-articles (list (cdr ga)))
212                 (gnus-newsgroup-name (car ga)))
213             (gnus-cache-possibly-remove-articles-1)))))
214     (setq gnus-cache-removable-articles nil)))
215
216 (defun gnus-cache-possibly-remove-articles-1 ()
217   "Possibly remove some of the removable articles."
218   (unless (eq gnus-use-cache 'passive)
219     (let ((articles gnus-cache-removable-articles)
220           (cache-articles gnus-newsgroup-cached)
221           article)
222       (gnus-cache-change-buffer gnus-newsgroup-name)
223       (while articles
224         (if (memq (setq article (pop articles)) cache-articles)
225             ;; The article was in the cache, so we see whether we are
226             ;; supposed to remove it from the cache.
227             (gnus-cache-possibly-remove-article
228              article (memq article gnus-newsgroup-marked)
229              (memq article gnus-newsgroup-dormant)
230              (or (memq article gnus-newsgroup-unreads)
231                  (memq article gnus-newsgroup-unselected))))))
232     ;; The overview file might have been modified, save it
233     ;; safe because we're only called at group exit anyway.
234     (gnus-cache-save-buffers)))
235
236 (defun gnus-cache-request-article (article group)
237   "Retrieve ARTICLE in GROUP from the cache."
238   (let ((file (gnus-cache-file-name group article))
239         (buffer-read-only nil))
240     (when (file-exists-p file)
241       (erase-buffer)
242       (gnus-kill-all-overlays)
243       (insert-file-contents file)
244       t)))
245
246 (defun gnus-cache-possibly-alter-active (group active)
247   "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
248   (when gnus-cache-active-hashtb
249     (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
250       (and cache-active 
251            (< (car cache-active) (car active))
252            (setcar active (car cache-active)))
253       (and cache-active
254            (> (cdr cache-active) (cdr active))
255            (setcdr active (cdr cache-active))))))
256
257 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old)
258   "Retrieve the headers for ARTICLES in GROUP."
259   (let ((cached 
260          (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group))))
261     (if (not cached)
262         ;; No cached articles here, so we just retrieve them
263         ;; the normal way.
264         (let ((gnus-use-cache nil))
265           (gnus-retrieve-headers articles group fetch-old))
266       (let ((uncached-articles (gnus-sorted-intersection
267                                 (gnus-sorted-complement articles cached)
268                                 articles))
269             (cache-file (gnus-cache-file-name group ".overview"))
270             type)
271         ;; We first retrieve all the headers that we don't have in 
272         ;; the cache.
273         (let ((gnus-use-cache nil))
274           (when uncached-articles
275             (setq type (and articles 
276                             (gnus-retrieve-headers 
277                              uncached-articles group fetch-old)))))
278         (gnus-cache-save-buffers)
279         ;; Then we insert the cached headers.
280         (save-excursion
281           (cond
282            ((not (file-exists-p cache-file))
283             ;; There are no cached headers.
284             type)
285            ((null type)
286             ;; There were no uncached headers (or retrieval was 
287             ;; unsuccessful), so we use the cached headers exclusively.
288             (set-buffer nntp-server-buffer)
289             (erase-buffer)
290             (insert-file-contents cache-file)
291             'nov)
292            ((eq type 'nov)
293             ;; We have both cached and uncached NOV headers, so we
294             ;; braid them.
295             (gnus-cache-braid-nov group cached)
296             type)
297            (t
298             ;; We braid HEADs.
299             (gnus-cache-braid-heads group (gnus-sorted-intersection
300                                            cached articles))
301             type)))))))
302
303 (defun gnus-cache-enter-article (&optional n)
304   "Enter the next N articles into the cache.
305 If not given a prefix, use the process marked articles instead.
306 Returns the list of articles entered."
307   (interactive "P")
308   (gnus-set-global-variables)
309   (let ((articles (gnus-summary-work-articles n))
310         article out)
311     (while articles
312       (setq article (pop articles))
313       (when (gnus-cache-possibly-enter-article 
314              gnus-newsgroup-name article (gnus-summary-article-header article)
315              nil nil nil t)
316         (push article out))
317       (gnus-summary-remove-process-mark article)
318       (gnus-summary-update-secondary-mark article))
319     (gnus-summary-next-subject 1)
320     (gnus-summary-position-point)
321     (nreverse out)))
322
323 (defun gnus-cache-remove-article (n)
324   "Remove the next N articles from the cache.
325 If not given a prefix, use the process marked articles instead.
326 Returns the list of articles removed."
327   (interactive "P")
328   (gnus-set-global-variables)
329   (gnus-cache-change-buffer gnus-newsgroup-name)
330   (let ((articles (gnus-summary-work-articles n))
331         article out)
332     (while articles
333       (setq article (pop articles))
334       (when (gnus-cache-possibly-remove-article article nil nil nil t)
335         (push article out))
336       (gnus-summary-remove-process-mark article)
337       (gnus-summary-update-secondary-mark article))
338     (gnus-summary-next-subject 1)
339     (gnus-summary-position-point)
340     (nreverse out)))
341
342 (defun gnus-cached-article-p (article)
343   "Say whether ARTICLE is cached in the current group."
344   (memq article gnus-newsgroup-cached))
345
346 ;;; Internal functions.
347
348 (defun gnus-cache-change-buffer (group)
349   (and gnus-cache-buffer
350        ;; See if the current group's overview cache has been loaded.
351        (or (string= group (car gnus-cache-buffer))
352            ;; Another overview cache is current, save it.
353            (gnus-cache-save-buffers)))
354   ;; if gnus-cache buffer is nil, create it
355   (or gnus-cache-buffer
356       ;; Create cache buffer
357       (save-excursion
358         (setq gnus-cache-buffer
359               (cons group
360                     (set-buffer (get-buffer-create " *gnus-cache-overview*"))))
361         (buffer-disable-undo (current-buffer))
362         ;; Insert the contents of this group's cache overview.
363         (erase-buffer)
364         (let ((file (gnus-cache-file-name group ".overview")))
365           (and (file-exists-p file)
366                (insert-file-contents file)))
367         ;; We have a fresh (empty/just loaded) buffer, 
368         ;; mark it as unmodified to save a redundant write later.
369         (set-buffer-modified-p nil))))
370
371 ;; Return whether an article is a member of a class.
372 (defun gnus-cache-member-of-class (class ticked dormant unread)
373   (or (and ticked (memq 'ticked class))
374       (and dormant (memq 'dormant class))
375       (and unread (memq 'unread class))
376       (and (not unread) (not ticked) (not dormant) (memq 'read class))))
377
378 (defun gnus-cache-file-name (group article)
379   (concat (file-name-as-directory gnus-cache-directory)
380           (file-name-as-directory
381            (if (gnus-use-long-file-name 'not-cache)
382                group 
383              (let ((group (nnheader-replace-chars-in-string group ?/ ?_)))
384                ;; Translate the first colon into a slash.
385                (when (string-match ":" group)
386                  (aset group (match-beginning 0) ?/))
387                (nnheader-replace-chars-in-string group ?. ?/))))
388           (if (stringp article) article (int-to-string article))))
389
390 (defun gnus-cache-update-article (group article)
391   "If ARTICLE is in the cache, remove it and re-enter it."
392   (when (gnus-cache-possibly-remove-article article nil nil nil t)
393     (let ((gnus-use-cache nil))
394       (gnus-cache-possibly-enter-article 
395        gnus-newsgroup-name article (gnus-summary-article-header article)
396        nil nil nil t))))
397
398 (defun gnus-cache-possibly-remove-article (article ticked dormant unread 
399                                                    &optional force)
400   "Possibly remove ARTICLE from the cache."
401   (let ((group gnus-newsgroup-name)
402         (number article)
403         file)
404     ;; If this is a virtual group, we find the real group.
405     (when (gnus-virtual-group-p group)
406       (let ((result (nnvirtual-find-group-art 
407                      (gnus-group-real-name group) article)))
408         (setq group (car result)
409               number (cdr result))))
410     (setq file (gnus-cache-file-name group number))
411     (when (and (file-exists-p file)
412                (or force
413                    (gnus-cache-member-of-class
414                     gnus-cache-remove-articles ticked dormant unread)))
415       (save-excursion
416         (delete-file file)
417         (set-buffer (cdr gnus-cache-buffer))
418         (goto-char (point-min))
419         (if (or (looking-at (concat (int-to-string number) "\t"))
420                 (search-forward (concat "\n" (int-to-string number) "\t")
421                                 (point-max) t))
422             (delete-region (progn (beginning-of-line) (point))
423                            (progn (forward-line 1) (point)))))
424       (setq gnus-newsgroup-cached
425             (delq article gnus-newsgroup-cached))
426       (gnus-summary-update-secondary-mark article)
427       t)))
428
429 (defun gnus-cache-articles-in-group (group)
430   "Return a sorted list of cached articles in GROUP."
431   (let ((dir (file-name-directory (gnus-cache-file-name group 1)))
432         articles)
433     (when (file-exists-p dir)
434       (sort (mapcar (lambda (name) (string-to-int name)) 
435                     (directory-files dir nil "^[0-9]+$" t))
436             '<))))
437
438 (defun gnus-cache-braid-nov (group cached)
439   (let ((cache-buf (get-buffer-create " *gnus-cache*"))
440         beg end)
441     (gnus-cache-save-buffers)
442     (save-excursion
443       (set-buffer cache-buf)
444       (buffer-disable-undo (current-buffer))
445       (erase-buffer)
446       (insert-file-contents (gnus-cache-file-name group ".overview"))
447       (goto-char (point-min))
448       (insert "\n")
449       (goto-char (point-min)))
450     (set-buffer nntp-server-buffer)
451     (goto-char (point-min))
452     (while cached
453       (while (and (not (eobp))
454                   (< (read (current-buffer)) (car cached)))
455         (forward-line 1))
456       (beginning-of-line)
457       (save-excursion
458         (set-buffer cache-buf)
459         (if (search-forward (concat "\n" (int-to-string (car cached)) "\t")
460                             nil t)
461             (setq beg (progn (beginning-of-line) (point))
462                   end (progn (end-of-line) (point)))
463           (setq beg nil)))
464       (if beg (progn (insert-buffer-substring cache-buf beg end)
465                      (insert "\n")))
466       (setq cached (cdr cached)))
467     (kill-buffer cache-buf)))
468
469 (defun gnus-cache-braid-heads (group cached)
470   (let ((cache-buf (get-buffer-create " *gnus-cache*")))
471     (save-excursion
472       (set-buffer cache-buf)
473       (buffer-disable-undo (current-buffer))
474       (erase-buffer))
475     (set-buffer nntp-server-buffer)
476     (goto-char (point-min))
477     (while cached
478       (while (and (not (eobp))
479                   (looking-at "2.. +\\([0-9]+\\) ")
480                   (< (progn (goto-char (match-beginning 1))
481                             (read (current-buffer)))
482                      (car cached)))
483         (search-forward "\n.\n" nil 'move))
484       (beginning-of-line)
485       (save-excursion
486         (set-buffer cache-buf)
487         (erase-buffer)
488         (insert-file-contents (gnus-cache-file-name group (car cached)))
489         (goto-char (point-min))
490         (insert "220 ")
491         (princ (car cached) (current-buffer))
492         (insert " Article retrieved.\n")
493         (search-forward "\n\n" nil 'move)
494         (delete-region (point) (point-max))
495         (forward-char -1)
496         (insert "."))
497       (insert-buffer-substring cache-buf)
498       (setq cached (cdr cached)))
499     (kill-buffer cache-buf)))
500
501 ;;;###autoload
502 (defun gnus-jog-cache ()
503   "Go through all groups and put the articles into the cache."
504   (interactive)
505   (let ((gnus-mark-article-hook nil)
506         (gnus-expert-user t)
507         (nnmail-spool-file nil)
508         (gnus-use-dribble-file nil)
509         (gnus-novice-user nil)
510         (gnus-large-newsgroup nil))
511     ;; Start Gnus.
512     (gnus)
513     ;; Go through all groups...
514     (gnus-group-mark-buffer)
515     (gnus-group-universal-argument 
516      nil nil 
517      (lambda ()
518        (gnus-summary-read-group nil nil t)
519        ;; ... and enter the articles into the cache.
520        (when (eq major-mode 'gnus-summary-mode)
521          (gnus-uu-mark-buffer)
522          (gnus-cache-enter-article)
523          (kill-buffer (current-buffer)))))))
524
525 (defun gnus-cache-read-active (&optional force)
526   "Read the cache active file."
527   (unless (file-exists-p gnus-cache-directory)
528     (make-directory gnus-cache-directory t))
529   (if (not (and (file-exists-p gnus-cache-active-file)
530                 (or force (not gnus-cache-active-hashtb))))
531       ;; There is no active file, so we generate one.
532       (gnus-cache-generate-active)
533     ;; We simply read the active file.
534     (save-excursion
535       (gnus-set-work-buffer)
536       (insert-file-contents gnus-cache-active-file)
537       (gnus-active-to-gnus-format
538        nil (setq gnus-cache-active-hashtb 
539                  (gnus-make-hashtable 
540                   (count-lines (point-min) (point-max)))))
541       (setq gnus-cache-active-altered nil))))
542        
543 (defun gnus-cache-write-active (&optional force)
544   "Write the active hashtb to the active file."
545   (when (or force
546             (and gnus-cache-active-hashtb
547                  gnus-cache-active-altered))
548     (save-excursion
549       (gnus-set-work-buffer)
550       (mapatoms
551        (lambda (sym)
552          (when (and sym (boundp sym))
553            (insert (format "%s %d %d y\n"
554                            (symbol-name sym) (cdr (symbol-value sym))
555                            (car (symbol-value sym))))))
556        gnus-cache-active-hashtb)
557       (make-directory (file-name-directory gnus-cache-active-file) t)
558       (write-region 
559        (point-min) (point-max) gnus-cache-active-file nil 'silent))
560     ;; Mark the active hashtb as unaltered.
561     (setq gnus-cache-active-altered nil)))
562
563 (defun gnus-cache-update-active (group number &optional low)
564   "Update the upper bound of the active info of GROUP to NUMBER.
565 If LOW, update the lower bound instead."
566   (let ((active (gnus-gethash group gnus-cache-active-hashtb)))
567     (if (null active)
568         ;; We just create a new active entry for this group.
569         (gnus-sethash group (cons number number) gnus-cache-active-hashtb)
570       ;; Update the lower or upper bound.
571       (if low
572           (setcar active number)
573         (setcdr active number))
574       ;; Mark the active hashtb as altered.
575       (setq gnus-cache-active-altered t))))
576
577 ;;;###autoload
578 (defun gnus-cache-generate-active (&optional directory)
579   "Generate the cache active file."
580   (interactive)
581   (let* ((top (null directory))
582          (directory (expand-file-name (or directory gnus-cache-directory)))
583          (files (directory-files directory 'full))
584          (group 
585           (if top
586               ""
587             (string-match 
588              (concat "^" (file-name-as-directory
589                           (expand-file-name gnus-cache-directory)))
590              (directory-file-name directory))
591             (nnheader-replace-chars-in-string 
592              (substring (directory-file-name directory) (match-end 0))
593              ?/ ?.)))
594          nums alphs)
595     (when top
596       (gnus-message 5 "Generating the cache active file...")
597       (setq gnus-cache-active-hashtb (gnus-make-hashtable 123)))
598     ;; Separate articles from all other files and directories.
599     (while files
600       (if (string-match "^[0-9]+$" (file-name-nondirectory (car files)))
601           (push (string-to-int (file-name-nondirectory (pop files))) nums)
602         (push (pop files) alphs)))
603     ;; If we have nums, then this is probably a valid group.
604     (when (setq nums (sort nums '<))
605       (gnus-sethash group (cons (car nums) (gnus-last-element nums))
606                     gnus-cache-active-hashtb))
607     ;; Go through all the other files.
608     (while alphs
609       (when (and (file-directory-p (car alphs))
610                  (not (string-match "^\\.\\.?$"
611                                     (file-name-nondirectory (car alphs)))))
612         ;; We descend directories.
613         (gnus-cache-generate-active (car alphs)))
614       (setq alphs (cdr alphs)))
615     ;; Write the new active file.
616     (when top
617       (gnus-cache-write-active t)
618       (gnus-message 5 "Generating the cache active file...done"))))
619
620 ;;;###autoload
621 (defun gnus-cache-generate-nov-databases (dir)
622   "Generate NOV files recursively starting in DIR."
623   (interactive (list gnus-cache-directory))
624   (gnus-cache-close)
625   (let ((nnml-generate-active-function 'identity))
626     (nnml-generate-nov-databases-1 dir)))
627
628 (provide 'gnus-cache)
629               
630 ;;; gnus-cache.el ends here