(message-reply): Take an optional switch-buffer parameter so that Gnus window confs...
[gnus] / lisp / gnus-sync.el
index b6131ce..892b10a 100644 (file)
@@ -1,7 +1,6 @@
 ;;; gnus-sync.el --- synchronization facility for Gnus
 
-;;; Copyright (C) 2010
-;;; Free Software Foundation, Inc.
+;; Copyright (C) 2010-2011  Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
 ;; Keywords: news synchronization nntp nnrss
 
 ;; This is the gnus-sync.el package.
 
+;; It's due for a rewrite using gnus-after-set-mark-hook and
+;; gnus-before-update-mark-hook.  Until then please consider it
+;; experimental.
+
 ;; Put this in your startup file (~/.gnus.el for instance)
 
 ;; possibilities for gnus-sync-backend:
 
 ;; - after gnus-sync-read, the message counts are wrong
 
+;; - use gnus-after-set-mark-hook and gnus-before-update-mark-hook to
+;;   catch the mark updates
+
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(require 'gnus)
+(require 'gnus-start)
 (require 'gnus-util)
 
 (defgroup gnus-sync nil
   "The Gnus synchronization facility."
-  :version "23.1"
+  :version "24.1"
   :group 'gnus)
 
 (defcustom gnus-sync-newsrc-groups `("nntp" "nnrss")
@@ -96,20 +104,16 @@ synchronized, I believe).  Also see `gnus-variable-list'."
     ;; populate gnus-sync-newsrc-loader from all but the first dummy
     ;; entry in gnus-newsrc-alist whose group matches any of the
     ;; gnus-sync-newsrc-groups
-    (let* ((loader
-            (loop for entry in (cdr gnus-newsrc-alist)
-                  when (gnus-grep-in-list
-                        (car entry)     ;the group name
-                        gnus-sync-newsrc-groups)
-                  collect (cons (car entry)
-                                (mapcar (lambda (offset)
-                                          (cons offset (nth offset entry)))
-                                        gnus-sync-newsrc-offsets))))
-           (gnus-sync-newsrc-loader
-            (nunion loader
-                    (set-difference gnus-sync-newsrc-loader loader :key 'car)
-                    :key 'car)))
-
+    ;; TODO: keep the old contents for groups we don't have!
+    (let ((gnus-sync-newsrc-loader
+           (loop for entry in (cdr gnus-newsrc-alist)
+                 when (gnus-grep-in-list
+                       (car entry)     ;the group name
+                       gnus-sync-newsrc-groups)
+                 collect (cons (car entry)
+                               (mapcar (lambda (offset)
+                                         (cons offset (nth offset entry)))
+                                       gnus-sync-newsrc-offsets)))))
       (with-temp-file gnus-sync-backend
         (progn
           (let ((coding-system-for-write gnus-ding-file-coding-system)
@@ -217,7 +221,7 @@ synchronized, I believe).  Also see `gnus-variable-list'."
   (interactive)
   ;; (add-hook 'gnus-get-new-news-hook 'gnus-sync-read)
   (add-hook 'gnus-save-newsrc-hook 'gnus-sync-save)
-  (add-hook 'gnus-read-newsrc-el-hoo4a 'gnus-sync-read))
+  (add-hook 'gnus-read-newsrc-el-hook 'gnus-sync-read))
 
 (defun gnus-sync-unload-hook ()
   "Uninstall the sync hooks."