Refactor out nnheader-update-marks-actions and use it throughout.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Fri, 26 Nov 2010 01:55:42 +0000 (02:55 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Fri, 26 Nov 2010 01:55:42 +0000 (02:55 +0100)
lisp/ChangeLog
lisp/nnfolder.el
lisp/nnheader.el
lisp/nnml.el
lisp/nntp.el

index 6b19451..2cb456c 100644 (file)
@@ -1,5 +1,13 @@
 2010-11-26  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nnheader.el (nnheader-update-marks-actions): Refactor out.
+
+       * nntp.el (nntp-request-set-mark): Use it.
+
+       * nnfolder.el (nnfolder-request-set-mark): Ditto.
+
+       * nnml.el (nnml-request-set-mark): Ditto.
+
        * nnimap.el (nnimap-last-response-string): Remove the unfolding -- it
        introduces regressions in article selection.
        (nnimap-find-uid-response): New function.
index 3f7043c..5de8653 100644 (file)
@@ -1186,23 +1186,7 @@ This command does not work if you use short group names."
     (nnfolder-open-server server))
   (unless nnfolder-marks-is-evil
     (nnfolder-open-marks group server)
-    (dolist (action actions)
-      (let ((range (nth 0 action))
-           (what  (nth 1 action))
-           (marks (nth 2 action)))
-       (dolist (mark marks)
-         (setq nnfolder-marks
-               (gnus-update-alist-soft
-                mark
-                (cond
-                 ((eq what 'add)
-                  (gnus-range-add (cdr (assoc mark nnfolder-marks)) range)
-                 ((eq what 'del)
-                  (gnus-remove-from-range
-                   (cdr (assoc mark nnfolder-marks)) range))
-                 ((eq what 'set)
-                  range)))
-                nnfolder-marks)))))
+    (setq nnfolder-marks (nnheader-update-marks-actions nnfolder-marks actions))
     (nnfolder-save-marks group server))
   nil)
 
index 08dc96d..d34229a 100644 (file)
@@ -1078,6 +1078,26 @@ See `find-file-noselect' for the arguments."
                   (truncate nnheader-read-timeout))
                1000))))
 
+(defun nnheader-update-marks-actions (backend-marks actions)
+  (dolist (action actions)
+    (let ((range (nth 0 action))
+         (what  (nth 1 action))
+         (marks (nth 2 action)))
+      (dolist (mark marks)
+       (setq backend-marks
+             (gnus-update-alist-soft
+              mark
+              (cond
+               ((eq what 'add)
+                (gnus-range-add (cdr (assoc mark backend-marks)) range)
+                ((eq what 'del)
+                 (gnus-remove-from-range
+                  (cdr (assoc mark backend-marks)) range))
+                ((eq what 'set)
+                 range)))
+              backend-marks)))))
+  backend-marks)
+
 (when (featurep 'xemacs)
   (require 'nnheaderxm))
 
index 6282b25..46a6d90 100644 (file)
@@ -1033,24 +1033,7 @@ Use the nov database for the current group if available."
   (nnml-possibly-change-directory group server)
   (unless nnml-marks-is-evil
     (nnml-open-marks group server)
-    (dolist (action actions)
-      (let ((range (nth 0 action))
-           (what  (nth 1 action))
-           (marks (nth 2 action)))
-       (assert (or (eq what 'add) (eq what 'del) (eq what 'set)) nil
-               "Unknown request-set-mark action: %s" what)
-       (dolist (mark marks)
-         (setq nnml-marks
-               (gnus-update-alist-soft
-                mark
-                (cond
-                 ((eq what 'add)
-                  (gnus-range-add (cdr (assoc mark nnml-marks)) range)
-                 ((eq what 'del)
-                  (gnus-remove-from-range (cdr (assoc mark nnml-marks)) range))
-                 ((eq what 'set)
-                  range)))
-                nnml-marks)))))
+    (setq nnml-marks (nnheader-update-marks-actions nnml-marks actions))
     (nnml-save-marks group server))
   nil)
 
index 1e33055..f37a1c8 100644 (file)
@@ -1118,22 +1118,7 @@ command whose response triggered the error."
             nntp-marks-file-name)
     (nntp-possibly-create-directory group server)
     (nntp-open-marks group server)
-    (dolist (action actions)
-      (let ((range (nth 0 action))
-           (what  (nth 1 action))
-           (marks (nth 2 action)))
-       (dolist (mark marks)
-         (setq nntp-marks
-               (gnus-update-alist-soft
-                mark
-                (cond
-                 ((eq what 'add)
-                  (gnus-range-add (cdr (assoc mark nntp-marks)) range)
-                 ((eq what 'del)
-                  (gnus-remove-from-range (cdr (assoc mark nntp-marks)) range))
-                 ((eq what 'set)
-                  range)))
-                nntp-marks)))))
+    (setq nntp-marks (nnheader-update-marks-actions nntp-marks actions))
     (nntp-save-marks group server))
   nil)