Mercurial > emacs
annotate lisp/gnus/gnus-cache.el @ 78023:fb819c8536d0
*** empty log message ***
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sun, 17 Jun 2007 22:25:08 +0000 |
parents | e3694f1cb928 |
children | 24202b793a08 95d0cdf160ea |
rev | line source |
---|---|
17493 | 1 ;;; gnus-cache.el --- cache interface for Gnus |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
61424
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
59089
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
75347 | 4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
17493 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
19493
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
31 |
17493 | 32 (require 'gnus) |
33 (require 'gnus-int) | |
34 (require 'gnus-range) | |
35 (require 'gnus-start) | |
36 (eval-when-compile | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
37 (if (not (fboundp 'gnus-agent-load-alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
38 (defun gnus-agent-load-alist (group))) |
17493 | 39 (require 'gnus-sum)) |
40 | |
41 (defcustom gnus-cache-active-file | |
33379
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
42 (expand-file-name "active" gnus-cache-directory) |
17493 | 43 "*The cache active file." |
44 :group 'gnus-cache | |
45 :type 'file) | |
46 | |
47 (defcustom gnus-cache-enter-articles '(ticked dormant) | |
48 "Classes of articles to enter into the cache." | |
49 :group 'gnus-cache | |
50 :type '(set (const ticked) (const dormant) (const unread) (const read))) | |
51 | |
52 (defcustom gnus-cache-remove-articles '(read) | |
53 "Classes of articles to remove from the cache." | |
54 :group 'gnus-cache | |
55 :type '(set (const ticked) (const dormant) (const unread) (const read))) | |
56 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
57 (defcustom gnus-cacheable-groups nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
58 "*Groups that match this regexp will be cached. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
59 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
60 If you only want to cache your nntp groups, you could set this |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
61 variable to \"^nntp\". |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
62 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
63 If a group matches both gnus-cacheable-groups and gnus-uncacheable-groups |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
64 it's not cached." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
65 :group 'gnus-cache |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
66 :type '(choice (const :tag "off" nil) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
67 regexp)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
68 |
17493 | 69 (defcustom gnus-uncacheable-groups nil |
70 "*Groups that match this regexp will not be cached. | |
71 | |
72 If you want to avoid caching your nnml groups, you could set this | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
73 variable to \"^nnml\". |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
74 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
75 If a group matches both gnus-cacheable-groups and gnus-uncacheable-groups |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
76 it's not cached." |
17493 | 77 :group 'gnus-cache |
78 :type '(choice (const :tag "off" nil) | |
79 regexp)) | |
80 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
81 (defvar gnus-cache-overview-coding-system 'raw-text |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
82 "Coding system used on Gnus cache files.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
83 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
84 (defvar gnus-cache-coding-system 'raw-text |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
85 "Coding system used on Gnus cache files.") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
86 |
17493 | 87 |
88 | |
89 ;;; Internal variables. | |
90 | |
91 (defvar gnus-cache-removable-articles nil) | |
92 (defvar gnus-cache-buffer nil) | |
93 (defvar gnus-cache-active-hashtb nil) | |
94 (defvar gnus-cache-active-altered nil) | |
95 | |
96 (eval-and-compile | |
97 (autoload 'nnml-generate-nov-databases-1 "nnml") | |
98 (autoload 'nnvirtual-find-group-art "nnvirtual")) | |
99 | |
100 | |
101 | |
102 ;;; Functions called from Gnus. | |
103 | |
104 (defun gnus-cache-open () | |
105 "Initialize the cache." | |
106 (when (or (file-exists-p gnus-cache-directory) | |
107 (and gnus-use-cache | |
108 (not (eq gnus-use-cache 'passive)))) | |
109 (gnus-cache-read-active))) | |
110 | |
111 ;; Complexities of byte-compiling make this kludge necessary. Eeek. | |
112 (ignore-errors | |
113 (gnus-add-shutdown 'gnus-cache-close 'gnus)) | |
114 | |
115 (defun gnus-cache-close () | |
116 "Shut down the cache." | |
117 (gnus-cache-write-active) | |
118 (gnus-cache-save-buffers) | |
119 (setq gnus-cache-active-hashtb nil)) | |
120 | |
121 (defun gnus-cache-save-buffers () | |
122 ;; save the overview buffer if it exists and has been modified | |
123 ;; delete empty cache subdirectories | |
124 (when gnus-cache-buffer | |
125 (let ((buffer (cdr gnus-cache-buffer)) | |
126 (overview-file (gnus-cache-file-name | |
127 (car gnus-cache-buffer) ".overview"))) | |
128 ;; write the overview only if it was modified | |
57243
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
129 (when (and (buffer-live-p buffer) (buffer-modified-p buffer)) |
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
130 (with-current-buffer buffer |
17493 | 131 (if (> (buffer-size) 0) |
132 ;; Non-empty overview, write it to a file. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
133 (let ((coding-system-for-write |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
134 gnus-cache-overview-coding-system)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
135 (gnus-write-buffer overview-file)) |
17493 | 136 ;; Empty overview file, remove it |
137 (when (file-exists-p overview-file) | |
138 (delete-file overview-file)) | |
139 ;; If possible, remove group's cache subdirectory. | |
140 (condition-case nil | |
141 ;; FIXME: we can detect the error type and warn the user | |
142 ;; of any inconsistencies (articles w/o nov entries?). | |
143 ;; for now, just be conservative...delete only if safe -- sj | |
144 (delete-directory (file-name-directory overview-file)) | |
145 (error nil))))) | |
146 ;; Kill the buffer -- it's either unmodified or saved. | |
147 (gnus-kill-buffer buffer) | |
148 (setq gnus-cache-buffer nil)))) | |
149 | |
150 (defun gnus-cache-possibly-enter-article | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
151 (group article ticked dormant unread &optional force) |
17493 | 152 (when (and (or force (not (eq gnus-use-cache 'passive))) |
153 (numberp article) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
154 (> article 0)) ; This might be a dummy article. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
155 (let ((number article) file headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
156 ;; If this is a virtual group, we find the real group. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
157 (when (gnus-virtual-group-p group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
158 (let ((result (nnvirtual-find-group-art |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
159 (gnus-group-real-name group) article))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
160 (setq group (car result) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
161 number (cdr result)))) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
162 (when (and number |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
163 (> number 0) ; Reffed article. |
17493 | 164 (or force |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
165 (and (gnus-cache-fully-p group) |
17493 | 166 (gnus-cache-member-of-class |
167 gnus-cache-enter-articles ticked dormant unread))) | |
168 (not (file-exists-p (setq file (gnus-cache-file-name | |
169 group number))))) | |
170 ;; Possibly create the cache directory. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
171 (gnus-make-directory (file-name-directory file)) |
17493 | 172 ;; Save the article in the cache. |
173 (if (file-exists-p file) | |
174 t ; The article already is saved. | |
175 (save-excursion | |
176 (set-buffer nntp-server-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
177 (require 'gnus-art) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
178 (let ((gnus-use-cache nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
179 (gnus-article-decode-hook nil)) |
17493 | 180 (gnus-request-article-this-buffer number group)) |
181 (when (> (buffer-size) 0) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
182 (let ((coding-system-for-write gnus-cache-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
183 (gnus-write-buffer file)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
184 (nnheader-remove-body) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
185 (setq headers (nnheader-parse-naked-head)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
186 (mail-header-set-number headers number) |
17493 | 187 (gnus-cache-change-buffer group) |
188 (set-buffer (cdr gnus-cache-buffer)) | |
189 (goto-char (point-max)) | |
190 (forward-line -1) | |
191 (while (condition-case () | |
192 (when (not (bobp)) | |
193 (> (read (current-buffer)) number)) | |
194 (error | |
195 ;; The line was malformed, so we just remove it!! | |
196 (gnus-delete-line) | |
197 t)) | |
198 (forward-line -1)) | |
199 (if (bobp) | |
200 (if (not (eobp)) | |
201 (progn | |
202 (beginning-of-line) | |
203 (when (< (read (current-buffer)) number) | |
204 (forward-line 1))) | |
205 (beginning-of-line)) | |
206 (forward-line 1)) | |
207 (beginning-of-line) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
208 (nnheader-insert-nov headers) |
17493 | 209 ;; Update the active info. |
210 (set-buffer gnus-summary-buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
211 (gnus-cache-possibly-update-active group (cons number number)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
212 (setq gnus-newsgroup-cached |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
213 (gnus-add-to-sorted-list gnus-newsgroup-cached article)) |
17493 | 214 (gnus-summary-update-secondary-mark article)) |
215 t)))))) | |
216 | |
217 (defun gnus-cache-enter-remove-article (article) | |
218 "Mark ARTICLE for later possible removal." | |
219 (when article | |
220 (push article gnus-cache-removable-articles))) | |
221 | |
222 (defun gnus-cache-possibly-remove-articles () | |
223 "Possibly remove some of the removable articles." | |
224 (if (not (gnus-virtual-group-p gnus-newsgroup-name)) | |
225 (gnus-cache-possibly-remove-articles-1) | |
226 (let ((arts gnus-cache-removable-articles) | |
227 ga) | |
228 (while arts | |
229 (when (setq ga (nnvirtual-find-group-art | |
230 (gnus-group-real-name gnus-newsgroup-name) (pop arts))) | |
231 (let ((gnus-cache-removable-articles (list (cdr ga))) | |
232 (gnus-newsgroup-name (car ga))) | |
233 (gnus-cache-possibly-remove-articles-1))))) | |
234 (setq gnus-cache-removable-articles nil))) | |
235 | |
236 (defun gnus-cache-possibly-remove-articles-1 () | |
237 "Possibly remove some of the removable articles." | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
238 (when (gnus-cache-fully-p gnus-newsgroup-name) |
17493 | 239 (let ((articles gnus-cache-removable-articles) |
240 (cache-articles gnus-newsgroup-cached) | |
241 article) | |
242 (gnus-cache-change-buffer gnus-newsgroup-name) | |
243 (while articles | |
244 (when (memq (setq article (pop articles)) cache-articles) | |
245 ;; The article was in the cache, so we see whether we are | |
246 ;; supposed to remove it from the cache. | |
247 (gnus-cache-possibly-remove-article | |
248 article (memq article gnus-newsgroup-marked) | |
249 (memq article gnus-newsgroup-dormant) | |
250 (or (memq article gnus-newsgroup-unreads) | |
251 (memq article gnus-newsgroup-unselected)))))) | |
252 ;; The overview file might have been modified, save it | |
253 ;; safe because we're only called at group exit anyway. | |
254 (gnus-cache-save-buffers))) | |
255 | |
256 (defun gnus-cache-request-article (article group) | |
257 "Retrieve ARTICLE in GROUP from the cache." | |
258 (let ((file (gnus-cache-file-name group article)) | |
259 (buffer-read-only nil)) | |
260 (when (file-exists-p file) | |
261 (erase-buffer) | |
262 (gnus-kill-all-overlays) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
263 (let ((coding-system-for-read gnus-cache-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
264 (insert-file-contents file)) |
17493 | 265 t))) |
266 | |
267 (defun gnus-cache-possibly-alter-active (group active) | |
268 "Alter the ACTIVE info for GROUP to reflect the articles in the cache." | |
269 (when gnus-cache-active-hashtb | |
270 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
271 (when cache-active |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
272 (when (< (car cache-active) (car active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
273 (setcar active (car cache-active))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
274 (when (> (cdr cache-active) (cdr active)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
275 (setcdr active (cdr cache-active))))))) |
17493 | 276 |
277 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old) | |
278 "Retrieve the headers for ARTICLES in GROUP." | |
279 (let ((cached | |
280 (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group)))) | |
281 (if (not cached) | |
282 ;; No cached articles here, so we just retrieve them | |
283 ;; the normal way. | |
284 (let ((gnus-use-cache nil)) | |
285 (gnus-retrieve-headers articles group fetch-old)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
286 (let ((uncached-articles (gnus-sorted-difference articles cached)) |
17493 | 287 (cache-file (gnus-cache-file-name group ".overview")) |
288 type) | |
289 ;; We first retrieve all the headers that we don't have in | |
290 ;; the cache. | |
291 (let ((gnus-use-cache nil)) | |
292 (when uncached-articles | |
293 (setq type (and articles | |
294 (gnus-retrieve-headers | |
295 uncached-articles group fetch-old))))) | |
296 (gnus-cache-save-buffers) | |
297 ;; Then we insert the cached headers. | |
298 (save-excursion | |
299 (cond | |
300 ((not (file-exists-p cache-file)) | |
301 ;; There are no cached headers. | |
302 type) | |
303 ((null type) | |
304 ;; There were no uncached headers (or retrieval was | |
305 ;; unsuccessful), so we use the cached headers exclusively. | |
306 (set-buffer nntp-server-buffer) | |
307 (erase-buffer) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33379
diff
changeset
|
308 (let ((coding-system-for-read |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
309 gnus-cache-overview-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
310 (insert-file-contents cache-file)) |
17493 | 311 'nov) |
312 ((eq type 'nov) | |
313 ;; We have both cached and uncached NOV headers, so we | |
314 ;; braid them. | |
315 (gnus-cache-braid-nov group cached) | |
316 type) | |
317 (t | |
318 ;; We braid HEADs. | |
319 (gnus-cache-braid-heads group (gnus-sorted-intersection | |
320 cached articles)) | |
321 type))))))) | |
322 | |
323 (defun gnus-cache-enter-article (&optional n) | |
324 "Enter the next N articles into the cache. | |
325 If not given a prefix, use the process marked articles instead. | |
326 Returns the list of articles entered." | |
327 (interactive "P") | |
328 (let ((articles (gnus-summary-work-articles n)) | |
329 article out) | |
330 (while (setq article (pop articles)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
331 (gnus-summary-remove-process-mark article) |
17493 | 332 (if (natnump article) |
333 (when (gnus-cache-possibly-enter-article | |
334 gnus-newsgroup-name article | |
335 nil nil nil t) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
336 (setq gnus-newsgroup-undownloaded (delq article gnus-newsgroup-undownloaded)) |
17493 | 337 (push article out)) |
338 (gnus-message 2 "Can't cache article %d" article)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
339 (gnus-summary-update-download-mark article) |
17493 | 340 (gnus-summary-update-secondary-mark article)) |
341 (gnus-summary-next-subject 1) | |
342 (gnus-summary-position-point) | |
343 (nreverse out))) | |
344 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
345 (defun gnus-cache-remove-article (&optional n) |
17493 | 346 "Remove the next N articles from the cache. |
347 If not given a prefix, use the process marked articles instead. | |
348 Returns the list of articles removed." | |
349 (interactive "P") | |
350 (gnus-cache-change-buffer gnus-newsgroup-name) | |
351 (let ((articles (gnus-summary-work-articles n)) | |
352 article out) | |
353 (while articles | |
354 (setq article (pop articles)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
355 (gnus-summary-remove-process-mark article) |
17493 | 356 (when (gnus-cache-possibly-remove-article article nil nil nil t) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
357 (when gnus-newsgroup-agentized |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
358 (let ((alist (gnus-agent-load-alist gnus-newsgroup-name))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
359 (unless (cdr (assoc article alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
360 (setq gnus-newsgroup-undownloaded |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
361 (gnus-add-to-sorted-list |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
362 gnus-newsgroup-undownloaded article))))) |
17493 | 363 (push article out)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
364 (gnus-summary-update-download-mark article) |
17493 | 365 (gnus-summary-update-secondary-mark article)) |
366 (gnus-summary-next-subject 1) | |
367 (gnus-summary-position-point) | |
368 (nreverse out))) | |
369 | |
370 (defun gnus-cached-article-p (article) | |
371 "Say whether ARTICLE is cached in the current group." | |
372 (memq article gnus-newsgroup-cached)) | |
373 | |
374 (defun gnus-summary-insert-cached-articles () | |
375 "Insert all the articles cached for this group into the current buffer." | |
376 (interactive) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
377 (let ((gnus-verbose (max 6 gnus-verbose))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
378 (if (not gnus-newsgroup-cached) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
379 (gnus-message 3 "No cached articles for this group") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
380 (gnus-summary-goto-subjects gnus-newsgroup-cached)))) |
17493 | 381 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
382 (defun gnus-summary-limit-include-cached () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
383 "Limit the summary buffer to articles that are cached." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
384 (interactive) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
385 (let ((gnus-verbose (max 6 gnus-verbose))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
386 (if gnus-newsgroup-cached |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
387 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
388 (gnus-summary-limit gnus-newsgroup-cached) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
389 (gnus-summary-position-point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
390 (gnus-message 3 "No cached articles for this group")))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
391 |
17493 | 392 ;;; Internal functions. |
393 | |
394 (defun gnus-cache-change-buffer (group) | |
395 (and gnus-cache-buffer | |
396 ;; See if the current group's overview cache has been loaded. | |
397 (or (string= group (car gnus-cache-buffer)) | |
398 ;; Another overview cache is current, save it. | |
399 (gnus-cache-save-buffers))) | |
400 ;; if gnus-cache buffer is nil, create it | |
401 (unless gnus-cache-buffer | |
402 ;; Create cache buffer | |
403 (save-excursion | |
404 (setq gnus-cache-buffer | |
405 (cons group | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
406 (set-buffer (gnus-get-buffer-create |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
407 " *gnus-cache-overview*")))) |
17493 | 408 ;; Insert the contents of this group's cache overview. |
409 (erase-buffer) | |
410 (let ((file (gnus-cache-file-name group ".overview"))) | |
411 (when (file-exists-p file) | |
412 (nnheader-insert-file-contents file))) | |
413 ;; We have a fresh (empty/just loaded) buffer, | |
414 ;; mark it as unmodified to save a redundant write later. | |
415 (set-buffer-modified-p nil)))) | |
416 | |
417 ;; Return whether an article is a member of a class. | |
418 (defun gnus-cache-member-of-class (class ticked dormant unread) | |
419 (or (and ticked (memq 'ticked class)) | |
420 (and dormant (memq 'dormant class)) | |
421 (and unread (memq 'unread class)) | |
422 (and (not unread) (not ticked) (not dormant) (memq 'read class)))) | |
423 | |
424 (defun gnus-cache-file-name (group article) | |
61424
ad05d91d3598
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents:
59089
diff
changeset
|
425 (setq group (gnus-group-decoded-name group)) |
33379
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
426 (expand-file-name |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
427 (if (stringp article) article (int-to-string article)) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
428 (file-name-as-directory |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
429 (expand-file-name |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
430 (nnheader-translate-file-chars |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
431 (if (gnus-use-long-file-name 'not-cache) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
432 group |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
433 (let ((group (nnheader-replace-duplicate-chars-in-string |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
434 (nnheader-replace-chars-in-string group ?/ ?_) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
435 ?. ?_))) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
436 ;; Translate the first colon into a slash. |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
437 (when (string-match ":" group) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
438 (setq group (concat (substring group 0 (match-beginning 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
439 "/" (substring group (match-end 0))))) |
33379
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
440 (nnheader-replace-chars-in-string group ?. ?/))) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
441 t) |
33c4d154294b
(gnus-cache-active-file): Don't use
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
442 gnus-cache-directory)))) |
17493 | 443 |
444 (defun gnus-cache-update-article (group article) | |
445 "If ARTICLE is in the cache, remove it and re-enter it." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
446 (gnus-cache-change-buffer group) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
447 (when (gnus-cache-possibly-remove-article article nil nil nil t) |
17493 | 448 (let ((gnus-use-cache nil)) |
449 (gnus-cache-possibly-enter-article | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
450 gnus-newsgroup-name article |
17493 | 451 nil nil nil t)))) |
452 | |
453 (defun gnus-cache-possibly-remove-article (article ticked dormant unread | |
454 &optional force) | |
455 "Possibly remove ARTICLE from the cache." | |
456 (let ((group gnus-newsgroup-name) | |
457 (number article) | |
458 file) | |
459 ;; If this is a virtual group, we find the real group. | |
460 (when (gnus-virtual-group-p group) | |
461 (let ((result (nnvirtual-find-group-art | |
462 (gnus-group-real-name group) article))) | |
463 (setq group (car result) | |
464 number (cdr result)))) | |
465 (setq file (gnus-cache-file-name group number)) | |
466 (when (and (file-exists-p file) | |
467 (or force | |
468 (gnus-cache-member-of-class | |
469 gnus-cache-remove-articles ticked dormant unread))) | |
470 (save-excursion | |
471 (delete-file file) | |
472 (set-buffer (cdr gnus-cache-buffer)) | |
473 (goto-char (point-min)) | |
474 (when (or (looking-at (concat (int-to-string number) "\t")) | |
475 (search-forward (concat "\n" (int-to-string number) "\t") | |
476 (point-max) t)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
477 (gnus-delete-line))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
478 (unless (setq gnus-newsgroup-cached |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
479 (delq article gnus-newsgroup-cached)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
480 (gnus-sethash gnus-newsgroup-name nil gnus-cache-active-hashtb) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
481 (setq gnus-cache-active-altered t)) |
17493 | 482 (gnus-summary-update-secondary-mark article) |
483 t))) | |
484 | |
485 (defun gnus-cache-articles-in-group (group) | |
486 "Return a sorted list of cached articles in GROUP." | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
487 (let ((dir (file-name-directory (gnus-cache-file-name group 1))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
488 articles) |
17493 | 489 (when (file-exists-p dir) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
490 (setq articles |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
61424
diff
changeset
|
491 (sort (mapcar (lambda (name) (string-to-number name)) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
492 (directory-files dir nil "^[0-9]+$" t)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
493 '<)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
494 ;; Update the cache active file, just to synch more. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
495 (if articles |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
496 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
497 (gnus-cache-update-active group (car articles) t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
498 (gnus-cache-update-active group (car (last articles)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
499 (when (gnus-gethash group gnus-cache-active-hashtb) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
500 (gnus-sethash group nil gnus-cache-active-hashtb) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
501 (setq gnus-cache-active-altered t))) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
502 articles))) |
17493 | 503 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
504 (defun gnus-cache-braid-nov (group cached &optional file) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
505 (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*")) |
17493 | 506 beg end) |
507 (gnus-cache-save-buffers) | |
508 (save-excursion | |
509 (set-buffer cache-buf) | |
510 (erase-buffer) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33379
diff
changeset
|
511 (let ((coding-system-for-read |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
512 gnus-cache-overview-coding-system)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33379
diff
changeset
|
513 (insert-file-contents |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
514 (or file (gnus-cache-file-name group ".overview")))) |
17493 | 515 (goto-char (point-min)) |
516 (insert "\n") | |
517 (goto-char (point-min))) | |
518 (set-buffer nntp-server-buffer) | |
519 (goto-char (point-min)) | |
520 (while cached | |
521 (while (and (not (eobp)) | |
522 (< (read (current-buffer)) (car cached))) | |
523 (forward-line 1)) | |
524 (beginning-of-line) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
525 (set-buffer cache-buf) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
526 (if (search-forward (concat "\n" (int-to-string (car cached)) "\t") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
527 nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
528 (setq beg (gnus-point-at-bol) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
529 end (progn (end-of-line) (point))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
530 (setq beg nil)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
531 (set-buffer nntp-server-buffer) |
17493 | 532 (when beg |
533 (insert-buffer-substring cache-buf beg end) | |
534 (insert "\n")) | |
535 (setq cached (cdr cached))) | |
536 (kill-buffer cache-buf))) | |
537 | |
538 (defun gnus-cache-braid-heads (group cached) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
539 (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*"))) |
17493 | 540 (save-excursion |
541 (set-buffer cache-buf) | |
542 (erase-buffer)) | |
543 (set-buffer nntp-server-buffer) | |
544 (goto-char (point-min)) | |
545 (while cached | |
546 (while (and (not (eobp)) | |
547 (looking-at "2.. +\\([0-9]+\\) ") | |
548 (< (progn (goto-char (match-beginning 1)) | |
549 (read (current-buffer))) | |
550 (car cached))) | |
551 (search-forward "\n.\n" nil 'move)) | |
552 (beginning-of-line) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
553 (set-buffer cache-buf) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
554 (erase-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
555 (let ((coding-system-for-read |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
556 gnus-cache-coding-system)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
557 (insert-file-contents (gnus-cache-file-name group (car cached)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
558 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
559 (insert "220 ") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
560 (princ (car cached) (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
561 (insert " Article retrieved.\n") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
562 (search-forward "\n\n" nil 'move) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
563 (delete-region (point) (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
564 (forward-char -1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
565 (insert ".") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
566 (set-buffer nntp-server-buffer) |
17493 | 567 (insert-buffer-substring cache-buf) |
568 (setq cached (cdr cached))) | |
569 (kill-buffer cache-buf))) | |
570 | |
571 ;;;###autoload | |
572 (defun gnus-jog-cache () | |
573 "Go through all groups and put the articles into the cache. | |
574 | |
575 Usage: | |
576 $ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache" | |
577 (interactive) | |
578 (let ((gnus-mark-article-hook nil) | |
579 (gnus-expert-user t) | |
580 (nnmail-spool-file nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
581 (mail-sources nil) |
17493 | 582 (gnus-use-dribble-file nil) |
583 (gnus-novice-user nil) | |
584 (gnus-large-newsgroup nil)) | |
585 ;; Start Gnus. | |
586 (gnus) | |
587 ;; Go through all groups... | |
588 (gnus-group-mark-buffer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
589 (gnus-group-iterate nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
590 (lambda (group) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
591 (let (gnus-auto-select-next) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
592 (gnus-summary-read-group group nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
593 ;; ... and enter the articles into the cache. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
594 (when (eq major-mode 'gnus-summary-mode) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
595 (gnus-uu-mark-buffer) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
596 (gnus-cache-enter-article) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
597 (kill-buffer (current-buffer)))))))) |
17493 | 598 |
599 (defun gnus-cache-read-active (&optional force) | |
600 "Read the cache active file." | |
601 (gnus-make-directory gnus-cache-directory) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
602 (if (or (not (file-exists-p gnus-cache-active-file)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
603 (zerop (nth 7 (file-attributes gnus-cache-active-file))) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
604 force) |
17493 | 605 ;; There is no active file, so we generate one. |
606 (gnus-cache-generate-active) | |
607 ;; We simply read the active file. | |
608 (save-excursion | |
609 (gnus-set-work-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
610 (nnheader-insert-file-contents gnus-cache-active-file) |
17493 | 611 (gnus-active-to-gnus-format |
612 nil (setq gnus-cache-active-hashtb | |
613 (gnus-make-hashtable | |
614 (count-lines (point-min) (point-max))))) | |
615 (setq gnus-cache-active-altered nil)))) | |
616 | |
617 (defun gnus-cache-write-active (&optional force) | |
618 "Write the active hashtb to the active file." | |
619 (when (or force | |
620 (and gnus-cache-active-hashtb | |
621 gnus-cache-active-altered)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
622 (gnus-write-active-file gnus-cache-active-file gnus-cache-active-hashtb t) |
17493 | 623 ;; Mark the active hashtb as unaltered. |
624 (setq gnus-cache-active-altered nil))) | |
625 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
626 (defun gnus-cache-possibly-update-active (group active) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
627 "Update active info bounds of GROUP with ACTIVE if necessary. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
628 The update is performed if ACTIVE contains a higher or lower bound |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
629 than the current." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
630 (let ((lower t) (higher t)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
631 (if gnus-cache-active-hashtb |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
632 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
633 (when cache-active |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
634 (unless (< (car active) (car cache-active)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
635 (setq lower nil)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
636 (unless (> (cdr active) (cdr cache-active)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
637 (setq higher nil)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
638 (gnus-cache-read-active)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
639 (when lower |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
640 (gnus-cache-update-active group (car active) t)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
641 (when higher |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
642 (gnus-cache-update-active group (cdr active))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
643 |
17493 | 644 (defun gnus-cache-update-active (group number &optional low) |
645 "Update the upper bound of the active info of GROUP to NUMBER. | |
646 If LOW, update the lower bound instead." | |
647 (let ((active (gnus-gethash group gnus-cache-active-hashtb))) | |
648 (if (null active) | |
649 ;; We just create a new active entry for this group. | |
650 (gnus-sethash group (cons number number) gnus-cache-active-hashtb) | |
651 ;; Update the lower or upper bound. | |
652 (if low | |
653 (setcar active number) | |
654 (setcdr active number))) | |
655 ;; Mark the active hashtb as altered. | |
656 (setq gnus-cache-active-altered t))) | |
657 | |
658 ;;;###autoload | |
659 (defun gnus-cache-generate-active (&optional directory) | |
660 "Generate the cache active file." | |
661 (interactive) | |
662 (let* ((top (null directory)) | |
663 (directory (expand-file-name (or directory gnus-cache-directory))) | |
664 (files (directory-files directory 'full)) | |
665 (group | |
666 (if top | |
667 "" | |
668 (string-match | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
669 (concat "^" (regexp-quote |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
670 (file-name-as-directory |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
671 (expand-file-name gnus-cache-directory)))) |
17493 | 672 (directory-file-name directory)) |
673 (nnheader-replace-chars-in-string | |
674 (substring (directory-file-name directory) (match-end 0)) | |
675 ?/ ?.))) | |
676 nums alphs) | |
677 (when top | |
678 (gnus-message 5 "Generating the cache active file...") | |
679 (setq gnus-cache-active-hashtb (gnus-make-hashtable 123))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
680 (when (string-match "^\\(nn[^_]+\\)_" group) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
681 (setq group (replace-match "\\1:" t nil group))) |
17493 | 682 ;; Separate articles from all other files and directories. |
683 (while files | |
684 (if (string-match "^[0-9]+$" (file-name-nondirectory (car files))) | |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
61424
diff
changeset
|
685 (push (string-to-number (file-name-nondirectory (pop files))) nums) |
17493 | 686 (push (pop files) alphs))) |
687 ;; If we have nums, then this is probably a valid group. | |
688 (when (setq nums (sort nums '<)) | |
689 (gnus-sethash group (cons (car nums) (gnus-last-element nums)) | |
690 gnus-cache-active-hashtb)) | |
691 ;; Go through all the other files. | |
692 (while alphs | |
693 (when (and (file-directory-p (car alphs)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
694 (not (string-match "^\\." |
17493 | 695 (file-name-nondirectory (car alphs))))) |
696 ;; We descend directories. | |
697 (gnus-cache-generate-active (car alphs))) | |
698 (setq alphs (cdr alphs))) | |
699 ;; Write the new active file. | |
700 (when top | |
701 (gnus-cache-write-active t) | |
702 (gnus-message 5 "Generating the cache active file...done")))) | |
703 | |
704 ;;;###autoload | |
705 (defun gnus-cache-generate-nov-databases (dir) | |
706 "Generate NOV files recursively starting in DIR." | |
707 (interactive (list gnus-cache-directory)) | |
708 (gnus-cache-close) | |
709 (let ((nnml-generate-active-function 'identity)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
710 (nnml-generate-nov-databases-1 dir)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
711 (gnus-cache-open)) |
17493 | 712 |
713 (defun gnus-cache-move-cache (dir) | |
714 "Move the cache tree to somewhere else." | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
715 (interactive "FMove the cache tree to: ") |
17493 | 716 (rename-file gnus-cache-directory dir)) |
717 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
718 (defun gnus-cache-fully-p (&optional group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
719 "Returns non-nil if the cache should be fully used. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
720 If GROUP is non-nil, also cater to `gnus-cacheable-groups' and |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
721 `gnus-uncacheable-groups'." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
722 (and gnus-use-cache |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
723 (not (eq gnus-use-cache 'passive)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
724 (if (null group) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
725 t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
726 (and (or (not gnus-cacheable-groups) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
727 (string-match gnus-cacheable-groups group)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
728 (or (not gnus-uncacheable-groups) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
729 (not (string-match gnus-uncacheable-groups group))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
730 |
57617
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
731 ;;;###autoload |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
732 (defun gnus-cache-rename-group (old-group new-group) |
67418
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
733 "Rename OLD-GROUP as NEW-GROUP. |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
734 Always updates the cache, even when disabled, as the old cache |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
735 files would corrupt Gnus when the cache was next enabled. It |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
736 depends on the caller to determine whether group renaming is |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
737 supported." |
57617
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
738 (let ((old-dir (gnus-cache-file-name old-group "")) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
739 (new-dir (gnus-cache-file-name new-group ""))) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
740 (gnus-rename-file old-dir new-dir t)) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
741 |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
742 (let ((no-save gnus-cache-active-hashtb)) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
743 (unless gnus-cache-active-hashtb |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
744 (gnus-cache-read-active)) |
67418
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
745 (let* ((old-group-hash-value |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
746 (gnus-gethash old-group gnus-cache-active-hashtb)) |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
747 (new-group-hash-value |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
748 (gnus-gethash new-group gnus-cache-active-hashtb)) |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
749 (delta |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
750 (or old-group-hash-value new-group-hash-value))) |
57617
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
751 (gnus-sethash new-group old-group-hash-value gnus-cache-active-hashtb) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
752 (gnus-sethash old-group nil gnus-cache-active-hashtb) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
753 |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
754 (if no-save |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
755 (setq gnus-cache-active-altered delta) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
756 (gnus-cache-write-active delta))))) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
757 |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
758 ;;;###autoload |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
759 (defun gnus-cache-delete-group (group) |
67418
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
760 "Delete GROUP from the cache. |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
761 Always updates the cache, even when disabled, as the old cache |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
762 files would corrupt gnus when the cache was next enabled. |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
763 Depends upon the caller to determine whether group deletion is |
28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
764 supported." |
57617
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
765 (let ((dir (gnus-cache-file-name group ""))) |
59089
22da0004ae3c
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents:
57617
diff
changeset
|
766 (gnus-delete-directory dir)) |
57617
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
767 |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
768 (let ((no-save gnus-cache-active-hashtb)) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
769 (unless gnus-cache-active-hashtb |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
770 (gnus-cache-read-active)) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
771 (let* ((group-hash-value (gnus-gethash group gnus-cache-active-hashtb))) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
772 (gnus-sethash group nil gnus-cache-active-hashtb) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
773 |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
774 (if no-save |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
775 (setq gnus-cache-active-altered group-hash-value) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
776 (gnus-cache-write-active group-hash-value))))) |
7fdc1df35f39
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
777 |
17493 | 778 (provide 'gnus-cache) |
779 | |
52401 | 780 ;;; arch-tag: 05a79442-8c58-4e65-bd0a-3cbb1b89a33a |
17493 | 781 ;;; gnus-cache.el ends here |