1 ;;; nnsoup.el --- SOUP 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.
33 (eval-when-compile (require 'cl))
35 (defvar nnsoup-directory "~/SOUP/"
36 "*SOUP packet directory.")
38 (defvar nnsoup-tmp-directory "/tmp/"
39 "*Where nnsoup will store temporary files.")
41 (defvar nnsoup-replies-directory (concat nnsoup-directory "replies/")
42 "*Directory where outgoing packets will be composed.")
44 (defvar nnsoup-replies-format-type ?n
45 "*Format of the replies packages.")
47 (defvar nnsoup-replies-index-type ?n
48 "*Index type of the replies packages.")
50 (defvar nnsoup-active-file (concat nnsoup-directory "active")
53 (defvar nnsoup-packer "tar cf - %s | gzip > $HOME/Soupin%d.tgz"
54 "Format string command for packing a SOUP packet.
55 The SOUP files will be inserted where the %s is in the string.
56 This string MUST contain both %s and %d. The file number will be
57 inserted where %d appears.")
59 (defvar nnsoup-unpacker "gunzip -c %s | tar xvf -"
60 "*Format string command for unpacking a SOUP packet.
61 The SOUP packet file name will be inserted at the %s.")
63 (defvar nnsoup-packet-directory "~/"
64 "*Where nnsoup will look for incoming packets.")
66 (defvar nnsoup-packet-regexp "Soupout"
67 "*Regular expression matching SOUP packets in `nnsoup-packet-directory'.")
71 (defconst nnsoup-version "nnsoup 0.0"
74 (defvar nnsoup-status-string "")
75 (defvar nnsoup-group-alist nil)
76 (defvar nnsoup-current-prefix 0)
77 (defvar nnsoup-replies-list nil)
78 (defvar nnsoup-buffers nil)
79 (defvar nnsoup-current-group nil)
80 (defvar nnsoup-group-alist-touched nil)
86 (defvar nnsoup-current-server nil)
87 (defvar nnsoup-server-alist nil)
88 (defvar nnsoup-server-variables
89 `((nnsoup-directory ,nnsoup-directory)
90 (nnsoup-active-file ,nnsoup-active-file)
91 (nnsoup-status-string "")
92 (nnsoup-current-prefix 0)
93 (nnsoup-current-group nil)
95 (nnsoup-replies-list nil)
96 (nnsoup-packet-regexp ,nnsoup-packet-regexp)
97 (nnsoup-packet-directory ,nnsoup-packet-directory)
98 (nnsoup-unpacker ,nnsoup-unpacker)
99 (nnsoup-packer ,nnsoup-packer)
100 (nnsoup-group-alist-touched nil)
101 (nnsoup-replies-index-type ,nnsoup-replies-index-type)
102 (nnsoup-replies-format-type ,nnsoup-replies-format-type)
103 (nnsoup-replies-directory ,nnsoup-replies-directory)
104 (nnsoup-tmp-directory ,nnsoup-tmp-directory)
105 (nnsoup-group-alist nil)))
109 ;;; Interface functions.
111 (defun nnsoup-retrieve-headers (sequence &optional group server fetch-old)
112 (nnsoup-possibly-change-group group)
114 (set-buffer nntp-server-buffer)
116 (let ((areas (cddr (assoc nnsoup-current-group nnsoup-group-alist)))
119 useful-areas this-area-seq msg-buf)
120 (if (stringp (car sequence))
121 ;; We don't support fetching by Message-ID.
123 ;; We go through all the areas and find which files the
124 ;; articles in SEQUENCE come from.
125 (while (and areas sequence)
126 ;; Peel off areas that are below sequence.
127 (while (and areas (< (cdaar areas) (car sequence)))
128 (setq areas (cdr areas)))
130 ;; This is a useful area.
131 (push (car areas) useful-areas)
132 (setq this-area-seq nil)
133 ;; We take note whether this MSG has a corresponding IDX
135 (when (or (= (gnus-soup-encoding-index
136 (gnus-soup-area-encoding (nth 1 (car areas)))) ?n)
139 (gnus-soup-area-prefix (nth 1 (car areas)))))))
141 ;; We assign the portion of `sequence' that is relevant to
142 ;; this MSG packet to this packet.
143 (while (and sequence (<= (car sequence) (cdaar areas)))
144 (push (car sequence) this-area-seq)
145 (setq sequence (cdr sequence)))
146 (setcar useful-areas (cons (nreverse this-area-seq)
147 (car useful-areas)))))
149 ;; We now have a list of article numbers and corresponding
151 (setq useful-areas (nreverse useful-areas))
153 ;; Two different approaches depending on whether all the MSG
154 ;; files have corresponding IDX files. If they all do, we
155 ;; simply return the relevant IDX files and let Gnus sort out
156 ;; what lines are relevant. If some of the IDX files are
157 ;; missing, we must return HEADs for all the articles.
159 ;; We have IDX files for all areas.
162 (goto-char (point-max))
164 (number (car (nth 1 (car useful-areas))))
165 (index-buffer (nnsoup-index-buffer
166 (gnus-soup-area-prefix
167 (nth 2 (car useful-areas))))))
169 (insert-buffer-substring index-buffer)
171 ;; We have to remove the index number entires and
172 ;; insert article numbers instead.
173 (while (looking-at "[0-9]+")
174 (replace-match (int-to-string number) t t)
177 (setq useful-areas (cdr useful-areas)))
181 (setq articles (caar useful-areas)
182 useful-areas (cdr useful-areas))
185 (nnsoup-narrow-to-article
186 (car articles) (cdar useful-areas) 'head))
187 (goto-char (point-max))
188 (insert (format "221 %d Article retrieved.\n" (car articles)))
189 (insert-buffer-substring msg-buf)
190 (goto-char (point-max))
192 (setq articles (cdr articles))))
194 (nnheader-fold-continuation-lines)
197 (defun nnsoup-open-server (server &optional defs)
198 (nnheader-change-server 'nnsoup server defs)
199 (when (not (file-exists-p nnsoup-directory))
201 (make-directory nnsoup-directory t)
204 ((not (file-exists-p nnsoup-directory))
205 (nnsoup-close-server)
206 (nnheader-report 'nnsoup "Couldn't create directory: %s" nnsoup-directory))
207 ((not (file-directory-p (file-truename nnsoup-directory)))
208 (nnsoup-close-server)
209 (nnheader-report 'nnsoup "Not a directory: %s" nnsoup-directory))
211 (nnsoup-read-active-file)
212 (nnheader-report 'nnsoup "Opened server %s using directory %s"
213 server nnsoup-directory)
216 (defun nnsoup-close-server (&optional server)
217 (setq nnsoup-current-server nil
218 nnsoup-group-alist-touched nil
219 nnsoup-group-alist nil)
222 (defun nnsoup-request-close ()
223 (nnsoup-write-active-file)
224 (nnsoup-write-replies)
225 (gnus-soup-save-areas)
226 ;; Kill all nnsoup buffers.
228 (while nnsoup-buffers
229 (setq buffer (cdr (pop nnsoup-buffers)))
232 (kill-buffer buffer))))
233 (setq nnsoup-group-alist nil
234 nnsoup-group-alist-touched nil
235 nnsoup-current-group nil
236 nnsoup-current-server nil
237 nnsoup-server-alist nil
238 nnsoup-replies-list nil)
241 (defun nnsoup-server-opened (&optional server)
242 (and (equal server nnsoup-current-server)
244 (buffer-name nntp-server-buffer)))
246 (defun nnsoup-status-message (&optional server)
247 nnsoup-status-string)
249 (defun nnsoup-request-article (id &optional newsgroup server buffer)
250 (nnsoup-possibly-change-group newsgroup)
253 (set-buffer (or buffer nntp-server-buffer))
255 (when (and (not (stringp id))
256 (setq buf (nnsoup-narrow-to-article id)))
257 (insert-buffer-substring buf)
260 (defun nnsoup-request-group (group &optional server dont-check)
261 (nnsoup-possibly-change-group group)
264 (let ((active (cadr (assoc group nnsoup-group-alist))))
266 (nnheader-report 'nnsoup "No such group: %s" group)
269 (max (1+ (- (cdr active) (car active))) 0)
270 (car active) (cdr active) group)))))
272 (defun nnsoup-request-type (group &optional article)
273 (nnsoup-possibly-change-group group)
276 (let ((kind (gnus-soup-encoding-kind
277 (gnus-soup-area-encoding
278 (nth 1 (nnsoup-article-to-area
279 article nnsoup-current-group))))))
280 (cond ((= kind ?m) 'mail)
284 (defun nnsoup-close-group (group &optional server)
285 ;; Kill all nnsoup buffers.
286 (let ((buffers nnsoup-buffers)
289 (when (equal (car (setq elem (pop buffers))) group)
290 (setq nnsoup-buffers (delq elem nnsoup-buffers))
291 (and (cdr elem) (buffer-name (cdr elem))
292 (kill-buffer (cdr elem))))))
295 (defun nnsoup-request-list (&optional server)
297 (set-buffer nntp-server-buffer)
299 (let ((alist nnsoup-group-alist)
300 (standard-output (current-buffer))
302 (while (setq entry (pop alist))
303 (insert (car entry) " ")
304 (princ (cdadr entry))
306 (princ (caadr entry))
310 (defun nnsoup-request-scan (group &optional server)
311 (nnsoup-unpack-packets))
313 (defun nnsoup-request-newgroups (date &optional server)
314 (nnsoup-request-list))
316 (defun nnsoup-request-list-newsgroups (&optional server)
319 (defun nnsoup-request-post (&optional server)
320 (nnsoup-store-reply "news")
323 (defun nnsoup-request-mail (&optional server)
324 (nnsoup-store-reply "mail")
327 (defun nnsoup-request-expire-articles (articles group &optional server force)
328 (nnsoup-possibly-change-group group)
329 (let* ((total-infolist (assoc group nnsoup-group-alist))
330 (active (cadr total-infolist))
331 (infolist (cddr total-infolist))
332 info range-list mod-time prefix)
334 (setq info (pop infolist)
335 range-list (gnus-uncompress-range (car info))
336 prefix (gnus-soup-area-prefix (nth 1 info)))
337 (when ;; All the articles in this file are marked for expiry.
338 (and (or (setq mod-time (nth 5 (file-attributes
339 (nnsoup-file prefix))))
340 (setq mod-time (nth 5 (file-attributes
341 (nnsoup-file prefix t)))))
342 (gnus-sublist-p articles range-list)
343 ;; This file is old enough.
344 (nnmail-expired-article-p group mod-time force))
345 ;; Ok, we delete this file.
346 (when (condition-case nil
349 5 "Deleting %s in group %s..." (nnsoup-file prefix)
351 (when (file-exists-p (nnsoup-file prefix))
352 (delete-file (nnsoup-file prefix)))
354 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
356 (when (file-exists-p (nnsoup-file prefix t))
357 (delete-file (nnsoup-file prefix t)))
360 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
361 (setq articles (gnus-sorted-complement articles range-list))))
363 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
364 (if (cddr total-infolist)
365 (setcar active (caaadr (cdr total-infolist)))
366 (setcar active (1+ (cdr active))))
367 (nnsoup-write-active-file t)
368 ;; Return the articles that weren't expired.
372 ;;; Internal functions
374 (defun nnsoup-possibly-change-group (group &optional force)
376 (setq nnsoup-current-group group)
379 (defun nnsoup-read-active-file ()
380 (setq nnsoup-group-alist)
381 (when (file-exists-p nnsoup-active-file)
383 (load nnsoup-active-file t t t)
385 ;; Be backwards compatible.
386 (when (and nnsoup-group-alist
387 (not (atom (caadar nnsoup-group-alist))))
388 (let ((alist nnsoup-group-alist)
390 (while (setq e (cdr (setq entry (pop alist))))
395 (setcdr entry (cons (cons min max) (cdr entry)))))
396 (setq nnsoup-group-alist-touched t))
399 (defun nnsoup-write-active-file (&optional force)
400 (when (and nnsoup-group-alist
402 nnsoup-group-alist-touched))
403 (setq nnsoup-group-alist-touched nil)
404 (nnheader-temp-write nnsoup-active-file
405 (let ((standard-output (current-buffer)))
406 (prin1 `(setq nnsoup-group-alist ',nnsoup-group-alist))
408 (prin1 `(setq nnsoup-current-prefix ,nnsoup-current-prefix))
411 (defun nnsoup-next-prefix ()
412 "Return the next free prefix."
414 (while (or (file-exists-p
415 (nnsoup-file (setq prefix (int-to-string
416 nnsoup-current-prefix))))
417 (file-exists-p (nnsoup-file prefix t)))
418 (incf nnsoup-current-prefix))
419 (incf nnsoup-current-prefix)
422 (defun nnsoup-read-areas ()
424 (set-buffer nntp-server-buffer)
425 (let ((areas (gnus-soup-parse-areas (concat nnsoup-tmp-directory "AREAS")))
426 entry number area lnum cur-prefix file)
427 ;; Go through all areas in the new AREAS file.
428 (while (setq area (pop areas))
429 ;; Change the name to the permanent name and move the files.
430 (setq cur-prefix (nnsoup-next-prefix))
431 (message "Incorporating file %s..." cur-prefix)
433 (setq file (concat nnsoup-tmp-directory
434 (gnus-soup-area-prefix area) ".IDX")))
435 (rename-file file (nnsoup-file cur-prefix)))
437 (setq file (concat nnsoup-tmp-directory
438 (gnus-soup-area-prefix area) ".MSG")))
439 (rename-file file (nnsoup-file cur-prefix t))
440 (gnus-soup-set-area-prefix area cur-prefix)
441 ;; Find the number of new articles in this area.
442 (setq number (nnsoup-number-of-articles area))
443 (if (not (setq entry (assoc (gnus-soup-area-name area)
444 nnsoup-group-alist)))
445 ;; If this is a new area (group), we just add this info to
447 (push (list (gnus-soup-area-name area)
449 (list (cons 1 number) area))
451 ;; There are already articles in this group, so we add this
452 ;; info to the end of the entry.
453 (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
456 (setcdr (cadr entry) (+ lnum number))))))
457 (nnsoup-write-active-file t)
458 (delete-file (concat nnsoup-tmp-directory "AREAS"))))
460 (defun nnsoup-number-of-articles (area)
463 ;; If the number is in the area info, we just return it.
464 ((gnus-soup-area-number area)
465 (gnus-soup-area-number area))
466 ;; If there is an index file, we just count the lines.
467 ((/= (gnus-soup-encoding-index (gnus-soup-area-encoding area)) ?n)
468 (set-buffer (nnsoup-index-buffer (gnus-soup-area-prefix area)))
469 (count-lines (point-min) (point-max)))
470 ;; We do it the hard way - re-searching through the message
473 (set-buffer (nnsoup-message-buffer (gnus-soup-area-prefix area)))
474 (goto-char (point-min))
475 (let ((regexp (nnsoup-header (gnus-soup-encoding-format
476 (gnus-soup-area-encoding area))))
478 (while (re-search-forward regexp nil t)
482 (defun nnsoup-index-buffer (prefix &optional message)
483 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
484 (buffer-name (concat " *nnsoup " file "*")))
485 (or (get-buffer buffer-name) ; File aready loaded.
486 (when (file-exists-p (concat nnsoup-directory file))
487 (save-excursion ; Load the file.
488 (set-buffer (get-buffer-create buffer-name))
489 (buffer-disable-undo (current-buffer))
490 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
491 (insert-file-contents (concat nnsoup-directory file))
492 (current-buffer))))))
494 (defun nnsoup-file (prefix &optional message)
496 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
498 (defun nnsoup-message-buffer (prefix)
499 (nnsoup-index-buffer prefix 'msg))
501 (defun nnsoup-unpack-packets ()
502 "Unpack all packets in `nnsoup-packet-directory'."
503 (let ((packets (directory-files
504 nnsoup-packet-directory t nnsoup-packet-regexp))
506 (while (setq packet (pop packets))
507 (message (format "nnsoup: unpacking %s..." packet))
508 (if (not (gnus-soup-unpack-packet
509 nnsoup-tmp-directory nnsoup-unpacker packet))
510 (message "Couldn't unpack %s" packet)
513 (message "Unpacking...done")))))
515 (defun nnsoup-narrow-to-article (article &optional area head)
516 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
517 (prefix (and area (gnus-soup-area-prefix (nth 1 area))))
518 (msg-buf (and prefix (nnsoup-index-buffer prefix 'msg)))
523 ;; There is no MSG file.
527 ;; We use the index file to find out where the article begins and ends.
528 ((and (= (gnus-soup-encoding-index
529 (gnus-soup-area-encoding (nth 1 area)))
531 (file-exists-p (nnsoup-file prefix)))
532 (set-buffer (nnsoup-index-buffer prefix))
534 (goto-char (point-min))
535 (forward-line (- article (caar area)))
536 (setq beg (read (current-buffer)))
538 (if (looking-at "[0-9]+")
540 (setq end (read (current-buffer)))
543 (let ((format (gnus-soup-encoding-format
544 (gnus-soup-area-encoding (nth 1 area)))))
546 (if (or (= format ?n) (= format ?m))
547 (setq end (progn (forward-line -1) (point))))))
548 (set-buffer msg-buf))
550 (narrow-to-region beg (or end (point-max))))
554 (goto-char (point-min))
555 (let ((header (nnsoup-header
556 (gnus-soup-encoding-format
557 (gnus-soup-area-encoding (nth 1 area))))))
558 (re-search-forward header nil t (- article (caar area)))
561 (if (re-search-forward header nil t)
564 (goto-char (point-min))
569 (if (search-forward "\n\n" nil t)
574 (defun nnsoup-header (format)
577 "^#! *rnews +[0-9]+ *$")
579 (concat "^" rmail-unix-mail-delimiter))
583 (error "Unknown format: %c" format))))
586 (defun nnsoup-pack-replies ()
587 "Make an outbound package of SOUP replies."
589 ;; Write all data buffers.
590 (gnus-soup-save-areas)
591 ;; Write the active file.
592 (nnsoup-write-active-file)
593 ;; Write the REPLIES file.
594 (nnsoup-write-replies)
595 ;; Pack all these files into a SOUP packet.
596 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
598 (defun nnsoup-write-replies ()
599 "Write the REPLIES file."
600 (when nnsoup-replies-list
601 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
602 (setq nnsoup-replies-list nil)))
604 (defun nnsoup-article-to-area (article group)
605 "Return the area that ARTICLE in GROUP is located in."
606 (let ((areas (cddr (assoc group nnsoup-group-alist))))
607 (while (and areas (< (cdaar areas) article))
608 (setq areas (cdr areas)))
609 (and areas (car areas))))
611 (defvar nnsoup-old-functions
612 (list message-send-mail-function message-send-news-function))
615 (defun nnsoup-set-variables ()
616 "Use the SOUP methods for posting news and mailing mail."
618 (setq message-send-news-function 'nnsoup-request-post)
619 (setq message-send-mail-function 'nnsoup-request-mail))
622 (defun nnsoup-revert-variables ()
623 "Revert posting and mailing methods to the standard Emacs methods."
625 (setq message-send-mail-function (car nnsoup-old-functions))
626 (setq message-send-news-function (cadr nnsoup-old-functions)))
628 (defun nnsoup-store-reply (kind)
629 ;; Mostly stolen from `message.el'.
630 (require 'mail-utils)
631 (let ((tembuf (generate-new-buffer " message temp"))
632 (case-fold-search nil)
633 (news (message-news-p))
634 (resend-to-addresses (mail-fetch-field "resent-to"))
636 (mailbuf (current-buffer)))
641 (insert-buffer-substring mailbuf)
642 ;; Remove some headers.
644 (message-narrow-to-headers)
645 ;; Remove some headers.
646 (message-remove-header message-ignored-mail-headers t))
647 (goto-char (point-max))
648 ;; require one newline at the end.
649 (or (= (preceding-char) ?\n)
653 (or (mail-fetch-field "cc")
654 (mail-fetch-field "to")))
655 (message-insert-courtesy-copy))
656 (let ((case-fold-search t))
657 ;; Change header-delimiter to be what sendmail expects.
658 (goto-char (point-min))
660 (concat "^" (regexp-quote mail-header-separator) "\n"))
663 (setq delimline (point-marker))
664 ;; Insert an extra newline if we need it to work around
665 ;; Sun's bug that swallows newlines.
666 (goto-char (1+ delimline))
667 (when (eval message-mailer-swallows-blank-line)
671 nnsoup-replies-directory
672 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
673 nnsoup-replies-index-type))
675 (when (and msg-buf (bufferp msg-buf))
678 (goto-char (point-min))
679 (while (re-search-forward "^#! *rnews" nil t)
681 (message "Stored %d messages" num)))
682 (nnsoup-write-replies)
683 (kill-buffer tembuf))))))
685 (defun nnsoup-kind-to-prefix (kind)
686 (unless nnsoup-replies-list
687 (setq nnsoup-replies-list
688 (gnus-soup-parse-replies
689 (concat nnsoup-replies-directory "REPLIES"))))
690 (let ((replies nnsoup-replies-list))
692 (not (string= kind (gnus-soup-reply-kind (car replies)))))
693 (setq replies (cdr replies)))
695 (gnus-soup-reply-prefix (car replies))
696 (setq nnsoup-replies-list
697 (cons (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
700 nnsoup-replies-format-type
701 nnsoup-replies-index-type
702 (if (string= kind "news")
704 nnsoup-replies-list))
705 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
707 (defun nnsoup-make-active ()
708 "(Re-)create the SOUP active file."
710 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
712 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
713 (string-to-int (match-string 1 f1)))
714 (progn (string-match "/\\([0-9]+\\)\\." f2)
715 (string-to-int (match-string 1 f2)))))))
716 active group lines ident elem min)
717 (set-buffer (get-buffer-create " *nnsoup work*"))
718 (buffer-disable-undo (current-buffer))
720 (message "Doing %s..." (car files))
722 (insert-file-contents (car files))
723 (goto-char (point-min))
724 (if (not (re-search-forward "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t *\\(Xref: \\)? *[^ ]* \\([^ ]+\\):[0-9]" nil t))
725 (setq group "unknown")
726 (setq group (match-string 2)))
727 (setq lines (count-lines (point-min) (point-max)))
728 (setq ident (progn (string-match
729 "/\\([0-9]+\\)\\." (car files))
731 (car files) (match-beginning 1)
733 (if (not (setq elem (assoc group active)))
734 (push (list group (cons 1 lines)
736 (vector ident group "ncm" "" lines)))
740 (list (cons (1+ (setq min (cdadr elem)))
742 (vector ident group "ncm" "" lines))))
743 (setcdr (cadr elem) (+ min lines)))
744 (setq files (cdr files)))
746 (setq nnsoup-group-alist active)
747 (nnsoup-write-active-file t)))
749 (defun nnsoup-delete-unreferenced-message-files ()
750 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
752 (let* ((known (apply 'nconc (mapcar
756 (gnus-soup-area-prefix (cadr area)))
758 nnsoup-group-alist)))
759 (regexp "\\.MSG$\\|\\.IDX$")
760 (files (directory-files nnsoup-directory nil regexp))
762 ;; Find all files that aren't known by nnsoup.
763 (while (setq file (pop files))
764 (string-match regexp file)
765 (unless (member (substring file 0 (match-beginning 0)) known)
766 (push file non-files)))
767 ;; Sort and delete the files.
768 (setq non-files (sort non-files 'string<))
769 (map-y-or-n-p "Delete file %s? "
770 (lambda (file) (delete-file (concat nnsoup-directory file)))
775 ;;; nnsoup.el ends here