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 ?n
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 (while (looking-at "^#! *rnews \\(+[0-9]+\\) *$")
486 (forward-char (string-to-number (match-string 1)))
491 (while (looking-at mbox-delim)
496 (if (re-search-forward mbox-delim nil t)
498 (goto-char (point-max)))
503 (while (looking-at "\^A\^A\^A\^A\n")
508 (if (search-forward "\n\^A\^A\^A\^A\n" nil t)
510 (goto-char (point-max)))
514 ((or (= format ?B) (= format ?b))
516 (setq len (+ (* (char-after (point)) (expt 2.0 24))
517 (* (char-after (+ (point) 1)) (expt 2 16))
518 (* (char-after (+ (point) 2)) (expt 2 8))
519 (char-after (+ (point) 3))))
521 (incf i) (+ (point) 4)
523 (forward-char (floor (+ len 4)))
527 (error "Unknown format: %c" format)))
528 (push (cons (gnus-soup-area-prefix area) alist) nnsoup-article-alist)))
530 (defun nnsoup-index-buffer (prefix &optional message)
531 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
532 (buffer-name (concat " *nnsoup " file "*")))
533 (or (get-buffer buffer-name) ; File already loaded.
534 (when (file-exists-p (concat nnsoup-directory file))
535 (save-excursion ; Load the file.
536 (set-buffer (get-buffer-create buffer-name))
537 (buffer-disable-undo)
538 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
539 (nnheader-insert-file-contents (concat nnsoup-directory file))
540 (current-buffer))))))
542 (defun nnsoup-file (prefix &optional message)
544 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
546 (defun nnsoup-message-buffer (prefix)
547 (nnsoup-index-buffer prefix 'msg))
549 (defun nnsoup-unpack-packets ()
550 "Unpack all packets in `nnsoup-packet-directory'."
551 (let ((packets (directory-files
552 nnsoup-packet-directory t nnsoup-packet-regexp))
554 (while (setq packet (pop packets))
555 (nnheader-message 5 "nnsoup: unpacking %s..." packet)
556 (if (not (gnus-soup-unpack-packet
557 nnsoup-tmp-directory nnsoup-unpacker packet))
558 (nnheader-message 5 "Couldn't unpack %s" packet)
561 (nnheader-message 5 "Unpacking...done")))))
563 (defun nnsoup-narrow-to-article (article &optional area head)
564 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
565 (prefix (and area (gnus-soup-area-prefix (nth 1 area))))
566 (msg-buf (and prefix (nnsoup-index-buffer prefix 'msg)))
571 ;; There is no MSG file.
574 ;; We use the index file to find out where the article
576 ((and (= (gnus-soup-encoding-index
577 (gnus-soup-area-encoding (nth 1 area)))
579 (file-exists-p (nnsoup-file prefix)))
580 (set-buffer (nnsoup-index-buffer prefix))
582 (goto-char (point-min))
583 (forward-line (- article (caar area)))
584 (setq beg (read (current-buffer)))
586 (if (looking-at "[0-9]+")
588 (setq end (read (current-buffer)))
591 (let ((format (gnus-soup-encoding-format
592 (gnus-soup-area-encoding (nth 1 area)))))
594 (when (or (= format ?n) (= format ?m))
595 (setq end (progn (forward-line -1) (point))))))
596 (set-buffer msg-buf))
598 (narrow-to-region beg (or end (point-max))))
602 (unless (assoc (gnus-soup-area-prefix (nth 1 area))
603 nnsoup-article-alist)
604 (nnsoup-dissect-buffer (nth 1 area)))
605 (let ((entry (assq article (cdr (assoc (gnus-soup-area-prefix
607 nnsoup-article-alist)))))
609 (narrow-to-region (cadr entry) (caddr entry))))))
610 (goto-char (point-min))
615 (if (search-forward "\n\n" nil t)
621 (defun nnsoup-pack-replies ()
622 "Make an outbound package of SOUP replies."
624 (unless (file-exists-p nnsoup-replies-directory)
625 (nnheader-message 5 "No such directory: %s" nnsoup-replies-directory))
626 ;; Write all data buffers.
627 (gnus-soup-save-areas)
628 ;; Write the active file.
629 (nnsoup-write-active-file)
630 ;; Write the REPLIES file.
631 (nnsoup-write-replies)
632 ;; Check whether there is anything here.
633 (when (null (directory-files nnsoup-replies-directory nil "\\.MSG$"))
634 (error "No files to pack"))
635 ;; Pack all these files into a SOUP packet.
636 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
638 (defun nnsoup-write-replies ()
639 "Write the REPLIES file."
640 (when nnsoup-replies-list
641 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
642 (setq nnsoup-replies-list nil)))
644 (defun nnsoup-article-to-area (article group)
645 "Return the area that ARTICLE in GROUP is located in."
646 (let ((areas (cddr (assoc group nnsoup-group-alist))))
647 (while (and areas (< (cdaar areas) article))
648 (setq areas (cdr areas)))
649 (and areas (car areas))))
651 (defvar nnsoup-old-functions
652 (list message-send-mail-function message-send-news-function))
655 (defun nnsoup-set-variables ()
656 "Use the SOUP methods for posting news and mailing mail."
658 (setq message-send-news-function 'nnsoup-request-post)
659 (setq message-send-mail-function 'nnsoup-request-mail))
662 (defun nnsoup-revert-variables ()
663 "Revert posting and mailing methods to the standard Emacs methods."
665 (setq message-send-mail-function (car nnsoup-old-functions))
666 (setq message-send-news-function (cadr nnsoup-old-functions)))
668 (defun nnsoup-store-reply (kind)
669 ;; Mostly stolen from `message.el'.
670 (require 'mail-utils)
671 (let ((tembuf (generate-new-buffer " message temp"))
672 (case-fold-search nil)
674 (mailbuf (current-buffer)))
678 (message-narrow-to-headers)
679 (if (equal kind "mail")
680 (message-generate-headers message-required-mail-headers)
681 (message-generate-headers message-required-news-headers)))
684 (insert-buffer-substring mailbuf)
685 ;; Remove some headers.
687 (message-narrow-to-headers)
688 ;; Remove some headers.
689 (message-remove-header message-ignored-mail-headers t))
690 (goto-char (point-max))
691 ;; require one newline at the end.
692 (or (= (preceding-char) ?\n)
694 (let ((case-fold-search t))
695 ;; Change header-delimiter to be what sendmail expects.
696 (goto-char (point-min))
698 (concat "^" (regexp-quote mail-header-separator) "\n"))
701 (setq delimline (point-marker))
702 (goto-char (1+ delimline))
705 nnsoup-replies-directory
706 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
707 nnsoup-replies-index-type))
709 (when (and msg-buf (bufferp msg-buf))
712 (goto-char (point-min))
713 (while (re-search-forward "^#! *rnews" nil t)
715 (when nnsoup-always-save
717 (nnheader-message 5 "Stored %d messages" num)))
718 (nnsoup-write-replies)
719 (kill-buffer tembuf))))))
721 (defun nnsoup-kind-to-prefix (kind)
722 (unless nnsoup-replies-list
723 (setq nnsoup-replies-list
724 (gnus-soup-parse-replies
725 (concat nnsoup-replies-directory "REPLIES"))))
726 (let ((replies nnsoup-replies-list))
728 (not (string= kind (gnus-soup-reply-kind (car replies)))))
729 (setq replies (cdr replies)))
731 (gnus-soup-reply-prefix (car replies))
732 (push (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
735 nnsoup-replies-format-type
736 nnsoup-replies-index-type
737 (if (string= kind "news")
740 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
742 (defun nnsoup-make-active ()
743 "(Re-)create the SOUP active file."
745 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
747 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
748 (string-to-int (match-string 1 f1)))
749 (progn (string-match "/\\([0-9]+\\)\\." f2)
750 (string-to-int (match-string 1 f2)))))))
751 active group lines ident elem min)
752 (set-buffer (get-buffer-create " *nnsoup work*"))
754 (nnheader-message 5 "Doing %s..." (car files))
756 (nnheader-insert-file-contents (car files))
757 (goto-char (point-min))
758 (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))
759 (setq group "unknown")
760 (setq group (match-string 2)))
761 (setq lines (count-lines (point-min) (point-max)))
762 (setq ident (progn (string-match
763 "/\\([0-9]+\\)\\." (car files))
765 (car files) (match-beginning 1)
767 (if (not (setq elem (assoc group active)))
768 (push (list group (cons 1 lines)
770 (vector ident group "ncm" "" lines)))
774 (list (cons (1+ (setq min (cdadr elem)))
776 (vector ident group "ncm" "" lines))))
777 (setcdr (cadr elem) (+ min lines)))
778 (setq files (cdr files)))
779 (nnheader-message 5 "")
780 (setq nnsoup-group-alist active)
781 (nnsoup-write-active-file t)))
783 (defun nnsoup-delete-unreferenced-message-files ()
784 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
786 (let* ((known (apply 'nconc (mapcar
790 (gnus-soup-area-prefix (cadr area)))
792 nnsoup-group-alist)))
793 (regexp "\\.MSG$\\|\\.IDX$")
794 (files (directory-files nnsoup-directory nil regexp))
796 ;; Find all files that aren't known by nnsoup.
797 (while (setq file (pop files))
798 (string-match regexp file)
799 (unless (member (substring file 0 (match-beginning 0)) known)
800 (push file non-files)))
801 ;; Sort and delete the files.
802 (setq non-files (sort non-files 'string<))
803 (map-y-or-n-p "Delete file %s? "
804 (lambda (file) (delete-file (concat nnsoup-directory file)))
809 ;;; nnsoup.el ends here