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)
85 (defvar nnsoup-current-server nil)
86 (defvar nnsoup-server-alist nil)
87 (defvar nnsoup-server-variables
88 `((nnsoup-directory ,nnsoup-directory)
89 (nnsoup-active-file ,nnsoup-active-file)
90 (nnsoup-status-string "")
91 (nnsoup-current-prefix 0)
92 (nnsoup-current-group nil)
94 (nnsoup-replies-list nil)
95 (nnsoup-packet-regexp ,nnsoup-packet-regexp)
96 (nnsoup-packet-directory ,nnsoup-packet-directory)
97 (nnsoup-unpacker ,nnsoup-unpacker)
98 (nnsoup-packer ,nnsoup-packer)
99 (nnsoup-replies-index-type ,nnsoup-replies-index-type)
100 (nnsoup-replies-format-type ,nnsoup-replies-format-type)
101 (nnsoup-replies-directory ,nnsoup-replies-directory)
102 (nnsoup-tmp-directory ,nnsoup-tmp-directory)
103 (nnsoup-group-alist nil)))
107 ;;; Interface functions.
109 (defun nnsoup-retrieve-headers (sequence &optional group server fetch-old)
110 (nnsoup-possibly-change-group group)
112 (set-buffer nntp-server-buffer)
114 (let ((areas (cddr (assoc nnsoup-current-group nnsoup-group-alist)))
117 useful-areas this-area-seq msg-buf)
118 (if (stringp (car sequence))
119 ;; We don't support fetching by Message-ID.
121 ;; We go through all the areas and find which files the
122 ;; articles in SEQUENCE come from.
123 (while (and areas sequence)
124 ;; Peel off areas that are below sequence.
125 (while (and areas (< (cdaar areas) (car sequence)))
126 (setq areas (cdr areas)))
128 ;; This is a useful area.
129 (push (car areas) useful-areas)
130 (setq this-area-seq nil)
131 ;; We take note whether this MSG has a corresponding IDX
133 (when (or (= (gnus-soup-encoding-index
134 (gnus-soup-area-encoding (nth 1 (car areas)))) ?n)
137 (gnus-soup-area-prefix (nth 1 (car areas)))))))
139 ;; We assign the portion of `sequence' that is relevant to
140 ;; this MSG packet to this packet.
141 (while (and sequence (<= (car sequence) (cdaar areas)))
142 (push (car sequence) this-area-seq)
143 (setq sequence (cdr sequence)))
144 (setcar useful-areas (cons (nreverse this-area-seq)
145 (car useful-areas)))))
147 ;; We now have a list of article numbers and corresponding
149 (setq useful-areas (nreverse useful-areas))
151 ;; Two different approaches depending on whether all the MSG
152 ;; files have corresponding IDX files. If they all do, we
153 ;; simply return the relevant IDX files and let Gnus sort out
154 ;; what lines are relevant. If some of the IDX files are
155 ;; missing, we must return HEADs for all the articles.
157 ;; We have IDX files for all areas.
160 (goto-char (point-max))
162 (number (car (nth 1 (car useful-areas))))
163 (index-buffer (nnsoup-index-buffer
164 (gnus-soup-area-prefix
165 (nth 2 (car useful-areas))))))
167 (insert-buffer-substring index-buffer)
169 ;; We have to remove the index number entires and
170 ;; insert article numbers instead.
171 (while (looking-at "[0-9]+")
172 (replace-match (int-to-string number) t t)
175 (setq useful-areas (cdr useful-areas)))
179 (setq articles (caar useful-areas)
180 useful-areas (cdr useful-areas))
183 (nnsoup-narrow-to-article
184 (car articles) (cdar useful-areas) 'head))
185 (goto-char (point-max))
186 (insert (format "221 %d Article retrieved.\n" (car articles)))
187 (insert-buffer-substring msg-buf)
188 (goto-char (point-max))
190 (setq articles (cdr articles))))
192 (nnheader-fold-continuation-lines)
195 (defun nnsoup-open-server (server &optional defs)
196 (nnheader-change-server 'nnsoup server defs)
197 (when (not (file-exists-p nnsoup-directory))
199 (make-directory nnsoup-directory t)
202 ((not (file-exists-p nnsoup-directory))
203 (nnsoup-close-server)
204 (nnheader-report 'nnsoup "Couldn't create directory: %s" nnsoup-directory))
205 ((not (file-directory-p (file-truename nnsoup-directory)))
206 (nnsoup-close-server)
207 (nnheader-report 'nnsoup "Not a directory: %s" nnsoup-directory))
209 (nnsoup-read-active-file)
210 (nnheader-report 'nnsoup "Opened server %s using directory %s"
211 server nnsoup-directory)
214 (defun nnsoup-close-server (&optional server)
215 (setq nnsoup-current-server nil
216 nnsoup-group-alist nil)
219 (defun nnsoup-request-close ()
220 (nnsoup-write-active-file)
221 (nnsoup-write-replies)
222 (gnus-soup-save-areas)
223 ;; Kill all nnsoup buffers.
225 (while nnsoup-buffers
226 (setq buffer (cdr (pop nnsoup-buffers)))
229 (kill-buffer buffer))))
230 (setq nnsoup-group-alist nil
231 nnsoup-current-group nil
232 nnsoup-current-server nil
233 nnsoup-server-alist nil
234 nnsoup-replies-list nil)
237 (defun nnsoup-server-opened (&optional server)
238 (and (equal server nnsoup-current-server)
240 (buffer-name nntp-server-buffer)))
242 (defun nnsoup-status-message (&optional server)
243 nnsoup-status-string)
245 (defun nnsoup-request-article (id &optional newsgroup server buffer)
246 (nnsoup-possibly-change-group newsgroup)
247 (let ((buffer (or buffer nntp-server-buffer)))
253 (insert-buffer-substring
254 (nnsoup-narrow-to-article id))
257 (defun nnsoup-request-group (group &optional server dont-check)
258 (nnsoup-possibly-change-group group)
261 (let ((active (cadr (assoc group nnsoup-group-alist))))
263 (nnheader-report 'nnsoup "No such group: %s" group)
266 (max (1+ (- (cdr active) (car active))) 0)
267 (car active) (cdr active) group)))))
269 (defun nnsoup-request-type (group &optional article)
270 (nnsoup-possibly-change-group group)
273 (let ((kind (gnus-soup-encoding-kind
274 (gnus-soup-area-encoding
275 (nth 1 (nnsoup-article-to-area
276 article nnsoup-current-group))))))
277 (cond ((= kind ?m) 'mail)
281 (defun nnsoup-close-group (group &optional server)
282 ;; Kill all nnsoup buffers.
283 (let ((buffers nnsoup-buffers)
286 (when (equal (car (setq elem (pop buffers))) group)
287 (setq nnsoup-buffers (delq elem nnsoup-buffers))
288 (and (cdr elem) (buffer-name (cdr elem))
289 (kill-buffer (cdr elem))))))
292 (defun nnsoup-request-list (&optional server)
294 (set-buffer nntp-server-buffer)
296 (let ((alist nnsoup-group-alist)
298 (while (setq entry (pop alist))
299 (insert (format "%s %d %d y\n" (car entry)
300 (cdadr entry) (caadr entry))))
303 (defun nnsoup-request-scan (group &optional server)
304 (nnsoup-unpack-packets))
306 (defun nnsoup-request-newgroups (date &optional server)
307 (nnsoup-request-list))
309 (defun nnsoup-request-list-newsgroups (&optional server)
312 (defun nnsoup-request-post (&optional server)
313 (nnsoup-store-reply "news")
316 (defun nnsoup-request-mail ()
317 (nnsoup-store-reply "mail")
320 (defun nnsoup-request-expire-articles (articles group &optional server force)
321 (nnsoup-possibly-change-group group)
322 (let* ((total-infolist (assoc group nnsoup-group-alist))
323 (active (cadr total-infolist))
324 (infolist (cddr total-infolist))
325 info range-list mod-time prefix)
327 (setq info (pop infolist)
328 range-list (gnus-uncompress-range (car info))
329 prefix (gnus-soup-area-prefix (nth 1 info)))
330 (when ;; All the articles in this file are marked for expiry.
331 (and (or (setq mod-time (nth 5 (file-attributes
332 (nnsoup-file prefix))))
333 (setq mod-time (nth 5 (file-attributes
334 (nnsoup-file prefix t)))))
335 (gnus-sublist-p articles range-list)
336 ;; This file is old enough.
337 (nnmail-expired-article-p group mod-time force))
338 ;; Ok, we delete this file.
339 (when (condition-case nil
342 5 "Deleting %s in group %s..." (nnsoup-file prefix)
344 (when (file-exists-p (nnsoup-file prefix))
345 (delete-file (nnsoup-file prefix)))
347 5 "Deleting %s in group %s..." (nnsoup-file prefix t)
349 (when (file-exists-p (nnsoup-file prefix t))
350 (delete-file (nnsoup-file prefix t)))
353 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
354 (setq articles (gnus-sorted-complement articles range-list))))
356 (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
357 (if (cddr total-infolist)
358 (setcar active (caaadr (cdr total-infolist)))
359 (setcar active (1+ (cdr active))))
360 (nnsoup-write-active-file)
361 ;; Return the articles that weren't expired.
365 ;;; Internal functions
367 (defun nnsoup-possibly-change-group (group &optional force)
369 (setq nnsoup-current-group group)
372 (defun nnsoup-read-active-file ()
373 (setq nnsoup-group-alist)
374 (when (file-exists-p nnsoup-active-file)
376 (load nnsoup-active-file)
378 ;; Be backwards compatible.
379 (when (and nnsoup-group-alist
380 (not (atom (caadar nnsoup-group-alist))))
381 (let ((alist nnsoup-group-alist)
383 (while (setq e (cdr (setq entry (pop alist))))
388 (setcdr entry (cons (cons min max) (cdr entry))))))
391 (defun nnsoup-write-active-file ()
392 (when nnsoup-group-alist
394 (set-buffer (get-buffer-create " *nnsoup work*"))
395 (buffer-disable-undo (current-buffer))
397 (insert (format "(setq nnsoup-group-alist '%S)\n" nnsoup-group-alist))
398 (insert (format "(setq nnsoup-current-prefix %d)\n"
399 nnsoup-current-prefix))
400 (write-region (point-min) (point-max) nnsoup-active-file
402 (kill-buffer (current-buffer)))))
404 (defun nnsoup-next-prefix ()
405 "Return the next free prefix."
407 (while (or (file-exists-p
408 (nnsoup-file (setq prefix (int-to-string
409 nnsoup-current-prefix))))
410 (file-exists-p (nnsoup-file prefix t)))
411 (incf nnsoup-current-prefix))
412 (incf nnsoup-current-prefix)
415 (defun nnsoup-read-areas ()
417 (set-buffer nntp-server-buffer)
418 (let ((areas (gnus-soup-parse-areas (concat nnsoup-tmp-directory "AREAS")))
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 (message "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)
451 (delete-file (concat nnsoup-tmp-directory "AREAS"))))
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 (goto-char (point-min))
468 (let ((regexp (nnsoup-header (gnus-soup-encoding-format
469 (gnus-soup-area-encoding area))))
471 (while (re-search-forward regexp nil t)
475 (defun nnsoup-index-buffer (prefix &optional message)
476 (let* ((file (concat prefix (if message ".MSG" ".IDX")))
477 (buffer-name (concat " *nnsoup " file "*")))
478 (or (get-buffer buffer-name) ; File aready loaded.
479 (when (file-exists-p (concat nnsoup-directory file))
480 (save-excursion ; Load the file.
481 (set-buffer (get-buffer-create buffer-name))
482 (buffer-disable-undo (current-buffer))
483 (push (cons nnsoup-current-group (current-buffer)) nnsoup-buffers)
484 (insert-file-contents (concat nnsoup-directory file))
485 (current-buffer))))))
487 (defun nnsoup-file (prefix &optional message)
489 (concat nnsoup-directory prefix (if message ".MSG" ".IDX"))))
491 (defun nnsoup-message-buffer (prefix)
492 (nnsoup-index-buffer prefix 'msg))
494 (defun nnsoup-unpack-packets ()
495 "Unpack all packets in `nnsoup-packet-directory'."
496 (let ((packets (directory-files
497 nnsoup-packet-directory t nnsoup-packet-regexp))
499 (while (setq packet (pop packets))
500 (message (format "nnsoup: unpacking %s..." packet))
501 (if (not (gnus-soup-unpack-packet
502 nnsoup-tmp-directory nnsoup-unpacker packet))
503 (message "Couldn't unpack %s" packet)
506 (message "Unpacking...done")))))
508 (defun nnsoup-narrow-to-article (article &optional area head)
509 (let* ((area (or area (nnsoup-article-to-area article nnsoup-current-group)))
510 (prefix (gnus-soup-area-prefix (nth 1 area)))
511 (msg-buf (nnsoup-index-buffer prefix 'msg))
515 ;; There is no MSG file.
519 ;; We use the index file to find out where the article begins and ends.
520 ((and (= (gnus-soup-encoding-index
521 (gnus-soup-area-encoding (nth 1 area)))
523 (file-exists-p (nnsoup-file prefix)))
524 (set-buffer (nnsoup-index-buffer prefix))
526 (goto-char (point-min))
527 (forward-line (- article (caar area)))
528 (setq beg (read (current-buffer)))
530 (if (looking-at "[0-9]+")
532 (setq end (read (current-buffer)))
535 (let ((format (gnus-soup-encoding-format
536 (gnus-soup-area-encoding (nth 1 area)))))
538 (if (or (= format ?n) (= format ?m))
539 (setq end (progn (forward-line -1) (point))))))
540 (set-buffer msg-buf))
542 (narrow-to-region beg (or end (point-max))))
546 (goto-char (point-min))
547 (let ((header (nnsoup-header
548 (gnus-soup-encoding-format
549 (gnus-soup-area-encoding (nth 1 area))))))
550 (re-search-forward header nil t (- article (caar area)))
553 (if (re-search-forward header nil t)
556 (goto-char (point-min))
561 (if (search-forward "\n\n" nil t)
566 (defun nnsoup-header (format)
569 "^#! *rnews +[0-9]+ *$")
571 (concat "^" rmail-unix-mail-delimiter))
575 (error "Unknown format: %c" format))))
578 (defun nnsoup-pack-replies ()
579 "Make an outbound package of SOUP replies."
581 ;; Write all data buffers.
582 (gnus-soup-save-areas)
583 ;; Write the active file.
584 (nnsoup-write-active-file)
585 ;; Write the REPLIES file.
586 (nnsoup-write-replies)
587 ;; Pack all these files into a SOUP packet.
588 (gnus-soup-pack nnsoup-replies-directory nnsoup-packer))
590 (defun nnsoup-write-replies ()
591 "Write the REPLIES file."
592 (when nnsoup-replies-list
593 (gnus-soup-write-replies nnsoup-replies-directory nnsoup-replies-list)
594 (setq nnsoup-replies-list nil)))
596 (defun nnsoup-article-to-area (article group)
597 "Return the area that ARTICLE in GROUP is located in."
598 (let ((areas (cddr (assoc group nnsoup-group-alist))))
599 (while (and areas (< (cdaar areas) article))
600 (setq areas (cdr areas)))
601 (and areas (car areas))))
603 (defvar nnsoup-old-functions
604 (list gnus-inews-article-function send-mail-function))
607 (defun nnsoup-set-variables ()
608 "Use the SOUP methods for posting news and mailing mail."
610 (setq gnus-inews-article-function 'nnsoup-request-post)
611 (setq send-mail-function 'nnsoup-request-mail))
614 (defun nnsoup-revert-variables ()
615 "Revert posting and mailing methods to the standard Emacs methods."
617 (setq gnus-inews-article-function (car nnsoup-old-functions))
618 (setq send-mail-function (cadr nnsoup-old-functions)))
620 (defun nnsoup-store-reply (kind)
621 ;; Mostly stolen from `sendmail.el'.
622 (let ((tembuf (generate-new-buffer " sendmail temp"))
623 (case-fold-search nil)
624 (mailbuf (current-buffer))
629 (insert-buffer-substring mailbuf)
630 (goto-char (point-max))
631 ;; require one newline at the end.
632 (or (= (preceding-char) ?\n)
634 ;; Change header-delimiter to be what sendmail expects.
635 (goto-char (point-min))
636 (if (re-search-forward
637 (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
639 (search-forward "\n\n" nil t))
641 (setq delimline (point-marker))
642 (if (and mail-aliases (fboundp 'expand-mail-aliases))
643 (expand-mail-aliases (point-min) delimline))
644 (goto-char (point-min))
645 ;; ignore any blank lines in the header
646 (while (and (re-search-forward "\n\n\n*" delimline t)
647 (< (point) delimline))
648 (replace-match "\n"))
649 (let ((case-fold-search t))
650 (goto-char (point-min))
651 ;; Find and handle any FCC fields.
652 (goto-char (point-min))
653 (if (re-search-forward "^FCC:" delimline t)
654 (mail-do-fcc delimline))
655 (goto-char (point-min))
656 ;; "S:" is an abbreviation for "Subject:".
657 (goto-char (point-min))
658 (if (re-search-forward "^S:" delimline t)
659 (replace-match "Subject:"))
660 ;; Don't send out a blank subject line
661 (goto-char (point-min))
662 (if (re-search-forward "^Subject:[ \t]*\n" delimline t)
664 ;; Insert an extra newline if we need it to work around
665 ;; Sun's bug that swallows newlines.
666 (goto-char (1+ delimline))
667 (if (and (boundp 'mail-mailer-swallows-blank-line)
668 (eval mail-mailer-swallows-blank-line))
672 nnsoup-replies-directory
673 (nnsoup-kind-to-prefix kind) nil nnsoup-replies-format-type
674 nnsoup-replies-index-type))
676 (when (and msg-buf (bufferp msg-buf))
679 (goto-char (point-min))
680 (while (re-search-forward "^#! *rnews" nil t)
682 (message "Stored %d messages" num)))
683 (nnsoup-write-replies)
684 (kill-buffer tembuf))))
686 (defun nnsoup-kind-to-prefix (kind)
687 (unless nnsoup-replies-list
688 (setq nnsoup-replies-list
689 (gnus-soup-parse-replies
690 (concat nnsoup-replies-directory "REPLIES"))))
691 (let ((replies nnsoup-replies-list))
693 (not (string= kind (gnus-soup-reply-kind (car replies)))))
694 (setq replies (cdr replies)))
696 (gnus-soup-reply-prefix (car replies))
697 (setq nnsoup-replies-list
698 (cons (vector (gnus-soup-unique-prefix nnsoup-replies-directory)
701 nnsoup-replies-format-type
702 nnsoup-replies-index-type
703 (if (string= kind "news")
705 nnsoup-replies-list))
706 (gnus-soup-reply-prefix (car nnsoup-replies-list)))))
708 (defun nnsoup-make-active ()
709 "(Re-)create the SOUP active file."
711 (let ((files (sort (directory-files nnsoup-directory t "IDX$")
713 (< (progn (string-match "/\\([0-9]+\\)\\." f1)
714 (string-to-int (match-string 1 f1)))
715 (progn (string-match "/\\([0-9]+\\)\\." f2)
716 (string-to-int (match-string 1 f2)))))))
717 active group lines ident elem min)
718 (set-buffer (get-buffer-create " *nnsoup work*"))
719 (buffer-disable-undo (current-buffer))
721 (message "Doing %s..." (car files))
723 (insert-file-contents (car files))
724 (goto-char (point-min))
726 (re-search-backward "[ \t]\\([^ ]+\\):[0-9]")
727 (setq group (buffer-substring (match-beginning 1) (match-end 1)))
728 (setq lines (count-lines (point-min) (point-max)))
729 (setq ident (progn (string-match
730 "/\\([0-9]+\\)\\." (car files))
732 (car files) (match-beginning 1)
734 (if (not (setq elem (assoc group active)))
735 (push (list group (cons 1 lines)
737 (vector ident group "ncm" "" lines)))
741 (list (cons (setq min (1+ (cdaadr elem)))
743 (vector ident group "ncm" "" lines))))
744 (setcdr (cadr elem) (+ min lines)))
745 (setq files (cdr files)))
747 (setq nnsoup-group-alist active)
749 (setcdr (car active) (nreverse (cdar active)))
750 (setq active (cdr active)))
751 (nnsoup-write-active-file)))
753 (defun nnsoup-delete-unreferenced-message-files ()
754 "Delete any *.MSG and *.IDX files that aren't known by nnsoup."
756 (let* ((known (apply 'nconc (mapcar
760 (gnus-soup-area-prefix (cadr area)))
762 nnsoup-group-alist)))
763 (regexp "\\.MSG$\\|\\.IDX$")
764 (files (directory-files nnsoup-directory nil regexp))
766 ;; Find all files that aren't known by nnsoup.
767 (while (setq file (pop files))
768 (string-match regexp file)
769 (unless (member (substring file 0 (match-beginning 0)) known)
770 (push file non-files)))
771 ;; Sort and delete the files.
772 (setq non-files (sort non-files 'string<))
773 (map-y-or-n-p "Delete file %s? "
774 (lambda (file) (delete-file (concat nnsoup-directory file)))
779 ;;; nnsoup.el ends here