1 ;;; nnsoup.el --- SOUP access for Gnus
2 ;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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
42 (cond ((fboundp 'temp-directory) (temp-directory))
43 ((boundp 'temporary-file-directory) temporary-file-directory)
45 "*Where nnsoup will store temporary files.")
47 (defvoo nnsoup-replies-directory (concat nnsoup-directory "replies/")
48 "*Directory where outgoing packets will be composed.")
50 (defvoo nnsoup-replies-format-type ?n
51 "*Format of the replies packages.")
53 (defvoo nnsoup-replies-index-type ?n
54 "*Index type of the replies packages.")
56 (defvoo nnsoup-active-file (concat nnsoup-directory "active")
59 (defvoo nnsoup-packer "tar cf - %s | gzip > $HOME/Soupin%d.tgz"
60 "Format string command for packing a SOUP packet.
61 The SOUP files will be inserted where the %s is in the string.
62 This string MUST contain both %s and %d. The file number will be
63 inserted where %d appears.")
65 (defvoo nnsoup-unpacker "gunzip -c %s | tar xvf -"
66 "*Format string command for unpacking a SOUP packet.
67 The SOUP packet file name will be inserted at the %s.")
69 (defvoo nnsoup-packet-directory "~/"
70 "*Where nnsoup will look for incoming packets.")
72 (defvoo nnsoup-packet-regexp "Soupout"
73 "*Regular expression matching SOUP packets in `nnsoup-packet-directory'.")
75 (defvoo nnsoup-always-save t
76 "If non nil commit the reply buffer on each message send.
77 This is necessary if using message mode outside Gnus with nnsoup as a
78 backend for the messages.")
82 (defconst nnsoup-version "nnsoup 0.0"
85 (defvoo nnsoup-status-string "")
86 (defvoo nnsoup-group-alist nil)
87 (defvoo nnsoup-current-prefix 0)
88 (defvoo nnsoup-replies-list nil)
89 (defvoo nnsoup-buffers nil)
90 (defvoo nnsoup-current-group nil)
91 (defvoo nnsoup-group-alist-touched nil)
92 (defvoo nnsoup-article-alist nil)
95 ;;; Interface functions.
97 (nnoo-define-basics nnsoup)
99 (deffoo nnsoup-retrieve-headers (sequence &optional group server fetch-old)
100 (nnsoup-possibly-change-group group)
102 (set-buffer nntp-server-buffer)
104 (let ((areas (cddr (assoc nnsoup-current-group nnsoup-group-alist)))
107 useful-areas this-area-seq msg-buf)
108 (if (stringp (car sequence))
109 ;; We don't support fetching by Message-ID.
111 ;; We go through all the areas and find which files the
112 ;; articles in SEQUENCE come from.
113 (while (and areas sequence)
114 ;; Peel off areas that are below sequence.
115 (while (and areas (< (cdaar areas) (car sequence)))
116 (setq areas (cdr areas)))
118 ;; This is a useful area.
119 (push (car areas) useful-areas)
120 (setq this-area-seq nil)
121 ;; We take note whether this MSG has a corresponding IDX
123 (when (or (= (gnus-soup-encoding-index
124 (gnus-soup-area-encoding (nth 1 (car areas)))) ?n)
127 (gnus-soup-area-prefix (nth 1 (car areas)))))))
129 ;; We assign the portion of `sequence' that is relevant to
130 ;; this MSG packet to this packet.
131 (while (and sequence (<= (car sequence) (cdaar areas)))
132 (push (car sequence) this-area-seq)
133 (setq sequence (cdr sequence)))
134 (setcar useful-areas (cons (nreverse this-area-seq)
135 (car useful-areas)))))
137 ;; We now have a list of article numbers and corresponding
139 (setq useful-areas (nreverse useful-areas))
141 ;; Two different approaches depending on whether all the MSG
142 ;; files have corresponding IDX files. If they all do, we
143 ;; simply return the relevant IDX files and let Gnus sort out
144 ;; what lines are relevant. If some of the IDX files are
145 ;; missing, we must return HEADs for all the articles.
147 ;; We have IDX files for all areas.
150 (goto-char (point-max))
152 (number (car (nth 1 (car useful-areas))))
153 (index-buffer (nnsoup-index-buffer
154 (gnus-soup-area-prefix
155 (nth 2 (car useful-areas))))))
157 (insert-buffer-substring index-buffer)
159 ;; We have to remove the index number entires and
160 ;; insert article numbers instead.
161 (while (looking-at "[0-9]+")
162 (replace-match (int-to-string number) t t)
165 (setq useful-areas (cdr useful-areas)))
169 (setq articles (caar useful-areas)
170 useful-areas (cdr useful-areas))
173 (nnsoup-narrow-to-article
174 (car articles) (cdar useful-areas) 'head))
175 (goto-char (point-max))
176 (insert (format "221 %d Article retrieved.\n" (car articles)))
177 (insert-buffer-substring msg-buf)
178 (goto-char (point-max))
180 (setq articles (cdr articles))))
182 (nnheader-fold-continuation-lines)
185 (deffoo nnsoup-open-server (server &optional defs)
186 (nnoo-change-server 'nnsoup server defs)
187 (when (not (file-exists-p nnsoup-directory))
189 (make-directory nnsoup-directory t)
192 ((not (file-exists-p nnsoup-directory))
193 (nnsoup-close-server)
194 (nnheader-report 'nnsoup "Couldn't create directory: %s" nnsoup-directory))
195 ((not (file-directory-p (file-truename nnsoup-directory)))
196 (nnsoup-close-server)
197 (nnheader-report 'nnsoup "Not a directory: %s" nnsoup-directory))
199 (nnsoup-read-active-file)
200 (nnheader-report 'nnsoup "Opened server %s using directory %s"
201 server nnsoup-directory)
204 (deffoo nnsoup-request-close ()
205 (nnsoup-write-active-file)
206 (nnsoup-write-replies)
207 (gnus-soup-save-areas)
208 ;; Kill all nnsoup buffers.
210 (while nnsoup-buffers
211 (setq buffer (cdr (pop nnsoup-buffers)))
214 (kill-buffer buffer))))
215 (setq nnsoup-group-alist nil
216 nnsoup-group-alist-touched nil
217 nnsoup-current-group nil
218 nnsoup-replies-list nil)
219 (nnoo-close-server 'nnoo)
222 (deffoo nnsoup-request-article (id &optional newsgroup server buffer)
223 (nnsoup-possibly-change-group newsgroup)
226 (set-buffer (or buffer nntp-server-buffer))
228 (when (and (not (stringp id))
229 (setq buf (nnsoup-narrow-to-article id)))
230 (insert-buffer-substring buf)
233 (deffoo nnsoup-request-group (group &optional server dont-check)
234 (nnsoup-possibly-change-group group)
237 (let ((active (cadr (assoc group nnsoup-group-alist))))
239 (nnheader-report 'nnsoup "No such group: %s" group)
242 (max (1+ (- (cdr active) (car active))) 0)
243 (car active) (cdr active) group)))))
245 (deffoo nnsoup-request-type (group &optional article)
246 (nnsoup-possibly-change-group group)
247 ;; Try to guess the type based on the first article in the group.
250 (cdaar (cddr (assoc group nnsoup-group-alist)))))
253 (let ((kind (gnus-soup-encoding-kind
254 (gnus-soup-area-encoding
255 (nth 1 (nnsoup-article-to-area
256 article nnsoup-current-group))))))
257 (cond ((= kind ?m) 'mail)
261 (deffoo nnsoup-close-group (group &optional server)
262 ;; Kill all nnsoup buffers.
263 (let ((buffers nnsoup-buffers)
266 (when (equal (car (setq elem (pop buffers))) group)
267 (setq nnsoup-buffers (delq elem nnsoup-buffers))
268 (and (cdr elem) (buffer-name (cdr elem))
269 (kill-buffer (cdr elem))))))
272 (deffoo nnsoup-request-list (&optional server)
274 (set-buffer nntp-server-buffer)
276 (unless nnsoup-group-alist
277 (nnsoup-read-active-file))
278 (let ((alist nnsoup-group-alist)
279 (standard-output (current-buffer))
281 (while (setq entry (pop alist))
282 (insert (car entry) " ")
283 (princ (cdadr entry))
285 (princ (caadr entry))
289 (deffoo nnsoup-request-scan (group &optional server)
290 (nnsoup-unpack-packets))
292 (deffoo nnsoup-request-newgroups (date &optional server)
293 (nnsoup-request-list))
295 (deffoo nnsoup-request-list-newsgroups (&optional server)
298 (deffoo nnsoup-request-post (&optional server)
299 (nnsoup-store-reply "news")
302 (deffoo nnsoup-request-mail (&optional server)
303 (nnsoup-store-reply "mail")
306 (deffoo nnsoup-request-expire-articles (articles group &optional server force)
307 (nnsoup-possibly-change-group group)
308 (let* ((total-infolist (assoc group nnsoup-group-alist))
309 (active (cadr total-infolist))
310 (infolist (cddr total-infolist))
311 info range-list mod-time prefix)
313 (setq info (pop infolist)
314 range-list (gnus-uncompress-range (car info))
315 prefix (gnus-soup-area-prefix (nth 1 info)))
316 (when ;; All the articles in this file are marked for expiry.
317 (and (or (setq mod-time (nth 5 (file-attributes
318 (nnsoup-file prefix))))
319 (setq mod-time (nth 5 (file-attributes
320 (nnsoup-file prefix t)))))
321 (gnus-sublist-p articles range-list)
322 ;; This file is old enough.
323 (nnmail-expired-article-p group mod-time force))
324 ;; Ok, we delete this file.
327 5 "Deleting %s in group %s..." (nnsoup-file prefix)
329 (when (file-exists-p (nnsoup-file prefix))
330 (delete-file (nnsoup-file prefix)))
332 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
334 (when (file-exists-p (nnsoup-file prefix t))
335 (delete-file (nnsoup-file prefix t)))
337 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
338 (setq articles (gnus-sorted-complement articles range-list))))
340 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
341 (if (cddr total-infolist)
342 (setcar active (caaadr (cdr total-infolist)))
343 (setcar active (1+ (cdr active))))
344 (nnsoup-write-active-file t)
345 ;; Return the articles that weren't expired.
349 ;;; Internal functions
351 (defun nnsoup-possibly-change-group (group &optional force)
353 (not (equal nnsoup-current-group group)))
354 (setq nnsoup-article-alist nil)
355 (setq nnsoup-current-group group))
358 (defun nnsoup-read-active-file ()
359 (setq nnsoup-group-alist nil)
360 (when (file-exists-p nnsoup-active-file)
362 (load nnsoup-active-file t t t))
363 ;; Be backwards compatible.
364 (when (and nnsoup-group-alist
365 (not (atom (caadar nnsoup-group-alist))))
366 (let ((alist nnsoup-group-alist)
368 (while (setq e (cdr (setq entry (pop alist))))
373 (setcdr entry (cons (cons min max) (cdr entry)))))
374 (setq nnsoup-group-alist-touched t))
377 (defun nnsoup-write-active-file (&optional force)
378 (when (and nnsoup-group-alist
380 nnsoup-group-alist-touched))
381 (setq nnsoup-group-alist-touched nil)
382 (with-temp-file nnsoup-active-file
383 (gnus-prin1 `(setq nnsoup-group-alist ',nnsoup-group-alist))
385 (gnus-prin1 `(setq nnsoup-current-prefix ,nnsoup-current-prefix))
388 (defun nnsoup-next-prefix ()
389 "Return the next free prefix."
391 (while (or (file-exists-p
392 (nnsoup-file (setq prefix (int-to-string
393 nnsoup-current-prefix))))
394 (file-exists-p (nnsoup-file prefix t)))
395 (incf nnsoup-current-prefix))
396 (incf nnsoup-current-prefix)
399 (defun nnsoup-file-name (dir file)
400 "Return the full path of FILE (in any case) in DIR."
401 (let* ((case-fold-search t)
402 (files (directory-files dir t))
403 (regexp (concat (regexp-quote file) "$")))
407 (if (string-match regexp file)
412 (defun nnsoup-read-areas ()
413 (let ((areas-file (nnsoup-file-name nnsoup-tmp-directory "areas")))
416 (set-buffer nntp-server-buffer)
417 (let ((areas (gnus-soup-parse-areas areas-file))
418 entry number area lnum cur-prefix file)
419 ;; Go through all areas in the new AREAS file.
420 (while (setq area (pop areas))
421 ;; Change the name to the permanent name and move the files.
422 (setq cur-prefix (nnsoup-next-prefix))
423 (nnheader-message 5 "Incorporating file %s..." cur-prefix)
425 (setq file (concat nnsoup-tmp-directory
426 (gnus-soup-area-prefix area) ".IDX")))
427 (rename-file file (nnsoup-file cur-prefix)))
429 (setq file (concat nnsoup-tmp-directory
430 (gnus-soup-area-prefix area) ".MSG")))
431 (rename-file file (nnsoup-file cur-prefix t))
432 (gnus-soup-set-area-prefix area cur-prefix)
433 ;; Find the number of new articles in this area.
434 (setq number (nnsoup-number-of-articles area))
435 (if (not (setq entry (assoc (gnus-soup-area-name area)
436 nnsoup-group-alist)))
437 ;; If this is a new area (group), we just add this info to
439 (push (list (gnus-soup-area-name area)
441 (list (cons 1 number) area))
443 ;; There are already articles in this group, so we add this
444 ;; info to the end of the entry.
445 (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
448 (setcdr (cadr entry) (+ lnum number))))))
449 (nnsoup-write-active-file t)
450 (delete-file areas-file)))))
452 (defun nnsoup-number-of-articles (area)
455 ;; If the number is in the area info, we just return it.
456 ((gnus-soup-area-number area)
457 (gnus-soup-area-number area))
458 ;; If there is an index file, we just count the lines.
459 ((/= (gnus-soup-encoding-index (gnus-soup-area-encoding area)) ?n)
460 (set-buffer (nnsoup-index-buffer (gnus-soup-area-prefix area)))
461 (count-lines (point-min) (point-max)))
462 ;; We do it the hard way - re-searching through the message
465 (set-buffer (nnsoup-message-buffer (gnus-soup-area-prefix area)))
466 (unless (assoc (gnus-soup-area-prefix area) nnsoup-article-alist)
467 (nnsoup-dissect-buffer area))
468 (length (cdr (assoc (gnus-soup-area-prefix area)
469 nnsoup-article-alist)))))))
471 (defun nnsoup-dissect-buffer (area)
472 (let ((mbox-delim (concat "^" message-unix-mail-delimiter))
473 (format (gnus-soup-encoding-format (gnus-soup-area-encoding area)))
476 (goto-char (point-min))
478 ;; rnews batch format
480 (while (looking-at "^#! *rnews \\(+[0-9]+\\) *$")
485 (forward-char (string-to-number (match-string 1)))
490 (while (looking-at mbox-delim)
495 (if (re-search-forward mbox-delim nil t)
497 (goto-char (point-max)))
502 (while (looking-at "\^A\^A\^A\^A\n")
507 (if (search-forward "\n\^A\^A\^A\^A\n" nil t)
509 (goto-char (point-max)))
513 ((or (= format ?B) (= format ?b))
515 (setq len (+ (* (char-after (point)) (expt 2.0 24))
516 (* (char-after (+ (point) 1)) (expt 2 16))
517 (* (char-after (+ (point) 2)) (expt 2 8))
518 (char-after (+ (point) 3))))
520 (incf i) (+ (point) 4)
522 (forward-char (floor (+ len 4)))
526 (error "Unknown format: %c" format)))
527 (push (cons (gnus-soup-area-prefix area) alist) nnsoup-article-alist)))
529 (defun nnsoup-index-buffer (prefix &optional message)
530 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
531 (buffer-name (concat " *nnsoup " file "*")))
532 (or (get-buffer buffer-name) ; File already loaded.
533 (when (file-exists-p (concat nnsoup-directory file))
534 (save-excursion ; Load the file.
535 (set-buffer (get-buffer-create buffer-name))
536 (buffer-disable-undo)
537 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
538 (nnheader-insert-file-contents (concat nnsoup-directory file))
539 (current-buffer))))))
541 (defun nnsoup-file (prefix &optional message)
543 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
545 (defun nnsoup-message-buffer (prefix)
546 (nnsoup-index-buffer prefix 'msg))
548 (defun nnsoup-unpack-packets ()
549 "Unpack all packets in `nnsoup-packet-directory'."
550 (let ((packets (directory-files
551 nnsoup-packet-directory t nnsoup-packet-regexp))
553 (while (setq packet (pop packets))
554 (nnheader-message 5 "nnsoup: unpacking %s..." packet)
555 (if (not (gnus-soup-unpack-packet
556 nnsoup-tmp-directory nnsoup-unpacker packet))
557 (nnheader-message 5 "Couldn't unpack %s" packet)
560 (nnheader-message 5 "Unpacking...done")))))
562 (defun nnsoup-narrow-to-article (article &optional area head)
563 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
564 (prefix (and area (gnus-soup-area-prefix (nth 1 area))))
565 (msg-buf (and prefix (nnsoup-index-buffer prefix 'msg)))
570 ;; There is no MSG file.
573 ;; We use the index file to find out where the article
575 ((and (= (gnus-soup-encoding-index
576 (gnus-soup-area-encoding (nth 1 area)))
578 (file-exists-p (nnsoup-file prefix)))
579 (set-buffer (nnsoup-index-buffer prefix))
581 (goto-char (point-min))
582 (forward-line (- article (caar area)))
583 (setq beg (read (current-buffer)))
585 (if (looking-at "[0-9]+")
587 (setq end (read (current-buffer)))
590 (let ((format (gnus-soup-encoding-format
591 (gnus-soup-area-encoding (nth 1 area)))))
593 (when (or (= format ?n) (= format ?m))
594 (setq end (progn (forward-line -1) (point))))))
595 (set-buffer msg-buf))
597 (narrow-to-region beg (or end (point-max))))
601 (unless (assoc (gnus-soup-area-prefix (nth 1 area))
602 nnsoup-article-alist)
603 (nnsoup-dissect-buffer (nth 1 area)))
604 (let ((entry (assq article (cdr (assoc (gnus-soup-area-prefix
606 nnsoup-article-alist)))))
608 (narrow-to-region (cadr entry) (caddr entry))))))
609 (goto-char (point-min))
614 (if (search-forward "\n\n" nil t)
620 (defun nnsoup-pack-replies ()
621 "Make an outbound package of SOUP replies."
623 (unless (file-exists-p nnsoup-replies-directory)
624 (nnheader-message 5 "No such directory: %s" nnsoup-replies-directory))
625 ;; Write all data buffers.
626 (gnus-soup-save-areas)
627 ;; Write the active file.
628 (nnsoup-write-active-file)
629 ;; Write the REPLIES file.
630 (nnsoup-write-replies)
631 ;; Check whether there is anything here.
632 (when (null (directory-files nnsoup-replies-directory nil "\\.MSG$"))
633 (error "No files to pack"))
634 ;; Pack all these files into a SOUP packet.
635 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
637 (defun nnsoup-write-replies ()
638 "Write the REPLIES file."
639 (when nnsoup-replies-list
640 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
641 (setq nnsoup-replies-list nil)))
643 (defun nnsoup-article-to-area (article group)
644 "Return the area that ARTICLE in GROUP is located in."
645 (let ((areas (cddr (assoc group nnsoup-group-alist))))
646 (while (and areas (< (cdaar areas) article))
647 (setq areas (cdr areas)))
648 (and areas (car areas))))
650 (defvar nnsoup-old-functions
651 (list message-send-mail-function message-send-news-function))
654 (defun nnsoup-set-variables ()
655 "Use the SOUP methods for posting news and mailing mail."
657 (setq message-send-news-function 'nnsoup-request-post)
658 (setq message-send-mail-function 'nnsoup-request-mail))
661 (defun nnsoup-revert-variables ()
662 "Revert posting and mailing methods to the standard Emacs methods."
664 (setq message-send-mail-function (car nnsoup-old-functions))
665 (setq message-send-news-function (cadr nnsoup-old-functions)))
667 (defun nnsoup-store-reply (kind)
668 ;; Mostly stolen from `message.el'.
669 (require 'mail-utils)
670 (let ((tembuf (generate-new-buffer " message temp"))
671 (case-fold-search nil)
673 (mailbuf (current-buffer)))
677 (message-narrow-to-headers)
678 (if (equal kind "mail")
679 (message-generate-headers message-required-mail-headers)
680 (message-generate-headers message-required-news-headers)))
683 (insert-buffer-substring mailbuf)
684 ;; Remove some headers.
686 (message-narrow-to-headers)
687 ;; Remove some headers.
688 (message-remove-header message-ignored-mail-headers t))
689 (goto-char (point-max))
690 ;; require one newline at the end.
691 (or (= (preceding-char) ?\n)
693 (let ((case-fold-search t))
694 ;; Change header-delimiter to be what sendmail expects.
695 (goto-char (point-min))
697 (concat "^" (regexp-quote mail-header-separator) "\n"))
700 (setq delimline (point-marker))
701 (goto-char (1+ delimline))
704 nnsoup-replies-directory
705 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
706 nnsoup-replies-index-type))
708 (when (and msg-buf (bufferp msg-buf))
711 (goto-char (point-min))
712 (while (re-search-forward "^#! *rnews" nil t)
714 (when nnsoup-always-save
716 (nnheader-message 5 "Stored %d messages" num)))
717 (nnsoup-write-replies)
718 (kill-buffer tembuf))))))
720 (defun nnsoup-kind-to-prefix (kind)
721 (unless nnsoup-replies-list
722 (setq nnsoup-replies-list
723 (gnus-soup-parse-replies
724 (concat nnsoup-replies-directory "REPLIES"))))
725 (let ((replies nnsoup-replies-list))
727 (not (string= kind (gnus-soup-reply-kind (car replies)))))
728 (setq replies (cdr replies)))
730 (gnus-soup-reply-prefix (car replies))
731 (push (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
734 nnsoup-replies-format-type
735 nnsoup-replies-index-type
736 (if (string= kind "news")
739 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
741 (defun nnsoup-make-active ()
742 "(Re-)create the SOUP active file."
744 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
746 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
747 (string-to-int (match-string 1 f1)))
748 (progn (string-match "/\\([0-9]+\\)\\." f2)
749 (string-to-int (match-string 1 f2)))))))
750 active group lines ident elem min)
751 (set-buffer (get-buffer-create " *nnsoup work*"))
753 (nnheader-message 5 "Doing %s..." (car files))
755 (nnheader-insert-file-contents (car files))
756 (goto-char (point-min))
757 (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))
758 (setq group "unknown")
759 (setq group (match-string 2)))
760 (setq lines (count-lines (point-min) (point-max)))
761 (setq ident (progn (string-match
762 "/\\([0-9]+\\)\\." (car files))
764 (car files) (match-beginning 1)
766 (if (not (setq elem (assoc group active)))
767 (push (list group (cons 1 lines)
769 (vector ident group "ncm" "" lines)))
773 (list (cons (1+ (setq min (cdadr elem)))
775 (vector ident group "ncm" "" lines))))
776 (setcdr (cadr elem) (+ min lines)))
777 (setq files (cdr files)))
778 (nnheader-message 5 "")
779 (setq nnsoup-group-alist active)
780 (nnsoup-write-active-file t)))
782 (defun nnsoup-delete-unreferenced-message-files ()
783 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
785 (let* ((known (apply 'nconc (mapcar
789 (gnus-soup-area-prefix (cadr area)))
791 nnsoup-group-alist)))
792 (regexp "\\.MSG$\\|\\.IDX$")
793 (files (directory-files nnsoup-directory nil regexp))
795 ;; Find all files that aren't known by nnsoup.
796 (while (setq file (pop files))
797 (string-match regexp file)
798 (unless (member (substring file 0 (match-beginning 0)) known)
799 (push file non-files)))
800 ;; Sort and delete the files.
801 (setq non-files (sort non-files 'string<))
802 (map-y-or-n-p "Delete file %s? "
803 (lambda (file) (delete-file (concat nnsoup-directory file)))
808 ;;; nnsoup.el ends here