Mercurial > hg > xemacs-beta
comparison lisp/gnus/gnus-cache.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 0293115a14e9 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
64 | 64 |
65 ;;; Functions called from Gnus. | 65 ;;; Functions called from Gnus. |
66 | 66 |
67 (defun gnus-cache-open () | 67 (defun gnus-cache-open () |
68 "Initialize the cache." | 68 "Initialize the cache." |
69 (gnus-cache-read-active)) | 69 (when (or (file-exists-p gnus-cache-directory) |
70 | 70 (and gnus-use-cache |
71 (gnus-add-shutdown 'gnus-cache-close 'gnus) | 71 (not (eq gnus-use-cache 'passive)))) |
72 (gnus-cache-read-active))) | |
73 | |
74 (condition-case () | |
75 (gnus-add-shutdown 'gnus-cache-close 'gnus) | |
76 ;; Complexities of byte-compiling makes this kludge necessary. Eeek. | |
77 (error nil)) | |
72 | 78 |
73 (defun gnus-cache-close () | 79 (defun gnus-cache-close () |
74 "Shut down the cache." | 80 "Shut down the cache." |
75 (gnus-cache-write-active) | 81 (gnus-cache-write-active) |
76 (gnus-cache-save-buffers) | 82 (gnus-cache-save-buffers) |
231 (insert-file-contents file) | 237 (insert-file-contents file) |
232 t))) | 238 t))) |
233 | 239 |
234 (defun gnus-cache-possibly-alter-active (group active) | 240 (defun gnus-cache-possibly-alter-active (group active) |
235 "Alter the ACTIVE info for GROUP to reflect the articles in the cache." | 241 "Alter the ACTIVE info for GROUP to reflect the articles in the cache." |
236 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) | 242 (when gnus-cache-active-hashtb |
237 (and cache-active | 243 (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) |
238 (< (car cache-active) (car active)) | 244 (and cache-active |
239 (setcar active (car cache-active))) | 245 (< (car cache-active) (car active)) |
240 (and cache-active | 246 (setcar active (car cache-active))) |
241 (> (cdr cache-active) (cdr active)) | 247 (and cache-active |
242 (setcdr active (cdr cache-active))))) | 248 (> (cdr cache-active) (cdr active)) |
249 (setcdr active (cdr cache-active)))))) | |
243 | 250 |
244 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old) | 251 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old) |
245 "Retrieve the headers for ARTICLES in GROUP." | 252 "Retrieve the headers for ARTICLES in GROUP." |
246 (let ((cached | 253 (let ((cached |
247 (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group)))) | 254 (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group)))) |
365 (defun gnus-cache-file-name (group article) | 372 (defun gnus-cache-file-name (group article) |
366 (concat (file-name-as-directory gnus-cache-directory) | 373 (concat (file-name-as-directory gnus-cache-directory) |
367 (file-name-as-directory | 374 (file-name-as-directory |
368 (if (gnus-use-long-file-name 'not-cache) | 375 (if (gnus-use-long-file-name 'not-cache) |
369 group | 376 group |
370 (let ((group (concat group ""))) | 377 (let ((group (nnheader-replace-chars-in-string group ?/ ?_))) |
371 (if (string-match ":" group) | 378 ;; Translate the first colon into a slash. |
372 (aset group (match-beginning 0) ?/)) | 379 (when (string-match ":" group) |
380 (aset group (match-beginning 0) ?/)) | |
373 (nnheader-replace-chars-in-string group ?. ?/)))) | 381 (nnheader-replace-chars-in-string group ?. ?/)))) |
374 (if (stringp article) article (int-to-string article)))) | 382 (if (stringp article) article (int-to-string article)))) |
375 | 383 |
376 (defun gnus-cache-update-article (group article) | 384 (defun gnus-cache-update-article (group article) |
377 "If ARTICLE is in the cache, remove it and re-enter it." | 385 "If ARTICLE is in the cache, remove it and re-enter it." |