Synch to No Gnus 200409290324.
[elisp/gnus.git-] / lisp / gnus-agent.el
index ca0ea7a..b4b46e9 100644 (file)
@@ -830,7 +830,8 @@ be a select method."
   (interactive)
   (save-excursion
     (dolist (gnus-command-method (gnus-agent-covered-methods))
-      (when (file-exists-p (gnus-agent-lib-file "flags"))
+      (when (and (file-exists-p (gnus-agent-lib-file "flags"))
+                (not (eq (gnus-server-status gnus-command-method) 'offline)))
        (gnus-agent-possibly-synchronize-flags-server gnus-command-method)))))
 
 (defun gnus-agent-synchronize-flags-server (method)
@@ -849,13 +850,18 @@ be a select method."
             (gnus-message 
              1 "Couldn't open server %s" (nth 1 gnus-command-method)))
            (t
-            (while (not (eobp))
-              (if (null (eval (read (current-buffer))))
-                  (gnus-delete-line)
-                (write-file (gnus-agent-lib-file "flags"))
-                (error "Couldn't set flags from file %s"
-                       (gnus-agent-lib-file "flags"))))
-            (delete-file (gnus-agent-lib-file "flags"))))
+            (condition-case err
+                (while t
+                  (let ((bgn (point)))
+                    (eval (read (current-buffer)))
+                    (delete-region bgn (point))))
+              (end-of-file
+               (delete-file (gnus-agent-lib-file "flags")))
+              (error
+               (let ((file (gnus-agent-lib-file "flags")))
+                 (write-file file)
+                 (error "Couldn't set flags from file %s due to %s"
+                        file (error-message-string err)))))))
       (kill-buffer nil))))
 
 (defun gnus-agent-possibly-synchronize-flags-server (method)
@@ -1211,6 +1217,32 @@ This can be added to `gnus-select-article-hook' or
 ;;; Internal functions
 ;;;
 
+(defun gnus-agent-synchronize-group-flags (group actions server)
+"Update a plugged group by performing the indicated actions."
+  (let* ((gnus-command-method (gnus-server-to-method server))
+        (info (or (gnus-get-info group)
+                  (gnus-get-info (gnus-group-full-name 
+                                  group gnus-command-method)))))
+    (gnus-request-set-mark group actions)
+
+    (when info
+      (dolist (action actions)
+       (let ((range (nth 0 action))
+             (what  (nth 1 action))
+             (marks (nth 2 action)))
+         (when (memq 'read marks)
+           (gnus-info-set-read 
+            info
+            (funcall (if (eq what 'add)
+                         'gnus-range-add
+                       'gnus-remove-from-range)
+                     (gnus-info-read info)
+                     range))
+           (gnus-get-unread-articles-in-group 
+            info
+            (gnus-active (gnus-info-group info)))))))
+    nil))
+
 (defun gnus-agent-save-active (method)
   (when (gnus-agent-method-p method)
     (let* ((gnus-command-method method)
@@ -1641,7 +1673,7 @@ and that there are no duplicates."
                   (setq backed-up (gnus-agent-backup-overview-buffer)))
               (gnus-message 1
                            "Duplicate overview line for %d" cur)
-             (delete-region (point) (progn (forward-line 1) (point))))
+             (delete-region p (progn (forward-line 1) (point))))
             ((< cur prev-num)
              (or backed-up
                   (setq backed-up (gnus-agent-backup-overview-buffer)))