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