"Load FILE and do a `read' there."
(with-temp-buffer
(ignore-errors
- (nnheader-insert-file-contents file)
+ (mm-insert-file-contents file)
(goto-char (point-min))
(read (current-buffer)))))
;;;
(defun gnus-agent-save-active (method)
+ (gnus-agent-save-active-1 method 'gnus-active-to-gnus-format))
+
+(defun gnus-agent-save-active-1 (method function)
(when (gnus-agent-method-p method)
(let* ((gnus-command-method method)
+ (new (gnus-make-hashtable (count-lines (point-min) (point-max))))
(file (gnus-agent-lib-file "active")))
- (gnus-make-directory (file-name-directory file))
- (let ((coding-system-for-write gnus-agent-file-coding-system))
- (write-region (point-min) (point-max) file nil 'silent))
- (when (file-exists-p (gnus-agent-lib-file "groups"))
- (delete-file (gnus-agent-lib-file "groups"))))))
-
-(defun gnus-agent-save-groups (method)
- (let* ((gnus-command-method method)
- (file (gnus-agent-lib-file "groups")))
+ (funcall function nil new)
+ (gnus-agent-write-active file new)
+ (erase-buffer)
+ (insert-file-contents-literally file))))
+
+(defun gnus-agent-write-active (file new)
+ (let ((orig (gnus-make-hashtable (count-lines (point-min) (point-max))))
+ (file (gnus-agent-lib-file "active"))
+ elem)
+ (when (file-exists-p file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (gnus-active-to-gnus-format nil orig))
+ (mapatoms
+ (lambda (sym)
+ (when (and sym (boundp sym))
+ (if (setq elem (symbol-value (intern (symbol-name sym) orig)))
+ (setcdr elem (cdr (symbol-value sym)))
+ (set (intern (symbol-name sym) orig) (symbol-value sym)))))
+ new))
(gnus-make-directory (file-name-directory file))
(let ((coding-system-for-write gnus-agent-file-coding-system))
- (write-region (point-min) (point-max) file nil 'silent))
- (when (file-exists-p (gnus-agent-lib-file "active"))
- (delete-file (gnus-agent-lib-file "active")))))
+ (gnus-write-active-file file orig))))
+
+(defun gnus-agent-save-groups (method)
+ (gnus-agent-save-active-1 method 'gnus-groups-to-gnus-format))
(defun gnus-agent-save-group-info (method group active)
(when (gnus-agent-method-p method)
(let* ((gnus-command-method method)
- (file (if nntp-server-list-active-group
- (gnus-agent-lib-file "active")
- (gnus-agent-lib-file "groups"))))
+ (file (gnus-agent-lib-file "active")))
(gnus-make-directory (file-name-directory file))
(with-temp-file file
(when (file-exists-p file)
- (nnheader-insert-file-contents file))
+ (mm-insert-file-contents file))
(goto-char (point-min))
- (if nntp-server-list-active-group
- (progn
- (when (re-search-forward
- (concat "^" (regexp-quote group) " ") nil t)
- (gnus-delete-line))
- (insert group " " (number-to-string (cdr active)) " "
- (number-to-string (car active)) " y\n"))
- (when (re-search-forward
- (concat (regexp-quote group) "\\($\\| \\)") nil t)
- (gnus-delete-line))
- (insert-buffer-substring nntp-server-buffer))))))
+ (when (re-search-forward
+ (concat "^" (regexp-quote group) " ") nil t)
+ (gnus-delete-line))
+ (insert group " " (number-to-string (cdr active)) " "
+ (number-to-string (car active)) " y\n")))))
(defun gnus-agent-group-path (group)
"Translate GROUP into a path."
(when (= (point-max) (point-min))
(push (cons group (current-buffer)) gnus-agent-buffer-alist)
(ignore-errors
- (nnheader-insert-file-contents
+ (mm-insert-file-contents
(gnus-agent-article-name ".overview" group))))
(nnheader-find-nov-line (string-to-number (cdar crosses)))
(insert (string-to-number (cdar crosses)))
(goto-char (point-min))
(set-buffer nntp-server-buffer)
(erase-buffer)
- (nnheader-insert-file-contents file)
+ (mm-insert-file-contents file)
(goto-char (point-max))
(if (or (= (point-min) (point-max))
(progn
(day (- (time-to-days (current-time)) gnus-agent-expire-days))
gnus-command-method sym group articles
history overview file histories elem art nov-file low info
- unreads marked article)
+ unreads marked article orig lowest highest)
(save-excursion
+ (with-temp-buffer
+ (insert-file-contents file)
+ (gnus-active-to-gnus-format
+ nil (setq orig (gnus-make-hashtable
+ (count-lines (point-min) (point-max))))))
(setq overview (gnus-get-buffer-create " *expire overview*"))
(while (setq gnus-command-method (pop methods))
(let ((expiry-hashtb (gnus-make-hashtable 1023)))
(gnus-uncompress-range
(cdr (assq 'dormant
(gnus-info-marks info)))))
- nov-file (gnus-agent-article-name ".overview" group))
+ nov-file (gnus-agent-article-name ".overview" group)
+ lowest nil
+ highest nil)
(gnus-agent-load-alist group)
(gnus-message 5 "Expiring articles in %s" group)
(set-buffer overview)
(erase-buffer)
(when (file-exists-p nov-file)
- (nnheader-insert-file-contents nov-file))
+ (mm-insert-file-contents nov-file))
(goto-char (point-min))
(setq article 0)
(while (setq elem (pop articles))
(if (file-exists-p
(gnus-agent-article-name
(number-to-string art) group))
- (forward-line 1)
+ (progn
+ (unless lowest
+ (setq lowest art))
+ (setq highest art)
+ (forward-line 1))
;; Remove old NOV lines that have no articles.
(gnus-delete-line)))
(if (or (eobp)
(gnus-dribble-enter
(concat "(gnus-group-set-info '"
(gnus-prin1-to-string info)
- ")"))))
+ ")")))
+ (when lowest
+ (if (gnus-gethash group orig)
+ (setcar (gnus-gethash group orig) lowest)
+ (gnus-sethash group (cons lowest highest) orig))))
expiry-hashtb)
(set-buffer history)
(setq histories (nreverse (sort histories '<)))
(goto-char (pop histories))
(gnus-delete-line))
(gnus-agent-save-history)
- (gnus-agent-close-history))
+ (gnus-agent-close-history)
+ (gnus-write-active-file
+ (gnus-agent-lib-file "active") orig))
(gnus-message 4 "Expiry...done"))))))
;;;###autoload