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)
251 (let ((buffer (or buffer nntp-server-buffer)))
257 (insert-buffer-substring
258 (nnsoup-narrow-to-article id))
261 (defun nnsoup-request-group (group &optional server dont-check)
262 (nnsoup-possibly-change-group group)
265 (let ((active (cadr (assoc group nnsoup-group-alist))))
267 (nnheader-report 'nnsoup "No such group: %s" group)
270 (max (1+ (- (cdr active) (car active))) 0)
271 (car active) (cdr active) group)))))
273 (defun nnsoup-request-type (group &optional article)
274 (nnsoup-possibly-change-group group)
277 (let ((kind (gnus-soup-encoding-kind
278 (gnus-soup-area-encoding
279 (nth 1 (nnsoup-article-to-area
280 article nnsoup-current-group))))))
281 (cond ((= kind ?m) 'mail)
285 (defun nnsoup-close-group (group &optional server)
286 ;; Kill all nnsoup buffers.
287 (let ((buffers nnsoup-buffers)
290 (when (equal (car (setq elem (pop buffers))) group)
291 (setq nnsoup-buffers (delq elem nnsoup-buffers))
292 (and (cdr elem) (buffer-name (cdr elem))
293 (kill-buffer (cdr elem))))))
296 (defun nnsoup-request-list (&optional server)
298 (set-buffer nntp-server-buffer)
300 (let ((alist nnsoup-group-alist)
301 (standard-output (current-buffer))
303 (while (setq entry (pop alist))
304 (insert (car entry) " ")
305 (princ (cdadr entry))
307 (princ (caadr entry))
311 (defun nnsoup-request-scan (group &optional server)
312 (nnsoup-unpack-packets))
314 (defun nnsoup-request-newgroups (date &optional server)
315 (nnsoup-request-list))
317 (defun nnsoup-request-list-newsgroups (&optional server)
320 (defun nnsoup-request-post (&optional server)
321 (nnsoup-store-reply "news")
324 (defun nnsoup-request-mail ()
325 (nnsoup-store-reply "mail")
328 (defun nnsoup-request-expire-articles (articles group &optional server force)
329 (nnsoup-possibly-change-group group)
330 (let* ((total-infolist (assoc group nnsoup-group-alist))
331 (active (cadr total-infolist))
332 (infolist (cddr total-infolist))
333 info range-list mod-time prefix)
335 (setq info (pop infolist)
336 range-list (gnus-uncompress-range (car info))
337 prefix (gnus-soup-area-prefix (nth 1 info)))
338 (when ;; All the articles in this file are marked for expiry.
339 (and (or (setq mod-time (nth 5 (file-attributes
340 (nnsoup-file prefix))))
341 (setq mod-time (nth 5 (file-attributes
342 (nnsoup-file prefix t)))))
343 (gnus-sublist-p articles range-list)
344 ;; This file is old enough.
345 (nnmail-expired-article-p group mod-time force))
346 ;; Ok, we delete this file.
347 (when (condition-case nil
350 5 "Deleting %s in group %s..." (nnsoup-file prefix)
352 (when (file-exists-p (nnsoup-file prefix))
353 (delete-file (nnsoup-file prefix)))
355 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
357 (when (file-exists-p (nnsoup-file prefix t))
358 (delete-file (nnsoup-file prefix t)))
361 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
362 (setq articles (gnus-sorted-complement articles range-list))))
364 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
365 (if (cddr total-infolist)
366 (setcar active (caaadr (cdr total-infolist)))
367 (setcar active (1+ (cdr active))))
368 (nnsoup-write-active-file t)
369 ;; Return the articles that weren't expired.
373 ;;; Internal functions
375 (defun nnsoup-possibly-change-group (group &optional force)
377 (setq nnsoup-current-group group)
380 (defun nnsoup-read-active-file ()
381 (setq nnsoup-group-alist)
382 (when (file-exists-p nnsoup-active-file)
384 (load nnsoup-active-file t t t)
386 ;; Be backwards compatible.
387 (when (and nnsoup-group-alist
388 (not (atom (caadar nnsoup-group-alist))))
389 (let ((alist nnsoup-group-alist)
391 (while (setq e (cdr (setq entry (pop alist))))
396 (setcdr entry (cons (cons min max) (cdr entry)))))
397 (setq nnsoup-group-alist-touched t))
400 (defun nnsoup-write-active-file (&optional force)
401 (when (and nnsoup-group-alist
403 nnsoup-group-alist-touched))
404 (setq nnsoup-group-alist-touched nil)
405 (nnheader-temp-write nnsoup-active-file
406 (let ((standard-output (current-buffer)))
407 (prin1 `(setq nnsoup-group-alist ',nnsoup-group-alist))
409 (prin1 `(setq nnsoup-current-prefix ,nnsoup-current-prefix))
412 (defun nnsoup-next-prefix ()
413 "Return the next free prefix."
415 (while (or (file-exists-p
416 (nnsoup-file (setq prefix (int-to-string
417 nnsoup-current-prefix))))
418 (file-exists-p (nnsoup-file prefix t)))
419 (incf nnsoup-current-prefix))
420 (incf nnsoup-current-prefix)
423 (defun nnsoup-read-areas ()
425 (set-buffer nntp-server-buffer)
426 (let ((areas (gnus-soup-parse-areas (concat nnsoup-tmp-directory "AREAS")))
427 entry number area lnum cur-prefix file)
428 ;; Go through all areas in the new AREAS file.
429 (while (setq area (pop areas))
430 ;; Change the name to the permanent name and move the files.
431 (setq cur-prefix (nnsoup-next-prefix))
432 (message "Incorporating file %s..." cur-prefix)
434 (setq file (concat nnsoup-tmp-directory
435 (gnus-soup-area-prefix area) ".IDX")))
436 (rename-file file (nnsoup-file cur-prefix)))
438 (setq file (concat nnsoup-tmp-directory
439 (gnus-soup-area-prefix area) ".MSG")))
440 (rename-file file (nnsoup-file cur-prefix t))
441 (gnus-soup-set-area-prefix area cur-prefix)
442 ;; Find the number of new articles in this area.
443 (setq number (nnsoup-number-of-articles area))
444 (if (not (setq entry (assoc (gnus-soup-area-name area)
445 nnsoup-group-alist)))
446 ;; If this is a new area (group), we just add this info to
448 (push (list (gnus-soup-area-name area)
450 (list (cons 1 number) area))
452 ;; There are already articles in this group, so we add this
453 ;; info to the end of the entry.
454 (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
457 (setcdr (cadr entry) (+ lnum number))))))
458 (nnsoup-write-active-file t)
459 (delete-file (concat nnsoup-tmp-directory "AREAS"))))
461 (defun nnsoup-number-of-articles (area)
464 ;; If the number is in the area info, we just return it.
465 ((gnus-soup-area-number area)
466 (gnus-soup-area-number area))
467 ;; If there is an index file, we just count the lines.
468 ((/= (gnus-soup-encoding-index (gnus-soup-area-encoding area)) ?n)
469 (set-buffer (nnsoup-index-buffer (gnus-soup-area-prefix area)))
470 (count-lines (point-min) (point-max)))
471 ;; We do it the hard way - re-searching through the message
474 (set-buffer (nnsoup-message-buffer (gnus-soup-area-prefix area)))
475 (goto-char (point-min))
476 (let ((regexp (nnsoup-header (gnus-soup-encoding-format
477 (gnus-soup-area-encoding area))))
479 (while (re-search-forward regexp nil t)
483 (defun nnsoup-index-buffer (prefix &optional message)
484 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
485 (buffer-name (concat " *nnsoup " file "*")))
486 (or (get-buffer buffer-name) ; File aready loaded.
487 (when (file-exists-p (concat nnsoup-directory file))
488 (save-excursion ; Load the file.
489 (set-buffer (get-buffer-create buffer-name))
490 (buffer-disable-undo (current-buffer))
491 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
492 (insert-file-contents (concat nnsoup-directory file))
493 (current-buffer))))))
495 (defun nnsoup-file (prefix &optional message)
497 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
499 (defun nnsoup-message-buffer (prefix)
500 (nnsoup-index-buffer prefix 'msg))
502 (defun nnsoup-unpack-packets ()
503 "Unpack all packets in `nnsoup-packet-directory'."
504 (let ((packets (directory-files
505 nnsoup-packet-directory t nnsoup-packet-regexp))
507 (while (setq packet (pop packets))
508 (message (format "nnsoup: unpacking %s..." packet))
509 (if (not (gnus-soup-unpack-packet
510 nnsoup-tmp-directory nnsoup-unpacker packet))
511 (message "Couldn't unpack %s" packet)
514 (message "Unpacking...done")))))
516 (defun nnsoup-narrow-to-article (article &optional area head)
517 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
518 (prefix (gnus-soup-area-prefix (nth 1 area)))
519 (msg-buf (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 gnus-inews-article-function send-mail-function))
615 (defun nnsoup-set-variables ()
616 "Use the SOUP methods for posting news and mailing mail."
618 (setq gnus-inews-article-function 'nnsoup-request-post)
619 (setq send-mail-function 'nnsoup-request-mail))
622 (defun nnsoup-revert-variables ()
623 "Revert posting and mailing methods to the standard Emacs methods."
625 (setq gnus-inews-article-function (car nnsoup-old-functions))
626 (setq send-mail-function (cadr nnsoup-old-functions)))
628 (defun nnsoup-store-reply (kind)
629 ;; Mostly stolen from `sendmail.el'.
630 (let ((tembuf (generate-new-buffer " sendmail temp"))
631 (case-fold-search nil)
632 (mailbuf (current-buffer))
637 (insert-buffer-substring mailbuf)
638 (goto-char (point-max))
639 ;; require one newline at the end.
640 (or (= (preceding-char) ?\n)
642 ;; Change header-delimiter to be what sendmail expects.
643 (goto-char (point-min))
644 (if (re-search-forward
645 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
647 (search-forward "\n\n" nil t))
649 (setq delimline (point-marker))
650 (if (and mail-aliases (fboundp 'expand-mail-aliases))
651 (expand-mail-aliases (point-min) delimline))
652 (goto-char (point-min))
653 ;; ignore any blank lines in the header
654 (while (and (re-search-forward "\n\n\n*" delimline t)
655 (< (point) delimline))
656 (replace-match "\n"))
657 (let ((case-fold-search t))
658 (goto-char (point-min))
659 ;; Find and handle any FCC fields.
660 (goto-char (point-min))
661 (if (re-search-forward "^FCC:" delimline t)
662 (mail-do-fcc delimline))
663 (goto-char (point-min))
664 ;; "S:" is an abbreviation for "Subject:".
665 (goto-char (point-min))
666 (if (re-search-forward "^S:" delimline t)
667 (replace-match "Subject:"))
668 ;; Don't send out a blank subject line
669 (goto-char (point-min))
670 (if (re-search-forward "^Subject:[ \t]*\n" delimline t)
672 ;; Insert an extra newline if we need it to work around
673 ;; Sun's bug that swallows newlines.
674 (goto-char (1+ delimline))
675 (if (and (boundp 'mail-mailer-swallows-blank-line)
676 (eval mail-mailer-swallows-blank-line))
680 nnsoup-replies-directory
681 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
682 nnsoup-replies-index-type))
684 (when (and msg-buf (bufferp msg-buf))
687 (goto-char (point-min))
688 (while (re-search-forward "^#! *rnews" nil t)
690 (message "Stored %d messages" num)))
691 (nnsoup-write-replies)
692 (kill-buffer tembuf))))
694 (defun nnsoup-kind-to-prefix (kind)
695 (unless nnsoup-replies-list
696 (setq nnsoup-replies-list
697 (gnus-soup-parse-replies
698 (concat nnsoup-replies-directory "REPLIES"))))
699 (let ((replies nnsoup-replies-list))
701 (not (string= kind (gnus-soup-reply-kind (car replies)))))
702 (setq replies (cdr replies)))
704 (gnus-soup-reply-prefix (car replies))
705 (setq nnsoup-replies-list
706 (cons (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
709 nnsoup-replies-format-type
710 nnsoup-replies-index-type
711 (if (string= kind "news")
713 nnsoup-replies-list))
714 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
716 (defun nnsoup-make-active ()
717 "(Re-)create the SOUP active file."
719 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
721 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
722 (string-to-int (match-string 1 f1)))
723 (progn (string-match "/\\([0-9]+\\)\\." f2)
724 (string-to-int (match-string 1 f2)))))))
725 active group lines ident elem min)
726 (set-buffer (get-buffer-create " *nnsoup work*"))
727 (buffer-disable-undo (current-buffer))
729 (message "Doing %s..." (car files))
731 (insert-file-contents (car files))
732 (goto-char (point-min))
733 (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))
734 (setq group "unknown")
735 (setq group (match-string 2)))
736 (setq lines (count-lines (point-min) (point-max)))
737 (setq ident (progn (string-match
738 "/\\([0-9]+\\)\\." (car files))
740 (car files) (match-beginning 1)
742 (if (not (setq elem (assoc group active)))
743 (push (list group (cons 1 lines)
745 (vector ident group "ncm" "" lines)))
749 (list (cons (1+ (setq min (cdadr elem)))
751 (vector ident group "ncm" "" lines))))
752 (setcdr (cadr elem) (+ min lines)))
753 (setq files (cdr files)))
755 (setq nnsoup-group-alist active)
756 (nnsoup-write-active-file t)))
758 (defun nnsoup-delete-unreferenced-message-files ()
759 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
761 (let* ((known (apply 'nconc (mapcar
765 (gnus-soup-area-prefix (cadr area)))
767 nnsoup-group-alist)))
768 (regexp "\\.MSG$\\|\\.IDX$")
769 (files (directory-files nnsoup-directory nil regexp))
771 ;; Find all files that aren't known by nnsoup.
772 (while (setq file (pop files))
773 (string-match regexp file)
774 (unless (member (substring file 0 (match-beginning 0)) known)
775 (push file non-files)))
776 ;; Sort and delete the files.
777 (setq non-files (sort non-files 'string<))
778 (map-y-or-n-p "Delete file %s? "
779 (lambda (file) (delete-file (concat nnsoup-directory file)))
784 ;;; nnsoup.el ends here