;;; gnus-cache.el --- cache interface for Gnus
-;; Copyright (C) 1995,96 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
;; Keywords: news
(require 'gnus)
(require 'gnus-int)
(require 'gnus-range)
-(require 'gnus-sum)
(require 'gnus-start)
+(eval-when-compile
+ (require 'gnus-sum))
(defgroup gnus-cache nil
"Cache interface."
:group 'gnus-cache
:type 'directory)
-(defcustom gnus-cache-active-file
+(defcustom gnus-cache-active-file
(concat (file-name-as-directory gnus-cache-directory) "active")
"*The cache active file."
:group 'gnus-cache
(gnus-kill-buffer buffer)
(setq gnus-cache-buffer nil))))
-(defun gnus-cache-possibly-enter-article
+(defun gnus-cache-possibly-enter-article
(group article headers ticked dormant unread &optional force)
(when (and (or force (not (eq gnus-use-cache 'passive)))
(numberp article)
; This might be a dummy article.
;; If this is a virtual group, we find the real group.
(when (gnus-virtual-group-p group)
- (let ((result (nnvirtual-find-group-art
+ (let ((result (nnvirtual-find-group-art
(gnus-group-real-name group) article)))
(setq group (car result)
headers (copy-sequence headers))
(when (equal group "no.norsk") (error "hie"))
(when gnus-cache-active-hashtb
(let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
- (and cache-active
+ (and cache-active
(< (car cache-active) (car active))
(setcar active (car cache-active)))
(and cache-active
(defun gnus-cache-retrieve-headers (articles group &optional fetch-old)
"Retrieve the headers for ARTICLES in GROUP."
- (let ((cached
+ (let ((cached
(setq gnus-newsgroup-cached (gnus-cache-articles-in-group group))))
(if (not cached)
;; No cached articles here, so we just retrieve them
articles))
(cache-file (gnus-cache-file-name group ".overview"))
type)
- ;; We first retrieve all the headers that we don't have in
+ ;; We first retrieve all the headers that we don't have in
;; the cache.
(let ((gnus-use-cache nil))
(when uncached-articles
- (setq type (and articles
- (gnus-retrieve-headers
+ (setq type (and articles
+ (gnus-retrieve-headers
uncached-articles group fetch-old)))))
(gnus-cache-save-buffers)
;; Then we insert the cached headers.
;; There are no cached headers.
type)
((null type)
- ;; There were no uncached headers (or retrieval was
+ ;; There were no uncached headers (or retrieval was
;; unsuccessful), so we use the cached headers exclusively.
(set-buffer nntp-server-buffer)
(erase-buffer)
article out)
(while (setq article (pop articles))
(if (natnump article)
- (when (gnus-cache-possibly-enter-article
- gnus-newsgroup-name article
+ (when (gnus-cache-possibly-enter-article
+ gnus-newsgroup-name article
(gnus-summary-article-header article)
nil nil nil t)
(push article out))
(let ((file (gnus-cache-file-name group ".overview")))
(when (file-exists-p file)
(nnheader-insert-file-contents file)))
- ;; We have a fresh (empty/just loaded) buffer,
+ ;; We have a fresh (empty/just loaded) buffer,
;; mark it as unmodified to save a redundant write later.
(set-buffer-modified-p nil))))
"If ARTICLE is in the cache, remove it and re-enter it."
(when (gnus-cache-possibly-remove-article article nil nil nil t)
(let ((gnus-use-cache nil))
- (gnus-cache-possibly-enter-article
+ (gnus-cache-possibly-enter-article
gnus-newsgroup-name article (gnus-summary-article-header article)
nil nil nil t))))
-(defun gnus-cache-possibly-remove-article (article ticked dormant unread
+(defun gnus-cache-possibly-remove-article (article ticked dormant unread
&optional force)
"Possibly remove ARTICLE from the cache."
(let ((group gnus-newsgroup-name)
file)
;; If this is a virtual group, we find the real group.
(when (gnus-virtual-group-p group)
- (let ((result (nnvirtual-find-group-art
+ (let ((result (nnvirtual-find-group-art
(gnus-group-real-name group) article)))
(setq group (car result)
number (cdr result))))
(gnus)
;; Go through all groups...
(gnus-group-mark-buffer)
- (gnus-group-universal-argument
- nil nil
+ (gnus-group-universal-argument
+ nil nil
(lambda ()
(interactive)
(gnus-summary-read-group (gnus-group-group-name) nil t)
(gnus-set-work-buffer)
(insert-file-contents gnus-cache-active-file)
(gnus-active-to-gnus-format
- nil (setq gnus-cache-active-hashtb
- (gnus-make-hashtable
+ nil (setq gnus-cache-active-hashtb
+ (gnus-make-hashtable
(count-lines (point-min) (point-max)))))
(setq gnus-cache-active-altered nil))))
-
+
(defun gnus-cache-write-active (&optional force)
"Write the active hashtb to the active file."
(when (or force
(let* ((top (null directory))
(directory (expand-file-name (or directory gnus-cache-directory)))
(files (directory-files directory 'full))
- (group
+ (group
(if top
""
- (string-match
+ (string-match
(concat "^" (file-name-as-directory
(expand-file-name gnus-cache-directory)))
(directory-file-name directory))
- (nnheader-replace-chars-in-string
+ (nnheader-replace-chars-in-string
(substring (directory-file-name directory) (match-end 0))
?/ ?.)))
nums alphs)
(rename-file gnus-cache-directory dir))
(provide 'gnus-cache)
-
+
;;; gnus-cache.el ends here