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.
29 (eval-when-compile (require 'cl))
39 (defvoo nnsoup-directory "~/SOUP/"
40 "*SOUP packet directory.")
42 (defvoo nnsoup-tmp-directory
43 (cond ((fboundp 'temp-directory) (temp-directory))
44 ((boundp 'temporary-file-directory) temporary-file-directory)
46 "*Where nnsoup will store temporary files.")
48 (defvoo nnsoup-replies-directory (concat nnsoup-directory "replies/")
49 "*Directory where outgoing packets will be composed.")
51 (defvoo nnsoup-replies-format-type ?u ;; u is USENET news format.
52 "*Format of the replies packages.")
54 (defvoo nnsoup-replies-index-type ?n
55 "*Index type of the replies packages.")
57 (defvoo nnsoup-active-file (concat nnsoup-directory "active")
60 (defvoo nnsoup-packer "tar cf - %s | gzip > $HOME/Soupin%d.tgz"
61 "Format string command for packing a SOUP packet.
62 The SOUP files will be inserted where the %s is in the string.
63 This string MUST contain both %s and %d. The file number will be
64 inserted where %d appears.")
66 (defvoo nnsoup-unpacker "gunzip -c %s | tar xvf -"
67 "*Format string command for unpacking a SOUP packet.
68 The SOUP packet file name will be inserted at the %s.")
70 (defvoo nnsoup-packet-directory "~/"
71 "*Where nnsoup will look for incoming packets.")
73 (defvoo nnsoup-packet-regexp "Soupout"
74 "*Regular expression matching SOUP packets in `nnsoup-packet-directory'.")
76 (defvoo nnsoup-always-save t
77 "If non nil commit the reply buffer on each message send.
78 This is necessary if using message mode outside Gnus with nnsoup as a
79 backend for the messages.")
83 (defconst nnsoup-version "nnsoup 0.0"
86 (defvoo nnsoup-status-string "")
87 (defvoo nnsoup-group-alist nil)
88 (defvoo nnsoup-current-prefix 0)
89 (defvoo nnsoup-replies-list nil)
90 (defvoo nnsoup-buffers nil)
91 (defvoo nnsoup-current-group nil)
92 (defvoo nnsoup-group-alist-touched nil)
93 (defvoo nnsoup-article-alist nil)
96 ;;; Interface functions.
98 (nnoo-define-basics nnsoup)
100 (deffoo nnsoup-retrieve-headers (sequence &optional group server fetch-old)
101 (nnsoup-possibly-change-group group)
103 (set-buffer nntp-server-buffer)
105 (let ((areas (cddr (assoc nnsoup-current-group nnsoup-group-alist)))
108 useful-areas this-area-seq msg-buf)
109 (if (stringp (car sequence))
110 ;; We don't support fetching by Message-ID.
112 ;; We go through all the areas and find which files the
113 ;; articles in SEQUENCE come from.
114 (while (and areas sequence)
115 ;; Peel off areas that are below sequence.
116 (while (and areas (< (cdaar areas) (car sequence)))
117 (setq areas (cdr areas)))
119 ;; This is a useful area.
120 (push (car areas) useful-areas)
121 (setq this-area-seq nil)
122 ;; We take note whether this MSG has a corresponding IDX
124 (when (or (= (gnus-soup-encoding-index
125 (gnus-soup-area-encoding (nth 1 (car areas)))) ?n)
128 (gnus-soup-area-prefix (nth 1 (car areas)))))))
130 ;; We assign the portion of `sequence' that is relevant to
131 ;; this MSG packet to this packet.
132 (while (and sequence (<= (car sequence) (cdaar areas)))
133 (push (car sequence) this-area-seq)
134 (setq sequence (cdr sequence)))
135 (setcar useful-areas (cons (nreverse this-area-seq)
136 (car useful-areas)))))
138 ;; We now have a list of article numbers and corresponding
140 (setq useful-areas (nreverse useful-areas))
142 ;; Two different approaches depending on whether all the MSG
143 ;; files have corresponding IDX files. If they all do, we
144 ;; simply return the relevant IDX files and let Gnus sort out
145 ;; what lines are relevant. If some of the IDX files are
146 ;; missing, we must return HEADs for all the articles.
148 ;; We have IDX files for all areas.
151 (goto-char (point-max))
153 (number (car (nth 1 (car useful-areas))))
154 (index-buffer (nnsoup-index-buffer
155 (gnus-soup-area-prefix
156 (nth 2 (car useful-areas))))))
158 (insert-buffer-substring index-buffer)
160 ;; We have to remove the index number entires and
161 ;; insert article numbers instead.
162 (while (looking-at "[0-9]+")
163 (replace-match (int-to-string number) t t)
166 (setq useful-areas (cdr useful-areas)))
170 (setq articles (caar useful-areas)
171 useful-areas (cdr useful-areas))
174 (nnsoup-narrow-to-article
175 (car articles) (cdar useful-areas) 'head))
176 (goto-char (point-max))
177 (insert (format "221 %d Article retrieved.\n" (car articles)))
178 (insert-buffer-substring msg-buf)
179 (goto-char (point-max))
181 (setq articles (cdr articles))))
183 (nnheader-fold-continuation-lines)
186 (deffoo nnsoup-open-server (server &optional defs)
187 (nnoo-change-server 'nnsoup server defs)
188 (when (not (file-exists-p nnsoup-directory))
190 (make-directory nnsoup-directory t)
193 ((not (file-exists-p nnsoup-directory))
194 (nnsoup-close-server)
195 (nnheader-report 'nnsoup "Couldn't create directory: %s" nnsoup-directory))
196 ((not (file-directory-p (file-truename nnsoup-directory)))
197 (nnsoup-close-server)
198 (nnheader-report 'nnsoup "Not a directory: %s" nnsoup-directory))
200 (nnsoup-read-active-file)
201 (nnheader-report 'nnsoup "Opened server %s using directory %s"
202 server nnsoup-directory)
205 (deffoo nnsoup-request-close ()
206 (nnsoup-write-active-file)
207 (nnsoup-write-replies)
208 (gnus-soup-save-areas)
209 ;; Kill all nnsoup buffers.
211 (while nnsoup-buffers
212 (setq buffer (cdr (pop nnsoup-buffers)))
215 (kill-buffer buffer))))
216 (setq nnsoup-group-alist nil
217 nnsoup-group-alist-touched nil
218 nnsoup-current-group nil
219 nnsoup-replies-list nil)
220 (nnoo-close-server 'nnoo)
223 (deffoo nnsoup-request-article (id &optional newsgroup server buffer)
224 (nnsoup-possibly-change-group newsgroup)
227 (set-buffer (or buffer nntp-server-buffer))
229 (when (and (not (stringp id))
230 (setq buf (nnsoup-narrow-to-article id)))
231 (insert-buffer-substring buf)
234 (deffoo nnsoup-request-group (group &optional server dont-check)
235 (nnsoup-possibly-change-group group)
238 (let ((active (cadr (assoc group nnsoup-group-alist))))
240 (nnheader-report 'nnsoup "No such group: %s" group)
243 (max (1+ (- (cdr active) (car active))) 0)
244 (car active) (cdr active) group)))))
246 (deffoo nnsoup-request-type (group &optional article)
247 (nnsoup-possibly-change-group group)
248 ;; Try to guess the type based on the first article in the group.
251 (cdaar (cddr (assoc group nnsoup-group-alist)))))
254 (let ((kind (gnus-soup-encoding-kind
255 (gnus-soup-area-encoding
256 (nth 1 (nnsoup-article-to-area
257 article nnsoup-current-group))))))
258 (cond ((= kind ?m) 'mail)
262 (deffoo nnsoup-close-group (group &optional server)
263 ;; Kill all nnsoup buffers.
264 (let ((buffers nnsoup-buffers)
267 (when (equal (car (setq elem (pop buffers))) group)
268 (setq nnsoup-buffers (delq elem nnsoup-buffers))
269 (and (cdr elem) (buffer-name (cdr elem))
270 (kill-buffer (cdr elem))))))
273 (deffoo nnsoup-request-list (&optional server)
275 (set-buffer nntp-server-buffer)
277 (unless nnsoup-group-alist
278 (nnsoup-read-active-file))
279 (let ((alist nnsoup-group-alist)
280 (standard-output (current-buffer))
282 (while (setq entry (pop alist))
283 (insert (car entry) " ")
284 (princ (cdadr entry))
286 (princ (caadr entry))
290 (deffoo nnsoup-request-scan (group &optional server)
291 (nnsoup-unpack-packets))
293 (deffoo nnsoup-request-newgroups (date &optional server)
294 (nnsoup-request-list))
296 (deffoo nnsoup-request-list-newsgroups (&optional server)
299 (deffoo nnsoup-request-post (&optional server)
300 (nnsoup-store-reply "news")
303 (deffoo nnsoup-request-mail (&optional server)
304 (nnsoup-store-reply "mail")
307 (deffoo nnsoup-request-expire-articles (articles group &optional server force)
308 (nnsoup-possibly-change-group group)
309 (let* ((total-infolist (assoc group nnsoup-group-alist))
310 (active (cadr total-infolist))
311 (infolist (cddr total-infolist))
312 info range-list mod-time prefix)
314 (setq info (pop infolist)
315 range-list (gnus-uncompress-range (car info))
316 prefix (gnus-soup-area-prefix (nth 1 info)))
317 (when;; All the articles in this file are marked for expiry.
318 (and (or (setq mod-time (nth 5 (file-attributes
319 (nnsoup-file prefix))))
320 (setq mod-time (nth 5 (file-attributes
321 (nnsoup-file prefix t)))))
322 (gnus-sublist-p articles range-list)
323 ;; This file is old enough.
324 (nnmail-expired-article-p group mod-time force))
325 ;; Ok, we delete this file.
328 5 "Deleting %s in group %s..." (nnsoup-file prefix)
330 (when (file-exists-p (nnsoup-file prefix))
331 (delete-file (nnsoup-file prefix)))
333 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
335 (when (file-exists-p (nnsoup-file prefix t))
336 (delete-file (nnsoup-file prefix t)))
338 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
339 (setq articles (gnus-sorted-complement articles range-list))))
341 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
342 (if (cddr total-infolist)
343 (setcar active (caaadr (cdr total-infolist)))
344 (setcar active (1+ (cdr active))))
345 (nnsoup-write-active-file t)
346 ;; Return the articles that weren't expired.
350 ;;; Internal functions
352 (defun nnsoup-possibly-change-group (group &optional force)
354 (not (equal nnsoup-current-group group)))
355 (setq nnsoup-article-alist nil)
356 (setq nnsoup-current-group group))
359 (defun nnsoup-read-active-file ()
360 (setq nnsoup-group-alist nil)
361 (when (file-exists-p nnsoup-active-file)
363 (load nnsoup-active-file t t t))
364 ;; Be backwards compatible.
365 (when (and nnsoup-group-alist
366 (not (atom (caadar nnsoup-group-alist))))
367 (let ((alist nnsoup-group-alist)
369 (while (setq e (cdr (setq entry (pop alist))))
374 (setcdr entry (cons (cons min max) (cdr entry)))))
375 (setq nnsoup-group-alist-touched t))
378 (defun nnsoup-write-active-file (&optional force)
379 (when (and nnsoup-group-alist
381 nnsoup-group-alist-touched))
382 (setq nnsoup-group-alist-touched nil)
383 (with-temp-file nnsoup-active-file
384 (gnus-prin1 `(setq nnsoup-group-alist ',nnsoup-group-alist))
386 (gnus-prin1 `(setq nnsoup-current-prefix ,nnsoup-current-prefix))
389 (defun nnsoup-next-prefix ()
390 "Return the next free prefix."
392 (while (or (file-exists-p
393 (nnsoup-file (setq prefix (int-to-string
394 nnsoup-current-prefix))))
395 (file-exists-p (nnsoup-file prefix t)))
396 (incf nnsoup-current-prefix))
397 (incf nnsoup-current-prefix)
400 (defun nnsoup-file-name (dir file)
401 "Return the full path of FILE (in any case) in DIR."
402 (let* ((case-fold-search t)
403 (files (directory-files dir t))
404 (regexp (concat (regexp-quote file) "$")))
408 (if (string-match regexp file)
413 (defun nnsoup-read-areas ()
414 (let ((areas-file (nnsoup-file-name nnsoup-tmp-directory "areas")))
417 (set-buffer nntp-server-buffer)
418 (let ((areas (gnus-soup-parse-areas areas-file))
419 entry number area lnum cur-prefix file)
420 ;; Go through all areas in the new AREAS file.
421 (while (setq area (pop areas))
422 ;; Change the name to the permanent name and move the files.
423 (setq cur-prefix (nnsoup-next-prefix))
424 (nnheader-message 5 "Incorporating file %s..." cur-prefix)
426 (setq file (concat nnsoup-tmp-directory
427 (gnus-soup-area-prefix area) ".IDX")))
428 (rename-file file (nnsoup-file cur-prefix)))
430 (setq file (concat nnsoup-tmp-directory
431 (gnus-soup-area-prefix area) ".MSG")))
432 (rename-file file (nnsoup-file cur-prefix t))
433 (gnus-soup-set-area-prefix area cur-prefix)
434 ;; Find the number of new articles in this area.
435 (setq number (nnsoup-number-of-articles area))
436 (if (not (setq entry (assoc (gnus-soup-area-name area)
437 nnsoup-group-alist)))
438 ;; If this is a new area (group), we just add this info to
440 (push (list (gnus-soup-area-name area)
442 (list (cons 1 number) area))
444 ;; There are already articles in this group, so we add this
445 ;; info to the end of the entry.
446 (nconc entry (list (list (cons (1+ (setq lnum (cdadr entry)))
449 (setcdr (cadr entry) (+ lnum number))))))
450 (nnsoup-write-active-file t)
451 (delete-file areas-file)))))
453 (defun nnsoup-number-of-articles (area)
456 ;; If the number is in the area info, we just return it.
457 ((gnus-soup-area-number area)
458 (gnus-soup-area-number area))
459 ;; If there is an index file, we just count the lines.
460 ((/= (gnus-soup-encoding-index (gnus-soup-area-encoding area)) ?n)
461 (set-buffer (nnsoup-index-buffer (gnus-soup-area-prefix area)))
462 (count-lines (point-min) (point-max)))
463 ;; We do it the hard way - re-searching through the message
466 (set-buffer (nnsoup-message-buffer (gnus-soup-area-prefix area)))
467 (unless (assoc (gnus-soup-area-prefix area) nnsoup-article-alist)
468 (nnsoup-dissect-buffer area))
469 (length (cdr (assoc (gnus-soup-area-prefix area)
470 nnsoup-article-alist)))))))
472 (defun nnsoup-dissect-buffer (area)
473 (let ((mbox-delim (concat "^" message-unix-mail-delimiter))
474 (format (gnus-soup-encoding-format (gnus-soup-area-encoding area)))
477 (goto-char (point-min))
479 ;; rnews batch format
481 (= format ?n)) ;; Gnus back compatibility.
482 (while (looking-at "^#! *rnews \\(+[0-9]+\\) *$")
487 (forward-char (string-to-number (match-string 1)))
492 (while (looking-at mbox-delim)
497 (if (re-search-forward mbox-delim nil t)
499 (goto-char (point-max)))
504 (while (looking-at "\^A\^A\^A\^A\n")
509 (if (search-forward "\n\^A\^A\^A\^A\n" nil t)
511 (goto-char (point-max)))
515 ((or (= format ?B) (= format ?b))
517 (setq len (+ (* (char-after (point)) (expt 2.0 24))
518 (* (char-after (+ (point) 1)) (expt 2 16))
519 (* (char-after (+ (point) 2)) (expt 2 8))
520 (char-after (+ (point) 3))))
522 (incf i) (+ (point) 4)
524 (forward-char (floor (+ len 4)))
528 (error "Unknown format: %c" format)))
529 (push (cons (gnus-soup-area-prefix area) alist) nnsoup-article-alist)))
531 (defun nnsoup-index-buffer (prefix &optional message)
532 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
533 (buffer-name (concat " *nnsoup " file "*")))
534 (or (get-buffer buffer-name) ; File already loaded.
535 (when (file-exists-p (concat nnsoup-directory file))
536 (save-excursion ; Load the file.
537 (set-buffer (get-buffer-create buffer-name))
538 (buffer-disable-undo)
539 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
540 (nnheader-insert-file-contents (concat nnsoup-directory file))
541 (current-buffer))))))
543 (defun nnsoup-file (prefix &optional message)
545 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
547 (defun nnsoup-message-buffer (prefix)
548 (nnsoup-index-buffer prefix 'msg))
550 (defun nnsoup-unpack-packets ()
551 "Unpack all packets in `nnsoup-packet-directory'."
552 (let ((packets (directory-files
553 nnsoup-packet-directory t nnsoup-packet-regexp))
555 (while (setq packet (pop packets))
556 (nnheader-message 5 "nnsoup: unpacking %s..." packet)
557 (if (not (gnus-soup-unpack-packet
558 nnsoup-tmp-directory nnsoup-unpacker packet))
559 (nnheader-message 5 "Couldn't unpack %s" packet)
562 (nnheader-message 5 "Unpacking...done")))))
564 (defun nnsoup-narrow-to-article (article &optional area head)
565 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
566 (prefix (and area (gnus-soup-area-prefix (nth 1 area))))
567 (msg-buf (and prefix (nnsoup-index-buffer prefix 'msg)))
572 ;; There is no MSG file.
575 ;; We use the index file to find out where the article
577 ((and (= (gnus-soup-encoding-index
578 (gnus-soup-area-encoding (nth 1 area)))
580 (file-exists-p (nnsoup-file prefix)))
581 (set-buffer (nnsoup-index-buffer prefix))
583 (goto-char (point-min))
584 (forward-line (- article (caar area)))
585 (setq beg (read (current-buffer)))
587 (if (looking-at "[0-9]+")
589 (setq end (read (current-buffer)))
592 (let ((format (gnus-soup-encoding-format
593 (gnus-soup-area-encoding (nth 1 area)))))
595 (when (or (= format ?u) (= format ?n) (= format ?m))
596 (setq end (progn (forward-line -1) (point))))))
597 (set-buffer msg-buf))
599 (narrow-to-region beg (or end (point-max))))
603 (unless (assoc (gnus-soup-area-prefix (nth 1 area))
604 nnsoup-article-alist)
605 (nnsoup-dissect-buffer (nth 1 area)))
606 (let ((entry (assq article (cdr (assoc (gnus-soup-area-prefix
608 nnsoup-article-alist)))))
610 (narrow-to-region (cadr entry) (caddr entry))))))
611 (goto-char (point-min))
616 (if (search-forward "\n\n" nil t)
622 (defun nnsoup-pack-replies ()
623 "Make an outbound package of SOUP replies."
625 (unless (file-exists-p nnsoup-replies-directory)
626 (nnheader-message 5 "No such directory: %s" nnsoup-replies-directory))
627 ;; Write all data buffers.
628 (gnus-soup-save-areas)
629 ;; Write the active file.
630 (nnsoup-write-active-file)
631 ;; Write the REPLIES file.
632 (nnsoup-write-replies)
633 ;; Check whether there is anything here.
634 (when (null (directory-files nnsoup-replies-directory nil "\\.MSG$"))
635 (error "No files to pack"))
636 ;; Pack all these files into a SOUP packet.
637 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
639 (defun nnsoup-write-replies ()
640 "Write the REPLIES file."
641 (when nnsoup-replies-list
642 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
643 (setq nnsoup-replies-list nil)))
645 (defun nnsoup-article-to-area (article group)
646 "Return the area that ARTICLE in GROUP is located in."
647 (let ((areas (cddr (assoc group nnsoup-group-alist))))
648 (while (and areas (< (cdaar areas) article))
649 (setq areas (cdr areas)))
650 (and areas (car areas))))
652 (defvar nnsoup-old-functions
653 (list message-send-mail-function message-send-news-function))
656 (defun nnsoup-set-variables ()
657 "Use the SOUP methods for posting news and mailing mail."
659 (setq message-send-news-function 'nnsoup-request-post)
660 (setq message-send-mail-function 'nnsoup-request-mail))
663 (defun nnsoup-revert-variables ()
664 "Revert posting and mailing methods to the standard Emacs methods."
666 (setq message-send-mail-function (car nnsoup-old-functions))
667 (setq message-send-news-function (cadr nnsoup-old-functions)))
669 (defun nnsoup-store-reply (kind)
670 ;; Mostly stolen from `message.el'.
671 (require 'mail-utils)
672 (let ((tembuf (generate-new-buffer " message temp"))
673 (case-fold-search nil)
675 (mailbuf (current-buffer)))
679 (message-narrow-to-headers)
680 (if (equal kind "mail")
681 (message-generate-headers message-required-mail-headers)
682 (message-generate-headers message-required-news-headers)))
685 (insert-buffer-substring mailbuf)
686 ;; Remove some headers.
688 (message-narrow-to-headers)
689 ;; Remove some headers.
690 (message-remove-header message-ignored-mail-headers t))
691 (goto-char (point-max))
692 ;; require one newline at the end.
693 (or (= (preceding-char) ?\n)
695 (let ((case-fold-search t))
696 ;; Change header-delimiter to be what sendmail expects.
697 (goto-char (point-min))
699 (concat "^" (regexp-quote mail-header-separator) "\n"))
702 (setq delimline (point-marker))
703 (goto-char (1+ delimline))
706 nnsoup-replies-directory
707 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
708 nnsoup-replies-index-type))
710 (when (and msg-buf (bufferp msg-buf))
713 (goto-char (point-min))
714 (while (re-search-forward "^#! *rnews" nil t)
716 (when nnsoup-always-save
718 (nnheader-message 5 "Stored %d messages" num)))
719 (nnsoup-write-replies)
720 (kill-buffer tembuf))))))
722 (defun nnsoup-kind-to-prefix (kind)
723 (unless nnsoup-replies-list
724 (setq nnsoup-replies-list
725 (gnus-soup-parse-replies
726 (concat nnsoup-replies-directory "REPLIES"))))
727 (let ((replies nnsoup-replies-list))
729 (not (string= kind (gnus-soup-reply-kind (car replies)))))
730 (setq replies (cdr replies)))
732 (gnus-soup-reply-prefix (car replies))
733 (push (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
736 nnsoup-replies-format-type
737 nnsoup-replies-index-type
738 (if (string= kind "news")
741 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
743 (defun nnsoup-make-active ()
744 "(Re-)create the SOUP active file."
746 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
748 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
749 (string-to-int (match-string 1 f1)))
750 (progn (string-match "/\\([0-9]+\\)\\." f2)
751 (string-to-int (match-string 1 f2)))))))
752 active group lines ident elem min)
753 (set-buffer (get-buffer-create " *nnsoup work*"))
755 (nnheader-message 5 "Doing %s..." (car files))
757 (nnheader-insert-file-contents (car files))
758 (goto-char (point-min))
759 (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))
760 (setq group "unknown")
761 (setq group (match-string 2)))
762 (setq lines (count-lines (point-min) (point-max)))
763 (setq ident (progn (string-match
764 "/\\([0-9]+\\)\\." (car files))
766 (car files) (match-beginning 1)
768 (if (not (setq elem (assoc group active)))
769 (push (list group (cons 1 lines)
771 (vector ident group "ucm" "" lines)))
775 (list (cons (1+ (setq min (cdadr elem)))
777 (vector ident group "ucm" "" lines))))
778 (setcdr (cadr elem) (+ min lines)))
779 (setq files (cdr files)))
780 (nnheader-message 5 "")
781 (setq nnsoup-group-alist active)
782 (nnsoup-write-active-file t)))
784 (defun nnsoup-delete-unreferenced-message-files ()
785 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
787 (let* ((known (apply 'nconc (mapcar
791 (gnus-soup-area-prefix (cadr area)))
793 nnsoup-group-alist)))
794 (regexp "\\.MSG$\\|\\.IDX$")
795 (files (directory-files nnsoup-directory nil regexp))
797 ;; Find all files that aren't known by nnsoup.
798 (while (setq file (pop files))
799 (string-match regexp file)
800 (unless (member (substring file 0 (match-beginning 0)) known)
801 (push file non-files)))
802 ;; Sort and delete the files.
803 (setq non-files (sort non-files 'string<))
804 (map-y-or-n-p "Delete file %s? "
805 (lambda (file) (delete-file (concat nnsoup-directory file)))
810 ;;; nnsoup.el ends here