annotate lisp/gnus/gnus-cache.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gnus-cache.el --- cache interface for Gnus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar gnus-cache-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (nnheader-concat gnus-directory "cache/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "*The directory where cached articles will be stored.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar gnus-cache-active-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (concat (file-name-as-directory gnus-cache-directory) "active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "*The cache active file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defvar gnus-cache-enter-articles '(ticked dormant)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "*Classes of articles to enter into the cache.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar gnus-cache-remove-articles '(read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "*Classes of articles to remove from the cache.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar gnus-uncacheable-groups nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*Groups that match this regexp will not be cached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 If you want to avoid caching your nnml groups, you could set this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 variable to \"^nnml\".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar gnus-cache-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar gnus-cache-active-hashtb nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar gnus-cache-active-altered nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (autoload 'nnml-generate-nov-databases-1 "nnml")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (autoload 'nnvirtual-find-group-art "nnvirtual"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; Functions called from Gnus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun gnus-cache-open ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "Initialize the cache."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
69 (when (or (file-exists-p gnus-cache-directory)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70 (and gnus-use-cache
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71 (not (eq gnus-use-cache 'passive))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 (gnus-cache-read-active)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 (condition-case ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
75 (gnus-add-shutdown 'gnus-cache-close 'gnus)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 ;; Complexities of byte-compiling makes this kludge necessary. Eeek.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 (error nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun gnus-cache-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Shut down the cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (gnus-cache-write-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (gnus-cache-save-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (setq gnus-cache-active-hashtb nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defun gnus-cache-save-buffers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; save the overview buffer if it exists and has been modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; delete empty cache subdirectories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if (null gnus-cache-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (let ((buffer (cdr gnus-cache-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (overview-file (gnus-cache-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (car gnus-cache-buffer) ".overview")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; write the overview only if it was modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (buffer-modified-p buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (if (> (buffer-size) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; non-empty overview, write it out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (gnus-make-directory (file-name-directory overview-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 overview-file nil 'quietly))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; empty overview file, remove it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (and (file-exists-p overview-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (delete-file overview-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; if possible, remove group's cache subdirectory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; FIXME: we can detect the error type and warn the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; of any inconsistencies (articles w/o nov entries?).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; for now, just be conservative...delete only if safe -- sj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (delete-directory (file-name-directory overview-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (error nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; kill the buffer, it's either unmodified or saved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (gnus-kill-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq gnus-cache-buffer nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defun gnus-cache-possibly-enter-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (group article headers ticked dormant unread &optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (when (and (or force (not (eq gnus-use-cache 'passive)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (numberp article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (> article 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (vectorp headers)) ; This might be a dummy article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; If this is a virtual group, we find the real group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (when (gnus-virtual-group-p group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let ((result (nnvirtual-find-group-art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (gnus-group-real-name group) article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (setq group (car result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 headers (copy-sequence headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (mail-header-set-number headers (cdr result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (let ((number (mail-header-number headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 file dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (when (and (> number 0) ; Reffed article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (or (not gnus-uncacheable-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (not (string-match gnus-uncacheable-groups group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (gnus-cache-member-of-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 gnus-cache-enter-articles ticked dormant unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (not (file-exists-p (setq file (gnus-cache-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 group number)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; Possibly create the cache directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (or (file-exists-p (setq dir (file-name-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (gnus-make-directory dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; Save the article in the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 t ; The article already is saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let ((gnus-use-cache nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (gnus-request-article-this-buffer number group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (when (> (buffer-size) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (write-region (point-min) (point-max) file nil 'quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (gnus-cache-change-buffer group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (set-buffer (cdr gnus-cache-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (while (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (and (not (bobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (> (read (current-buffer)) number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; The line was malformed, so we just remove it!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (gnus-delete-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if (< (read (current-buffer)) number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; [number subject from date id references chars lines xref]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (insert (format "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (mail-header-number headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (mail-header-subject headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (mail-header-from headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (mail-header-date headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (mail-header-id headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (or (mail-header-references headers) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (or (mail-header-chars headers) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (or (mail-header-lines headers) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (or (mail-header-xref headers) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; Update the active info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (set-buffer gnus-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (gnus-cache-update-active group number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (push article gnus-newsgroup-cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (gnus-summary-update-secondary-mark article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun gnus-cache-enter-remove-article (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Mark ARTICLE for later possible removal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (when article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (push article gnus-cache-removable-articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (defun gnus-cache-possibly-remove-articles ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 "Possibly remove some of the removable articles."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (if (not (gnus-virtual-group-p gnus-newsgroup-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (gnus-cache-possibly-remove-articles-1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (let ((arts gnus-cache-removable-articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ga)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (while arts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (when (setq ga (nnvirtual-find-group-art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (gnus-group-real-name gnus-newsgroup-name) (pop arts)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((gnus-cache-removable-articles (list (cdr ga)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (gnus-newsgroup-name (car ga)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (gnus-cache-possibly-remove-articles-1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq gnus-cache-removable-articles nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defun gnus-cache-possibly-remove-articles-1 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "Possibly remove some of the removable articles."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (unless (eq gnus-use-cache 'passive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (let ((articles gnus-cache-removable-articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (cache-articles gnus-newsgroup-cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (gnus-cache-change-buffer gnus-newsgroup-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (memq (setq article (pop articles)) cache-articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; The article was in the cache, so we see whether we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; supposed to remove it from the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (gnus-cache-possibly-remove-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 article (memq article gnus-newsgroup-marked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (memq article gnus-newsgroup-dormant)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (or (memq article gnus-newsgroup-unreads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (memq article gnus-newsgroup-unselected))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; The overview file might have been modified, save it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; safe because we're only called at group exit anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (gnus-cache-save-buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun gnus-cache-request-article (article group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "Retrieve ARTICLE in GROUP from the cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((file (gnus-cache-file-name group article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (when (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (gnus-kill-all-overlays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (insert-file-contents file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun gnus-cache-possibly-alter-active (group active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
242 (when gnus-cache-active-hashtb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
244 (and cache-active
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
245 (< (car cache-active) (car active))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
246 (setcar active (car cache-active)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
247 (and cache-active
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
248 (> (cdr cache-active) (cdr active))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
249 (setcdr active (cdr cache-active))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Retrieve the headers for ARTICLES in GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (let ((cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (if (not cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; No cached articles here, so we just retrieve them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; the normal way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let ((gnus-use-cache nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (gnus-retrieve-headers articles group fetch-old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (let ((uncached-articles (gnus-sorted-intersection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (gnus-sorted-complement articles cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (cache-file (gnus-cache-file-name group ".overview"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; We first retrieve all the headers that we don't have in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let ((gnus-use-cache nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (when uncached-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq type (and articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (gnus-retrieve-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 uncached-articles group fetch-old)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (gnus-cache-save-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; Then we insert the cached headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ((not (file-exists-p cache-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; There are no cached headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ((null type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; There were no uncached headers (or retrieval was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; unsuccessful), so we use the cached headers exclusively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (insert-file-contents cache-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 'nov)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ((eq type 'nov)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; We have both cached and uncached NOV headers, so we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; braid them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (gnus-cache-braid-nov group cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; We braid HEADs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (gnus-cache-braid-heads group (gnus-sorted-intersection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 cached articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 type)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun gnus-cache-enter-article (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 "Enter the next N articles into the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 If not given a prefix, use the process marked articles instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Returns the list of articles entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (gnus-set-global-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (let ((articles (gnus-summary-work-articles n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 article out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (setq article (pop articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (when (gnus-cache-possibly-enter-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 gnus-newsgroup-name article (gnus-summary-article-header article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 nil nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (push article out))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (gnus-summary-remove-process-mark article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (gnus-summary-update-secondary-mark article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (gnus-summary-next-subject 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (gnus-summary-position-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (nreverse out)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun gnus-cache-remove-article (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Remove the next N articles from the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 If not given a prefix, use the process marked articles instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 Returns the list of articles removed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (gnus-set-global-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (gnus-cache-change-buffer gnus-newsgroup-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (let ((articles (gnus-summary-work-articles n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 article out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq article (pop articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (when (gnus-cache-possibly-remove-article article nil nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (push article out))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (gnus-summary-remove-process-mark article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (gnus-summary-update-secondary-mark article))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (gnus-summary-next-subject 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (gnus-summary-position-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (nreverse out)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defun gnus-cached-article-p (article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 "Say whether ARTICLE is cached in the current group."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (memq article gnus-newsgroup-cached))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;; Internal functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun gnus-cache-change-buffer (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (and gnus-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; See if the current group's overview cache has been loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (or (string= group (car gnus-cache-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; Another overview cache is current, save it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (gnus-cache-save-buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; if gnus-cache buffer is nil, create it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (or gnus-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; Create cache buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq gnus-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (cons group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (set-buffer (get-buffer-create " *gnus-cache-overview*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Insert the contents of this group's cache overview.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (let ((file (gnus-cache-file-name group ".overview")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (and (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (insert-file-contents file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;; We have a fresh (empty/just loaded) buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; mark it as unmodified to save a redundant write later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; Return whether an article is a member of a class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defun gnus-cache-member-of-class (class ticked dormant unread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (or (and ticked (memq 'ticked class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (and dormant (memq 'dormant class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (and unread (memq 'unread class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (and (not unread) (not ticked) (not dormant) (memq 'read class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun gnus-cache-file-name (group article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (concat (file-name-as-directory gnus-cache-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (gnus-use-long-file-name 'not-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 group
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
377 (let ((group (nnheader-replace-chars-in-string group ?/ ?_)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
378 ;; Translate the first colon into a slash.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
379 (when (string-match ":" group)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
380 (aset group (match-beginning 0) ?/))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (nnheader-replace-chars-in-string group ?. ?/))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (stringp article) article (int-to-string article))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defun gnus-cache-update-article (group article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "If ARTICLE is in the cache, remove it and re-enter it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (when (gnus-cache-possibly-remove-article article nil nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (let ((gnus-use-cache nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (gnus-cache-possibly-enter-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 gnus-newsgroup-name article (gnus-summary-article-header article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 nil nil nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun gnus-cache-possibly-remove-article (article ticked dormant unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 &optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Possibly remove ARTICLE from the cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (let ((group gnus-newsgroup-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (number article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; If this is a virtual group, we find the real group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (when (gnus-virtual-group-p group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (let ((result (nnvirtual-find-group-art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (gnus-group-real-name group) article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (setq group (car result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 number (cdr result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (setq file (gnus-cache-file-name group number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (when (and (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (gnus-cache-member-of-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 gnus-cache-remove-articles ticked dormant unread)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (set-buffer (cdr gnus-cache-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (or (looking-at (concat (int-to-string number) "\t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (search-forward (concat "\n" (int-to-string number) "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (progn (forward-line 1) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq gnus-newsgroup-cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (delq article gnus-newsgroup-cached))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (gnus-summary-update-secondary-mark article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defun gnus-cache-articles-in-group (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "Return a sorted list of cached articles in GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (let ((dir (file-name-directory (gnus-cache-file-name group 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (when (file-exists-p dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (sort (mapcar (lambda (name) (string-to-int name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (directory-files dir nil "^[0-9]+$" t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 '<))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (defun gnus-cache-braid-nov (group cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((cache-buf (get-buffer-create " *gnus-cache*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (gnus-cache-save-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (set-buffer cache-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (insert-file-contents (gnus-cache-file-name group ".overview"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (while cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (< (read (current-buffer)) (car cached)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (set-buffer cache-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (search-forward (concat "\n" (int-to-string (car cached)) "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq beg (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 end (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (setq beg nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if beg (progn (insert-buffer-substring cache-buf beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (insert "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (setq cached (cdr cached)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (kill-buffer cache-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun gnus-cache-braid-heads (group cached)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let ((cache-buf (get-buffer-create " *gnus-cache*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (set-buffer cache-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (while cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (looking-at "2.. +\\([0-9]+\\) ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (< (progn (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (car cached)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (search-forward "\n.\n" nil 'move))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (set-buffer cache-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (insert-file-contents (gnus-cache-file-name group (car cached)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (insert "220 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (princ (car cached) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (insert " Article retrieved.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (search-forward "\n\n" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (insert "."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (insert-buffer-substring cache-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (setq cached (cdr cached)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (kill-buffer cache-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun gnus-jog-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 "Go through all groups and put the articles into the cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (let ((gnus-mark-article-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (gnus-expert-user t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (nnmail-spool-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (gnus-use-dribble-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (gnus-novice-user nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (gnus-large-newsgroup nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;; Start Gnus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; Go through all groups...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (gnus-group-mark-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (gnus-group-universal-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (gnus-summary-read-group nil nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; ... and enter the articles into the cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (when (eq major-mode 'gnus-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (gnus-uu-mark-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (gnus-cache-enter-article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (kill-buffer (current-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (defun gnus-cache-read-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 "Read the cache active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (unless (file-exists-p gnus-cache-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (make-directory gnus-cache-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (if (not (and (file-exists-p gnus-cache-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (or force (not gnus-cache-active-hashtb))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; There is no active file, so we generate one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (gnus-cache-generate-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; We simply read the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (gnus-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (insert-file-contents gnus-cache-active-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (gnus-active-to-gnus-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 nil (setq gnus-cache-active-hashtb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (gnus-make-hashtable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (count-lines (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (setq gnus-cache-active-altered nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun gnus-cache-write-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 "Write the active hashtb to the active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (when (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (and gnus-cache-active-hashtb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 gnus-cache-active-altered))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (gnus-set-work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (mapatoms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (when (and sym (boundp sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (insert (format "%s %d %d y\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (symbol-name sym) (cdr (symbol-value sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (car (symbol-value sym))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 gnus-cache-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (gnus-make-directory (file-name-directory gnus-cache-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (point-min) (point-max) gnus-cache-active-file nil 'silent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;; Mark the active hashtb as unaltered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq gnus-cache-active-altered nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun gnus-cache-update-active (group number &optional low)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 "Update the upper bound of the active info of GROUP to NUMBER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 If LOW, update the lower bound instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let ((active (gnus-gethash group gnus-cache-active-hashtb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (null active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; We just create a new active entry for this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (gnus-sethash group (cons number number) gnus-cache-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; Update the lower or upper bound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (if low
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (setcar active number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (setcdr active number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; Mark the active hashtb as altered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (setq gnus-cache-active-altered t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (defun gnus-cache-generate-active (&optional directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 "Generate the cache active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (let* ((top (null directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (directory (expand-file-name (or directory gnus-cache-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (files (directory-files directory 'full))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (if top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (concat "^" (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (expand-file-name gnus-cache-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (directory-file-name directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (nnheader-replace-chars-in-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (substring (directory-file-name directory) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ?/ ?.)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 nums alphs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (when top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (gnus-message 5 "Generating the cache active file...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (setq gnus-cache-active-hashtb (gnus-make-hashtable 123)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; Separate articles from all other files and directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if (string-match "^[0-9]+$" (file-name-nondirectory (car files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (push (string-to-int (file-name-nondirectory (pop files))) nums)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (push (pop files) alphs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; If we have nums, then this is probably a valid group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (when (setq nums (sort nums '<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (gnus-sethash group (cons (car nums) (gnus-last-element nums))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 gnus-cache-active-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; Go through all the other files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (while alphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (when (and (file-directory-p (car alphs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (not (string-match "^\\.\\.?$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (file-name-nondirectory (car alphs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; We descend directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (gnus-cache-generate-active (car alphs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq alphs (cdr alphs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; Write the new active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (when top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (gnus-cache-write-active t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (gnus-message 5 "Generating the cache active file...done"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (defun gnus-cache-generate-nov-databases (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 "Generate NOV files recursively starting in DIR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (interactive (list gnus-cache-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (gnus-cache-close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (let ((nnml-generate-active-function 'identity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (nnml-generate-nov-databases-1 dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (provide 'gnus-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; gnus-cache.el ends here