*** empty log message ***
[gnus] / lisp / nnvirtual.el
index f26770a..26d314d 100644 (file)
@@ -62,7 +62,8 @@
        'headers
       (let ((map nnvirtual-current-mapping)
            (offset 0)
-           articles beg group active top article result prefix)
+           articles beg group active top article result prefix
+           fetched-articles)
        (while sequence
          (while (< (car (car map)) (car sequence))
            (setq offset (car (car map)))
                ;; parse a mixed HEAD/NOV buffer.
                (and (eq result 'headers) (nnvirtual-convert-headers))
                (goto-char (point-min))
+               (setq fetched-articles nil)
                (while (not (eobp))
-                 (setq beg (point))
-                 (setq article (read nntp-server-buffer))
+                 (setq beg (point)
+                       article (read nntp-server-buffer)
+                       fetched-articles (cons article fetched-articles))
                  (delete-region beg (point))
                  (insert (int-to-string (+ (- article active) offset)))
                  (beginning-of-line)
                        (insert ?\t)))
                  (forward-line 1))))
          (goto-char (point-max))
-         (insert-buffer-substring nntp-server-buffer))
+         (insert-buffer-substring nntp-server-buffer)
+         ;; We have now massaged and inserted the headers from one
+         ;; group. In case some of the articles have expired or been
+         ;; cancelled, we have to mark them as read in the component
+         ;; group. 
+         (let ((unfetched (gnus-sorted-complement 
+                           articles (nreverse fetched-articles))))
+           (and unfetched
+                (gnus-group-make-articles-read group unfetched nil))))
        ;; The headers are ready for reading, so they are inserted into
        ;; the nntp-server-buffer, which is where Gnus expects to find
        ;; them.
@@ -269,6 +280,8 @@ If the stream is opened, return T, otherwise return NIL."
            (setq nnvirtual-current-groups nil)
            (while newsrc
              (and (string-match regexp (car (car newsrc)))
+                  (not (string= (gnus-group-real-name (car (car newsrc)))
+                                nnvirtual-current-group))
                   (setq nnvirtual-current-groups
                         (cons (car (car newsrc)) nnvirtual-current-groups)))
              (setq newsrc (cdr newsrc))))
@@ -288,10 +301,8 @@ If the stream is opened, return T, otherwise return NIL."
   (let* ((group (gnus-group-prefixed-name group (list 'nnvirtual "")))
         (info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
         (groups nnvirtual-current-groups)
-        (i 1)
-        (total 0)
         (offset 0)
-        reads unread igroup itotal itreads ireads)
+        reads unread igroup itotal ireads)
     ;; The virtual group doesn't exist. (?)
     (or info (error "No such group: %s" group))
     (setq nnvirtual-current-mapping nil)
@@ -308,8 +319,7 @@ If the stream is opened, return T, otherwise return NIL."
                  (gnus-get-unread-articles-in-group
                   info (gnus-gethash igroup gnus-active-hashtb))
                  (setq active (gnus-gethash igroup gnus-active-hashtb)))
-             (message "Couldn't open component group %s" igroup)
-             (ding)))
+             (message "Couldn't open component group %s" igroup)))
        (if (null active)
            ()
          ;; And then we do the mapping for this component group. If
@@ -400,6 +410,7 @@ If the stream is opened, return T, otherwise return NIL."
        marks art-group group-alist g)
     (while mark-lists
       (setq marks (symbol-value (car (car mark-lists))))
+      ;; Find out what groups the mark belong to.
       (while marks
        (setq art-group (nnvirtual-art-group (car marks)))
        (if (setq g (assoc (car art-group) group-alist))
@@ -407,6 +418,13 @@ If the stream is opened, return T, otherwise return NIL."
          (setq group-alist (cons (list (car art-group) (cdr art-group)) 
                                  group-alist)))
        (setq marks (cdr marks)))
+      ;; The groups that don't have marks must have no marks. (Yup.)
+      (let ((groups nnvirtual-current-groups))
+       (while groups
+         (or (assoc (car groups) group-alist)
+             (setq group-alist (cons (list (car groups)) group-alist)))
+         (setq groups (cdr groups))))
+      ;; The we update the list of marks.
       (while group-alist
        (gnus-add-marked-articles 
         (car (car group-alist)) (cdr (car mark-lists)) 
@@ -431,8 +449,9 @@ If the stream is opened, return T, otherwise return NIL."
   (nnvirtual-possibly-change-newsgroups group server)
   (let ((gnus-group-marked nnvirtual-current-groups)
        (gnus-expert-user t))
-    (set-buffer gnus-group-buffer)
-    (gnus-group-catchup-current nil all)))
+    (save-excursion
+      (set-buffer gnus-group-buffer)
+      (gnus-group-catchup-current nil all))))
 
 (provide 'nnvirtual)