*** empty log message ***
[gnus] / lisp / gnus-agent.el
index aaeb1cb..12efc52 100644 (file)
@@ -535,7 +535,8 @@ the actual number of articles toggled is returned."
           (file (gnus-agent-lib-file "active")))
       (gnus-make-directory (file-name-directory file))
       (nnheader-temp-write file
-       (insert-file-contents file)
+       (when (file-exists-p file)
+         (insert-file-contents file))
        (goto-char (point-min))
        (when (re-search-forward (concat "^" (regexp-quote group) " ") nil t)
          (gnus-delete-line))
@@ -769,8 +770,11 @@ the actual number of articles toggled is returned."
          (gnus-make-directory (nnheader-translate-file-chars
                                (file-name-directory file)))
          (write-region (point-min) (point-max) file nil 'silent)
-         (gnus-agent-save-alist group articles nil))
-       t))))
+         (gnus-agent-save-alist group articles nil)
+         (gnus-agent-enter-history "last-header-fetched-for-session"
+                                   (list (cons group (nth (- (length  articles) 1) articles)))
+                                   (gnus-time-to-day (current-time)))
+       t)))))
 
 (defsubst gnus-agent-copy-nov-line (article)
   (let (b e)
@@ -1254,13 +1258,13 @@ The following commands are available:
   (interactive)
   (let ((methods gnus-agent-covered-methods)
        (day (- (gnus-time-to-day (current-time)) gnus-agent-expire-days))
-       (expiry-hashtb (gnus-make-hashtable 1023))
        gnus-command-method sym group articles
        history overview file histories elem art nov-file low info
        unreads marked article)
     (save-excursion
       (setq overview (get-buffer-create " *expire overview*"))
       (while (setq gnus-command-method (pop methods))
+       (let ((expiry-hashtb (gnus-make-hashtable 1023)))
        (gnus-agent-open-history)
        (set-buffer
         (setq gnus-agent-current-history
@@ -1292,7 +1296,7 @@ The following commands are available:
                   info (gnus-get-info group)
                   unreads (ignore-errors (gnus-list-of-unread-articles group))
                   marked (nconc (gnus-uncompress-range
-                                 (cdr (assq 'ticked (gnus-info-marks info))))
+                                 (cdr (assq 'tick (gnus-info-marks info))))
                                 (gnus-uncompress-range
                                  (cdr (assq 'dormant
                                             (gnus-info-marks info)))))
@@ -1319,7 +1323,7 @@ The following commands are available:
                                 (< art article)))
                   (if (file-exists-p
                        (gnus-agent-article-name
-                        (number-to-string article) group))
+                        (number-to-string art) group))
                       (forward-line 1)
                     ;; Remove old NOV lines that have no articles.
                     (gnus-delete-line)))
@@ -1352,8 +1356,19 @@ The following commands are available:
                     (setcdr prev (setq alist (cdr alist)))
                   (setq prev alist
                         alist (cdr alist))))
-              (setq gnus-agent-article-alist (cdr first)))
-            (gnus-agent-save-alist group))
+              (setq gnus-agent-article-alist (cdr first))
+              ;;; Mark all articles up to the first article
+              ;;; in `gnus-article-alist' as read.
+              (when (caar gnus-agent-article-alist)
+                (setcar (nthcdr 2 info)
+                        (gnus-range-add
+                         (nth 2 info)
+                         (cons 1 (- (caar gnus-agent-article-alist) 1)))))
+              (gnus-dribble-enter
+               (concat "(gnus-group-set-info '"
+                       (gnus-prin1-to-string info)
+                       ")"))
+              (gnus-agent-save-alist group)))
           expiry-hashtb)
          (set-buffer history)
          (setq histories (nreverse (sort histories '<)))
@@ -1362,7 +1377,7 @@ The following commands are available:
            (gnus-delete-line))
          (gnus-agent-save-history)
          (gnus-agent-close-history))
-       (gnus-message 4 "Expiry...done")))))
+       (gnus-message 4 "Expiry...done"))))))
 
 ;;;###autoload
 (defun gnus-agent-batch ()