diff options
Diffstat (limited to 'lisp/gnus/gnus-cache.el')
-rw-r--r-- | lisp/gnus/gnus-cache.el | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el index a30ae38abb6..afe8a8a416c 100644 --- a/lisp/gnus/gnus-cache.el +++ b/lisp/gnus/gnus-cache.el @@ -24,7 +24,7 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(eval-when-compile (require 'cl-lib)) (require 'gnus) (require 'gnus-sum) @@ -187,9 +187,9 @@ it's not cached." (setq lines-chars (nnheader-get-lines-and-char)) (nnheader-remove-body) (setq headers (nnheader-parse-naked-head)) - (mail-header-set-number headers number) - (mail-header-set-lines headers (car lines-chars)) - (mail-header-set-chars headers (cadr lines-chars)) + (setf (mail-header-number headers) number) + (setf (mail-header-lines headers) (car lines-chars)) + (setf (mail-header-chars headers) (cadr lines-chars)) (gnus-cache-change-buffer group) (set-buffer (cdr gnus-cache-buffer)) (goto-char (point-max)) @@ -272,7 +272,7 @@ it's not cached." (defun gnus-cache-possibly-alter-active (group active) "Alter the ACTIVE info for GROUP to reflect the articles in the cache." (when gnus-cache-active-hashtb - (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) + (let ((cache-active (gethash group gnus-cache-active-hashtb))) (when cache-active (when (< (car cache-active) (car active)) (setcar active (car cache-active))) @@ -522,7 +522,7 @@ system for example was used.") (gnus-delete-line))) (unless (setq gnus-newsgroup-cached (delq article gnus-newsgroup-cached)) - (gnus-sethash gnus-newsgroup-name nil gnus-cache-active-hashtb) + (remhash gnus-newsgroup-name gnus-cache-active-hashtb) (setq gnus-cache-active-altered t)) (gnus-summary-update-secondary-mark article) t))) @@ -542,8 +542,8 @@ system for example was used.") (progn (gnus-cache-update-active group (car articles) t) (gnus-cache-update-active group (car (last articles)))) - (when (gnus-gethash group gnus-cache-active-hashtb) - (gnus-sethash group nil gnus-cache-active-hashtb) + (when (gethash group gnus-cache-active-hashtb) + (remhash group gnus-cache-active-hashtb) (setq gnus-cache-active-altered t))) articles))) @@ -642,7 +642,8 @@ $ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache" "Read the cache active file." (gnus-make-directory gnus-cache-directory) (if (or (not (file-exists-p gnus-cache-active-file)) - (zerop (nth 7 (file-attributes gnus-cache-active-file))) + (zerop (file-attribute-size + (file-attributes gnus-cache-active-file))) force) ;; There is no active file, so we generate one. (gnus-cache-generate-active) @@ -665,13 +666,16 @@ $ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache" ;; Mark the active hashtb as unaltered. (setq gnus-cache-active-altered nil))) +;; FIXME: Why is there a `gnus-cache-possibly-alter-active', +;; `gnus-cache-possibly-update-active', and +;; `gnus-cache-update-active'? Do we really need all three? (defun gnus-cache-possibly-update-active (group active) "Update active info bounds of GROUP with ACTIVE if necessary. The update is performed if ACTIVE contains a higher or lower bound than the current." (let ((lower t) (higher t)) (if gnus-cache-active-hashtb - (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb))) + (let ((cache-active (gethash group gnus-cache-active-hashtb))) (when cache-active (unless (< (car active) (car cache-active)) (setq lower nil)) @@ -686,10 +690,10 @@ than the current." (defun gnus-cache-update-active (group number &optional low) "Update the upper bound of the active info of GROUP to NUMBER. If LOW, update the lower bound instead." - (let ((active (gnus-gethash group gnus-cache-active-hashtb))) + (let ((active (gethash group gnus-cache-active-hashtb))) (if (null active) ;; We just create a new active entry for this group. - (gnus-sethash group (cons number number) gnus-cache-active-hashtb) + (puthash group (cons number number) gnus-cache-active-hashtb) ;; Update the lower or upper bound. (if low (setcar active number) @@ -733,10 +737,10 @@ If LOW, update the lower bound instead." ;; FIXME: this is kind of a workaround. The active file should ;; be updated at the time articles are cached. It will make ;; `gnus-cache-unified-group-names' needless. - (gnus-sethash (or (cdr (assoc group gnus-cache-unified-group-names)) - group) - (cons (car nums) (gnus-last-element nums)) - gnus-cache-active-hashtb)) + (puthash (or (cdr (assoc group gnus-cache-unified-group-names)) + group) + (cons (car nums) (car (last nums))) + gnus-cache-active-hashtb)) ;; Go through all the other files. (dolist (file alphs) (when (and (file-directory-p file) @@ -797,13 +801,13 @@ supported." (unless gnus-cache-active-hashtb (gnus-cache-read-active)) (let* ((old-group-hash-value - (gnus-gethash old-group gnus-cache-active-hashtb)) + (gethash old-group gnus-cache-active-hashtb)) (new-group-hash-value - (gnus-gethash new-group gnus-cache-active-hashtb)) + (gethash new-group gnus-cache-active-hashtb)) (delta (or old-group-hash-value new-group-hash-value))) - (gnus-sethash new-group old-group-hash-value gnus-cache-active-hashtb) - (gnus-sethash old-group nil gnus-cache-active-hashtb) + (puthash new-group old-group-hash-value gnus-cache-active-hashtb) + (puthash old-group nil gnus-cache-active-hashtb) (if no-save (setq gnus-cache-active-altered delta) @@ -825,8 +829,8 @@ supported." (let ((no-save gnus-cache-active-hashtb)) (unless gnus-cache-active-hashtb (gnus-cache-read-active)) - (let* ((group-hash-value (gnus-gethash group gnus-cache-active-hashtb))) - (gnus-sethash group nil gnus-cache-active-hashtb) + (let* ((group-hash-value (gethash group gnus-cache-active-hashtb))) + (remhash group gnus-cache-active-hashtb) (if no-save (setq gnus-cache-active-altered group-hash-value) @@ -848,13 +852,13 @@ supported." (when gnus-cache-total-fetched-hashtb (gnus-cache-with-refreshed-group group - (let* ((entry (or (gnus-gethash group gnus-cache-total-fetched-hashtb) - (gnus-sethash group (make-vector 2 0) - gnus-cache-total-fetched-hashtb))) + (let* ((entry (or (gethash group gnus-cache-total-fetched-hashtb) + (puthash group (make-vector 2 0) + gnus-cache-total-fetched-hashtb))) size) (if file - (setq size (or (nth 7 (file-attributes file)) 0)) + (setq size (or (file-attribute-size (file-attributes file)) 0)) (let* ((file-name-coding-system nnmail-pathname-coding-system) (files (directory-files (gnus-cache-file-name group "") t nil t)) @@ -862,22 +866,22 @@ supported." (setq size 0.0) (while (setq file (pop files)) (setq attrs (file-attributes file)) - (unless (nth 0 attrs) - (incf size (float (nth 7 attrs))))))) + (unless (file-attribute-type attrs) + (cl-incf size (float (file-attribute-size attrs))))))) (setq gnus-cache-need-update-total-fetched-for t) - (incf (nth 1 entry) (if subtract (- size) size)))))) + (cl-incf (nth 1 entry) (if subtract (- size) size)))))) (defun gnus-cache-update-overview-total-fetched-for (group file) (when gnus-cache-total-fetched-hashtb (gnus-cache-with-refreshed-group group - (let* ((entry (or (gnus-gethash group gnus-cache-total-fetched-hashtb) - (gnus-sethash group (make-list 2 0) + (let* ((entry (or (gethash group gnus-cache-total-fetched-hashtb) + (puthash group (make-list 2 0) gnus-cache-total-fetched-hashtb))) (file-name-coding-system nnmail-pathname-coding-system) - (size (or (nth 7 (file-attributes + (size (or (file-attribute-size (file-attributes (or file (gnus-cache-file-name group ".overview")))) 0))) @@ -887,22 +891,21 @@ supported." (defun gnus-cache-rename-group-total-fetched-for (old-group new-group) "Record of disk space used by OLD-GROUP now associated with NEW-GROUP." (when gnus-cache-total-fetched-hashtb - (let ((entry (gnus-gethash old-group gnus-cache-total-fetched-hashtb))) - (gnus-sethash new-group entry gnus-cache-total-fetched-hashtb) - (gnus-sethash old-group nil gnus-cache-total-fetched-hashtb)))) + (let ((entry (gethash old-group gnus-cache-total-fetched-hashtb))) + (puthash new-group entry gnus-cache-total-fetched-hashtb) + (remhash old-group gnus-cache-total-fetched-hashtb)))) (defun gnus-cache-delete-group-total-fetched-for (group) "Delete record of disk space used by GROUP being deleted." (when gnus-cache-total-fetched-hashtb - (gnus-sethash group nil gnus-cache-total-fetched-hashtb))) + (remhash group gnus-cache-total-fetched-hashtb))) (defun gnus-cache-total-fetched-for (group &optional no-inhibit) "Get total disk space used by the cache for the specified GROUP." (unless (equal group "dummy.group") (unless gnus-cache-total-fetched-hashtb - (setq gnus-cache-total-fetched-hashtb (gnus-make-hashtable 1024))) - - (let* ((entry (gnus-gethash group gnus-cache-total-fetched-hashtb))) + (setq gnus-cache-total-fetched-hashtb (gnus-make-hashtable 1000))) + (let* ((entry (gethash group gnus-cache-total-fetched-hashtb))) (if entry (apply '+ entry) (let ((gnus-cache-inhibit-update-total-fetched-for (not no-inhibit))) |