Sync up with gnus-5.6.31
[elisp/gnus.git-] / lisp / gnus-agent.el
index aaeb1cb..69265c8 100644 (file)
@@ -1,4 +1,4 @@
-;;; gnus-agent.el --- unplugged support for Gnus
+;;; gnus-agent.el --- unplugged support for Semi-gnus
 ;; Copyright (C) 1997,98 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -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))
@@ -719,7 +720,7 @@ the actual number of articles toggled is returned."
        (when (= (point-max) (point-min))
          (push (cons group (current-buffer)) gnus-agent-buffer-alist)
          (ignore-errors
-           (insert-file-contents
+           (nnheader-insert-file-contents
             (gnus-agent-article-name ".overview" group))))
        (nnheader-find-nov-line (string-to-number (cdar crosses)))
        (insert (string-to-number (cdar crosses)))
@@ -760,6 +761,17 @@ the actual number of articles toggled is returned."
        (set-buffer nntp-server-buffer)
        (unless (eq 'nov (gnus-retrieve-headers articles group))
          (nnvirtual-convert-headers))
+       ;;
+       ;; To gnus-agent-expire work fine with no Xref field in .overview 
+       ;; Tatsuya Ichikawa <ichikawa@hv.epson.co.jp>
+       (goto-char (point-min))
+       (while (not (eobp))
+         (goto-char (point-at-eol))
+         (insert "\t")
+         (forward-line 1))
+       ;; Tatsuya Ichikawa <ichikawa@hv.epson.co.jp>
+       ;; To gnus-agent-expire work fine with no Xref field in .overview 
+       ;;
        ;; Save these headers for later processing.
        (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
        (let (file)
@@ -769,8 +781,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)
@@ -788,7 +803,7 @@ the actual number of articles toggled is returned."
     (goto-char (point-min))
     (set-buffer nntp-server-buffer)
     (erase-buffer)
-    (insert-file-contents file)
+    (nnheader-insert-file-contents file)
     (goto-char (point-min))
     (if (or (= (point-min) (point-max))
            (progn
@@ -1254,13 +1269,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,19 +1307,19 @@ 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)))))
                   nov-file (gnus-agent-article-name ".overview" group))
-            (gnus-agent-load-alist group)
+            (gnus-agent-load-alist group)
             (gnus-message 5 "Expiring articles in %s" group)
             (set-buffer overview)
             (erase-buffer)
             (when (file-exists-p nov-file)
-              (insert-file-contents nov-file))
+              (nnheader-insert-file-contents nov-file))
             (goto-char (point-min))
-            (setq article 0)
+            (setq article 0)
             (while (setq elem (pop articles))
               (setq article (car elem))
               (when (or (null low)
@@ -1319,7 +1334,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 +1367,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 +1388,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 ()