1 ;;; nnsoup.el --- SOUP access for Gnus
2 ;; Copyright (C) 1995,96,97 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.
34 (eval-when-compile (require 'cl))
38 (defvoo nnsoup-directory "~/SOUP/"
39 "*SOUP packet directory.")
41 (defvoo nnsoup-tmp-directory "/tmp/"
42 "*Where nnsoup will store temporary files.")
44 (defvoo nnsoup-replies-directory (concat nnsoup-directory "replies/")
45 "*Directory where outgoing packets will be composed.")
47 (defvoo nnsoup-replies-format-type ?n
48 "*Format of the replies packages.")
50 (defvoo nnsoup-replies-index-type ?n
51 "*Index type of the replies packages.")
53 (defvoo nnsoup-active-file (concat nnsoup-directory "active")
56 (defvoo nnsoup-packer "tar cf - %s | gzip > $HOME/Soupin%d.tgz"
57 "Format string command for packing a SOUP packet.
58 The SOUP files will be inserted where the %s is in the string.
59 This string MUST contain both %s and %d. The file number will be
60 inserted where %d appears.")
62 (defvoo nnsoup-unpacker "gunzip -c %s | tar xvf -"
63 "*Format string command for unpacking a SOUP packet.
64 The SOUP packet file name will be inserted at the %s.")
66 (defvoo nnsoup-packet-directory "~/"
67 "*Where nnsoup will look for incoming packets.")
69 (defvoo nnsoup-packet-regexp "Soupout"
70 "*Regular expression matching SOUP packets in `nnsoup-packet-directory'.")
74 (defconst nnsoup-version "nnsoup 0.0"
77 (defvoo nnsoup-status-string "")
78 (defvoo nnsoup-group-alist nil)
79 (defvoo nnsoup-current-prefix 0)
80 (defvoo nnsoup-replies-list nil)
81 (defvoo nnsoup-buffers nil)
82 (defvoo nnsoup-current-group nil)
83 (defvoo nnsoup-group-alist-touched nil)
84 (defvoo nnsoup-article-alist nil)
88 ;;; Interface functions.
90 (nnoo-define-basics nnsoup)
92 (deffoo nnsoup-retrieve-headers (sequence &optional group server fetch-old)
93 (nnsoup-possibly-change-group group)
95 (set-buffer nntp-server-buffer)
97 (let ((areas (cddr (assoc nnsoup-current-group nnsoup-group-alist)))
100 useful-areas this-area-seq msg-buf)
101 (if (stringp (car sequence))
102 ;; We don't support fetching by Message-ID.
104 ;; We go through all the areas and find which files the
105 ;; articles in SEQUENCE come from.
106 (while (and areas sequence)
107 ;; Peel off areas that are below sequence.
108 (while (and areas (< (cdaar areas) (car sequence)))
109 (setq areas (cdr areas)))
111 ;; This is a useful area.
112 (push (car areas) useful-areas)
113 (setq this-area-seq nil)
114 ;; We take note whether this MSG has a corresponding IDX
116 (when (or (= (gnus-soup-encoding-index
117 (gnus-soup-area-encoding (nth 1 (car areas)))) ?n)
120 (gnus-soup-area-prefix (nth 1 (car areas)))))))
122 ;; We assign the portion of `sequence' that is relevant to
123 ;; this MSG packet to this packet.
124 (while (and sequence (<= (car sequence) (cdaar areas)))
125 (push (car sequence) this-area-seq)
126 (setq sequence (cdr sequence)))
127 (setcar useful-areas (cons (nreverse this-area-seq)
128 (car useful-areas)))))
130 ;; We now have a list of article numbers and corresponding
132 (setq useful-areas (nreverse useful-areas))
134 ;; Two different approaches depending on whether all the MSG
135 ;; files have corresponding IDX files. If they all do, we
136 ;; simply return the relevant IDX files and let Gnus sort out
137 ;; what lines are relevant. If some of the IDX files are
138 ;; missing, we must return HEADs for all the articles.
140 ;; We have IDX files for all areas.
143 (goto-char (point-max))
145 (number (car (nth 1 (car useful-areas))))
146 (index-buffer (nnsoup-index-buffer
147 (gnus-soup-area-prefix
148 (nth 2 (car useful-areas))))))
150 (insert-buffer-substring index-buffer)
152 ;; We have to remove the index number entires and
153 ;; insert article numbers instead.
154 (while (looking-at "[0-9]+")
155 (replace-match (int-to-string number) t t)
158 (setq useful-areas (cdr useful-areas)))
162 (setq articles (caar useful-areas)
163 useful-areas (cdr useful-areas))
166 (nnsoup-narrow-to-article
167 (car articles) (cdar useful-areas) 'head))
168 (goto-char (point-max))
169 (insert (format "221 %d Article retrieved.\n" (car articles)))
170 (insert-buffer-substring msg-buf)
171 (goto-char (point-max))
173 (setq articles (cdr articles))))
175 (nnheader-fold-continuation-lines)
178 (deffoo nnsoup-open-server (server &optional defs)
179 (nnoo-change-server 'nnsoup server defs)
180 (when (not (file-exists-p nnsoup-directory))
182 (make-directory nnsoup-directory t)
185 ((not (file-exists-p nnsoup-directory))
186 (nnsoup-close-server)
187 (nnheader-report 'nnsoup "Couldn't create directory: %s" nnsoup-directory))
188 ((not (file-directory-p (file-truename nnsoup-directory)))
189 (nnsoup-close-server)
190 (nnheader-report 'nnsoup "Not a directory: %s" nnsoup-directory))
192 (nnsoup-read-active-file)
193 (nnheader-report 'nnsoup "Opened server %s using directory %s"
194 server nnsoup-directory)
197 (deffoo nnsoup-request-close ()
198 (nnsoup-write-active-file)
199 (nnsoup-write-replies)
200 (gnus-soup-save-areas)
201 ;; Kill all nnsoup buffers.
203 (while nnsoup-buffers
204 (setq buffer (cdr (pop nnsoup-buffers)))
207 (kill-buffer buffer))))
208 (setq nnsoup-group-alist nil
209 nnsoup-group-alist-touched nil
210 nnsoup-current-group nil
211 nnsoup-replies-list nil)
212 (nnoo-close-server 'nnoo)
215 (deffoo nnsoup-request-article (id &optional newsgroup server buffer)
216 (nnsoup-possibly-change-group newsgroup)
219 (set-buffer (or buffer nntp-server-buffer))
221 (when (and (not (stringp id))
222 (setq buf (nnsoup-narrow-to-article id)))
223 (insert-buffer-substring buf)
226 (deffoo nnsoup-request-group (group &optional server dont-check)
227 (nnsoup-possibly-change-group group)
230 (let ((active (cadr (assoc group nnsoup-group-alist))))
232 (nnheader-report 'nnsoup "No such group: %s" group)
235 (max (1+ (- (cdr active) (car active))) 0)
236 (car active) (cdr active) group)))))
238 (deffoo nnsoup-request-type (group &optional article)
239 (nnsoup-possibly-change-group group)
240 ;; Try to guess the type based on the first articl ein the group.
243 (cdaar (cddr (assoc group nnsoup-group-alist)))))
246 (let ((kind (gnus-soup-encoding-kind
247 (gnus-soup-area-encoding
248 (nth 1 (nnsoup-article-to-area
249 article nnsoup-current-group))))))
250 (cond ((= kind ?m) 'mail)
254 (deffoo nnsoup-close-group (group &optional server)
255 ;; Kill all nnsoup buffers.
256 (let ((buffers nnsoup-buffers)
259 (when (equal (car (setq elem (pop buffers))) group)
260 (setq nnsoup-buffers (delq elem nnsoup-buffers))
261 (and (cdr elem) (buffer-name (cdr elem))
262 (kill-buffer (cdr elem))))))
265 (deffoo nnsoup-request-list (&optional server)
267 (set-buffer nntp-server-buffer)
269 (unless nnsoup-group-alist
270 (nnsoup-read-active-file))
271 (let ((alist nnsoup-group-alist)
272 (standard-output (current-buffer))
274 (while (setq entry (pop alist))
275 (insert (car entry) " ")
276 (princ (cdadr entry))
278 (princ (caadr entry))
282 (deffoo nnsoup-request-scan (group &optional server)
283 (nnsoup-unpack-packets))
285 (deffoo nnsoup-request-newgroups (date &optional server)
286 (nnsoup-request-list))
288 (deffoo nnsoup-request-list-newsgroups (&optional server)
291 (deffoo nnsoup-request-post (&optional server)
292 (nnsoup-store-reply "news")
295 (deffoo nnsoup-request-mail (&optional server)
296 (nnsoup-store-reply "mail")
299 (deffoo nnsoup-request-expire-articles (articles group &optional server force)
300 (nnsoup-possibly-change-group group)
301 (let* ((total-infolist (assoc group nnsoup-group-alist))
302 (active (cadr total-infolist))
303 (infolist (cddr total-infolist))
304 info range-list mod-time prefix)
306 (setq info (pop infolist)
307 range-list (gnus-uncompress-range (car info))
308 prefix (gnus-soup-area-prefix (nth 1 info)))
309 (when ;; All the articles in this file are marked for expiry.
310 (and (or (setq mod-time (nth 5 (file-attributes
311 (nnsoup-file prefix))))
312 (setq mod-time (nth 5 (file-attributes
313 (nnsoup-file prefix t)))))
314 (gnus-sublist-p articles range-list)
315 ;; This file is old enough.
316 (nnmail-expired-article-p group mod-time force))
317 ;; Ok, we delete this file.
320 5 "Deleting %s in group %s..." (nnsoup-file prefix)
322 (when (file-exists-p (nnsoup-file prefix))
323 (delete-file (nnsoup-file prefix)))
325 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
327 (when (file-exists-p (nnsoup-file prefix t))
328 (delete-file (nnsoup-file prefix t)))
330 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
331 (setq articles (gnus-sorted-complement articles range-list))))
333 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
334 (if (cddr total-infolist)
335 (setcar active (caaadr (cdr total-infolist)))
336 (setcar active (1+ (cdr active))))
337 (nnsoup-write-active-file t)
338 ;; Return the articles that weren't expired.
342 ;;; Internal functions
344 (defun nnsoup-possibly-change-group (group &optional force)
346 (not (equal nnsoup-current-group group)))
347 (setq nnsoup-article-alist nil)
348 (setq nnsoup-current-group group))
351 (defun nnsoup-read-active-file ()
352 (setq nnsoup-group-alist nil)
353 (when (file-exists-p nnsoup-active-file)
355 (load nnsoup-active-file t t t))
356 ;; Be backwards compatible.
357 (when (and nnsoup-group-alist
358 (not (atom (caadar nnsoup-group-alist))))
359 (let ((alist nnsoup-group-alist)
361 (while (setq e (cdr (setq entry (pop alist))))
366 (setcdr entry (cons (cons min max) (cdr entry)))))
367 (setq nnsoup-group-alist-touched t))
370 (defun nnsoup-write-active-file (&optional force)
371 (when (and nnsoup-group-alist
373 nnsoup-group-alist-touched))
374 (setq nnsoup-group-alist-touched nil)
375 (nnheader-temp-write nnsoup-active-file
376 (gnus-prin1 `(setq nnsoup-group-alist ',nnsoup-group-alist))
378 (gnus-prin1 `(setq nnsoup-current-prefix ,nnsoup-current-prefix))
381 (defun nnsoup-next-prefix ()
382 "Return the next free prefix."
384 (while (or (file-exists-p
385 (nnsoup-file (setq prefix (int-to-string
386 nnsoup-current-prefix))))
387 (file-exists-p (nnsoup-file prefix t)))
388 (incf nnsoup-current-prefix))
389 (incf nnsoup-current-prefix)
392 (defun nnsoup-file-name (dir file)
393 "Return the full path of FILE (in any case) in DIR."
394 (let* ((case-fold-search t)
395 (files (directory-files dir t (concat (regexp-quote file) "$"))))
398 (defun nnsoup-read-areas ()
399 (let ((areas-file (nnsoup-file-name nnsoup-tmp-directory "areas")))
402 (set-buffer nntp-server-buffer)
403 (let ((areas (gnus-soup-parse-areas areas-file))
404 entry number area lnum cur-prefix file)
405 ;; Go through all areas in the new AREAS file.
406 (while (setq area (pop areas))
407 ;; Change the name to the permanent name and move the files.
408 (setq cur-prefix (nnsoup-next-prefix))
409 (message "Incorporating file %s..." cur-prefix)
411 (setq file (concat nnsoup-tmp-directory
412 (gnus-soup-area-prefix area) ".IDX")))
413 (rename-file file (nnsoup-file cur-prefix)))
415 (setq file (concat nnsoup-tmp-directory
416 (gnus-soup-area-prefix area) ".MSG")))
417 (rename-file file (nnsoup-file cur-prefix t))
418 (gnus-soup-set-area-prefix area cur-prefix)
419 ;; Find the number of new articles in this area.
420 (setq number (nnsoup-number-of-articles area))
421 (if (not (setq entry (assoc (gnus-soup-area-name area)
422 nnsoup-group-alist)))
423 ;; If this is a new area (group), we just add this info to
425 (push (list (gnus-soup-area-name area)
427 (list (cons 1 number) area))
429 ;; There are already articles in this group, so we add this
430 ;; info to the end of the entry.
431 (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
434 (setcdr (cadr entry) (+ lnum number))))))
435 (nnsoup-write-active-file t)
436 (delete-file areas-file)))))
438 (defun nnsoup-number-of-articles (area)
441 ;; If the number is in the area info, we just return it.
442 ((gnus-soup-area-number area)
443 (gnus-soup-area-number area))
444 ;; If there is an index file, we just count the lines.
445 ((/= (gnus-soup-encoding-index (gnus-soup-area-encoding area)) ?n)
446 (set-buffer (nnsoup-index-buffer (gnus-soup-area-prefix area)))
447 (count-lines (point-min) (point-max)))
448 ;; We do it the hard way - re-searching through the message
451 (set-buffer (nnsoup-message-buffer (gnus-soup-area-prefix area)))
452 (unless (assoc (gnus-soup-area-prefix area) nnsoup-article-alist)
453 (nnsoup-dissect-buffer area))
454 (length (cdr (assoc (gnus-soup-area-prefix area)
455 nnsoup-article-alist)))))))
457 (defun nnsoup-dissect-buffer (area)
458 (let ((mbox-delim (concat "^" message-unix-mail-delimiter))
459 (format (gnus-soup-encoding-format (gnus-soup-area-encoding area)))
462 (goto-char (point-min))
464 ;; rnews batch format
466 (while (looking-at "^#! *rnews \\(+[0-9]+\\) *$")
471 (forward-char (string-to-number (match-string 1)))
476 (while (looking-at mbox-delim)
481 (if (re-search-forward mbox-delim nil t)
483 (goto-char (point-max)))
488 (while (looking-at "\^A\^A\^A\^A\n")
493 (if (search-forward "\n\^A\^A\^A\^A\n" nil t)
495 (goto-char (point-max)))
499 ((or (= format ?B) (= format ?b))
501 (setq len (+ (* (char-after (point)) (expt 2.0 24))
502 (* (char-after (+ (point) 1)) (expt 2 16))
503 (* (char-after (+ (point) 2)) (expt 2 8))
504 (char-after (+ (point) 3))))
506 (incf i) (+ (point) 4)
508 (forward-char (floor (+ len 4)))
512 (error "Unknown format: %c" format)))
513 (push (cons (gnus-soup-area-prefix area) alist) nnsoup-article-alist)))
515 (defun nnsoup-index-buffer (prefix &optional message)
516 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
517 (buffer-name (concat " *nnsoup " file "*")))
518 (or (get-buffer buffer-name) ; File already loaded.
519 (when (file-exists-p (concat nnsoup-directory file))
520 (save-excursion ; Load the file.
521 (set-buffer (get-buffer-create buffer-name))
522 (buffer-disable-undo (current-buffer))
523 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
524 (nnheader-insert-file-contents (concat nnsoup-directory file))
525 (current-buffer))))))
527 (defun nnsoup-file (prefix &optional message)
529 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
531 (defun nnsoup-message-buffer (prefix)
532 (nnsoup-index-buffer prefix 'msg))
534 (defun nnsoup-unpack-packets ()
535 "Unpack all packets in `nnsoup-packet-directory'."
536 (let ((packets (directory-files
537 nnsoup-packet-directory t nnsoup-packet-regexp))
539 (while (setq packet (pop packets))
540 (message "nnsoup: unpacking %s..." packet)
541 (if (not (gnus-soup-unpack-packet
542 nnsoup-tmp-directory nnsoup-unpacker packet))
543 (message "Couldn't unpack %s" packet)
546 (message "Unpacking...done")))))
548 (defun nnsoup-narrow-to-article (article &optional area head)
549 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
550 (prefix (and area (gnus-soup-area-prefix (nth 1 area))))
551 (msg-buf (and prefix (nnsoup-index-buffer prefix 'msg)))
556 ;; There is no MSG file.
559 ;; We use the index file to find out where the article
561 ((and (= (gnus-soup-encoding-index
562 (gnus-soup-area-encoding (nth 1 area)))
564 (file-exists-p (nnsoup-file prefix)))
565 (set-buffer (nnsoup-index-buffer prefix))
567 (goto-char (point-min))
568 (forward-line (- article (caar area)))
569 (setq beg (read (current-buffer)))
571 (if (looking-at "[0-9]+")
573 (setq end (read (current-buffer)))
576 (let ((format (gnus-soup-encoding-format
577 (gnus-soup-area-encoding (nth 1 area)))))
579 (when (or (= format ?n) (= format ?m))
580 (setq end (progn (forward-line -1) (point))))))
581 (set-buffer msg-buf))
583 (narrow-to-region beg (or end (point-max))))
587 (unless (assoc (gnus-soup-area-prefix (nth 1 area))
588 nnsoup-article-alist)
589 (nnsoup-dissect-buffer (nth 1 area)))
590 (let ((entry (assq article (cdr (assoc (gnus-soup-area-prefix
592 nnsoup-article-alist)))))
594 (narrow-to-region (cadr entry) (caddr entry))))))
595 (goto-char (point-min))
600 (if (search-forward "\n\n" nil t)
606 (defun nnsoup-pack-replies ()
607 "Make an outbound package of SOUP replies."
609 (unless (file-exists-p nnsoup-replies-directory)
610 (message "No such directory: %s" nnsoup-replies-directory))
611 ;; Write all data buffers.
612 (gnus-soup-save-areas)
613 ;; Write the active file.
614 (nnsoup-write-active-file)
615 ;; Write the REPLIES file.
616 (nnsoup-write-replies)
617 ;; Check whether there is anything here.
618 (when (null (directory-files nnsoup-replies-directory nil "\\.MSG$"))
619 (error "No files to pack."))
620 ;; Pack all these files into a SOUP packet.
621 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
623 (defun nnsoup-write-replies ()
624 "Write the REPLIES file."
625 (when nnsoup-replies-list
626 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
627 (setq nnsoup-replies-list nil)))
629 (defun nnsoup-article-to-area (article group)
630 "Return the area that ARTICLE in GROUP is located in."
631 (let ((areas (cddr (assoc group nnsoup-group-alist))))
632 (while (and areas (< (cdaar areas) article))
633 (setq areas (cdr areas)))
634 (and areas (car areas))))
636 (defvar nnsoup-old-functions
637 (list message-send-mail-function message-send-news-function))
640 (defun nnsoup-set-variables ()
641 "Use the SOUP methods for posting news and mailing mail."
643 (setq message-send-news-function 'nnsoup-request-post)
644 (setq message-send-mail-function 'nnsoup-request-mail))
647 (defun nnsoup-revert-variables ()
648 "Revert posting and mailing methods to the standard Emacs methods."
650 (setq message-send-mail-function (car nnsoup-old-functions))
651 (setq message-send-news-function (cadr nnsoup-old-functions)))
653 (defun nnsoup-store-reply (kind)
654 ;; Mostly stolen from `message.el'.
655 (require 'mail-utils)
656 (let ((tembuf (generate-new-buffer " message temp"))
657 (case-fold-search nil)
659 (mailbuf (current-buffer)))
663 (message-narrow-to-headers)
664 (if (equal kind "mail")
665 (message-generate-headers message-required-mail-headers)
666 (message-generate-headers message-required-news-headers)))
669 (insert-buffer-substring mailbuf)
670 ;; Remove some headers.
672 (message-narrow-to-headers)
673 ;; Remove some headers.
674 (message-remove-header message-ignored-mail-headers t))
675 (goto-char (point-max))
676 ;; require one newline at the end.
677 (or (= (preceding-char) ?\n)
679 (let ((case-fold-search t))
680 ;; Change header-delimiter to be what sendmail expects.
681 (goto-char (point-min))
683 (concat "^" (regexp-quote mail-header-separator) "\n"))
686 (setq delimline (point-marker))
687 ;; Insert an extra newline if we need it to work around
688 ;; Sun's bug that swallows newlines.
689 (goto-char (1+ delimline))
690 (when (eval message-mailer-swallows-blank-line)
694 nnsoup-replies-directory
695 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
696 nnsoup-replies-index-type))
698 (when (and msg-buf (bufferp msg-buf))
701 (goto-char (point-min))
702 (while (re-search-forward "^#! *rnews" nil t)
704 (message "Stored %d messages" num)))
705 (nnsoup-write-replies)
706 (kill-buffer tembuf))))))
708 (defun nnsoup-kind-to-prefix (kind)
709 (unless nnsoup-replies-list
710 (setq nnsoup-replies-list
711 (gnus-soup-parse-replies
712 (concat nnsoup-replies-directory "REPLIES"))))
713 (let ((replies nnsoup-replies-list))
715 (not (string= kind (gnus-soup-reply-kind (car replies)))))
716 (setq replies (cdr replies)))
718 (gnus-soup-reply-prefix (car replies))
719 (push (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
722 nnsoup-replies-format-type
723 nnsoup-replies-index-type
724 (if (string= kind "news")
727 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
729 (defun nnsoup-make-active ()
730 "(Re-)create the SOUP active file."
732 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
734 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
735 (string-to-int (match-string 1 f1)))
736 (progn (string-match "/\\([0-9]+\\)\\." f2)
737 (string-to-int (match-string 1 f2)))))))
738 active group lines ident elem min)
739 (set-buffer (get-buffer-create " *nnsoup work*"))
740 (buffer-disable-undo (current-buffer))
742 (message "Doing %s..." (car files))
744 (nnheader-insert-file-contents (car files))
745 (goto-char (point-min))
746 (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))
747 (setq group "unknown")
748 (setq group (match-string 2)))
749 (setq lines (count-lines (point-min) (point-max)))
750 (setq ident (progn (string-match
751 "/\\([0-9]+\\)\\." (car files))
753 (car files) (match-beginning 1)
755 (if (not (setq elem (assoc group active)))
756 (push (list group (cons 1 lines)
758 (vector ident group "ncm" "" lines)))
762 (list (cons (1+ (setq min (cdadr elem)))
764 (vector ident group "ncm" "" lines))))
765 (setcdr (cadr elem) (+ min lines)))
766 (setq files (cdr files)))
768 (setq nnsoup-group-alist active)
769 (nnsoup-write-active-file t)))
771 (defun nnsoup-delete-unreferenced-message-files ()
772 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
774 (let* ((known (apply 'nconc (mapcar
778 (gnus-soup-area-prefix (cadr area)))
780 nnsoup-group-alist)))
781 (regexp "\\.MSG$\\|\\.IDX$")
782 (files (directory-files nnsoup-directory nil regexp))
784 ;; Find all files that aren't known by nnsoup.
785 (while (setq file (pop files))
786 (string-match regexp file)
787 (unless (member (substring file 0 (match-beginning 0)) known)
788 (push file non-files)))
789 ;; Sort and delete the files.
790 (setq non-files (sort non-files 'string<))
791 (map-y-or-n-p "Delete file %s? "
792 (lambda (file) (delete-file (concat nnsoup-directory file)))
797 ;;; nnsoup.el ends here