* nnagent.el (nnagent-retrieve-headers): Use gnus-sorted-difference.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Wed, 30 Jan 2002 19:40:52 +0000 (19:40 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Wed, 30 Jan 2002 19:40:52 +0000 (19:40 +0000)
* gnus-agent.el (gnus-agent-retrieve-headers): Use
gnus-sorted-difference.

* nnsoup.el (nnsoup-request-expire-articles): Use
gnus-sorted-difference.

* nnheader.el: Autoload gnus-sorted-difference.

* nnfolder.el (nnfolder-request-expire-articles): Use
gnus-sorted-difference.

* gnus-cache.el (gnus-cache-retrieve-headers): Use
gnus-sorted-difference.

* gnus-range.el: Autoload cookies.
(gnus-sorted-difference): New function.
(gnus-sorted-ndifference): New function.
(gnus-sorted-nintersection): Rename from
gnus-set-sorted-intersection.
(gnus-sorted-nunion): Rename from gnus-sorted-nunion.
(gnus-list-range-difference): Rename from
gnus-inverse-list-range-intersection.
(gnus-inverse-list-range-intersection): Use defalias.

* gnus-sum.el (gnus-select-newsgroup): Use gnus-sorted-difference,
gnus-sorted-ndifference, and gnus-sorted-nintersection.
(gnus-articles-to-read): Use gnus-sorted-difference.
(gnus-summary-limit-mark-excluded-as-read): Use
gnus-sorted-intersection and gnus-sorted-ndifference.
(gnus-list-of-read-articles): Use gnus-list-range-difference.
(gnus-summary-insert-articles): Use gnus-sorted-difference.

lisp/ChangeLog
lisp/gnus-agent.el
lisp/gnus-cache.el
lisp/gnus-range.el
lisp/gnus-sum.el
lisp/nnagent.el
lisp/nnfolder.el
lisp/nnheader.el
lisp/nnsoup.el

index f975496..c7f2682 100644 (file)
@@ -1,7 +1,41 @@
 2002-01-30  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
+       * nnagent.el (nnagent-retrieve-headers): Use gnus-sorted-difference.
+
+       * gnus-agent.el (gnus-agent-retrieve-headers): Use
+       gnus-sorted-difference.
+
+       * nnsoup.el (nnsoup-request-expire-articles): Use
+       gnus-sorted-difference.
+
+       * nnheader.el: Autoload gnus-sorted-difference.
+
+       * nnfolder.el (nnfolder-request-expire-articles): Use
+       gnus-sorted-difference.
+
+       * gnus-cache.el (gnus-cache-retrieve-headers): Use
+       gnus-sorted-difference.
+
+       * gnus-range.el: Autoload cookies.
+       (gnus-sorted-difference): New function.
+       (gnus-sorted-ndifference): New function.
+       (gnus-sorted-nintersection): Rename from
+       gnus-set-sorted-intersection.
+       (gnus-sorted-nunion): Rename from gnus-sorted-nunion.
+       (gnus-list-range-difference): Rename from
+       gnus-inverse-list-range-intersection.
+       (gnus-inverse-list-range-intersection): Use defalias.
+
+       * gnus-sum.el (gnus-select-newsgroup): Use gnus-sorted-difference,
+       gnus-sorted-ndifference, and gnus-sorted-nintersection.
+       (gnus-articles-to-read): Use gnus-sorted-difference.
+       (gnus-summary-limit-mark-excluded-as-read): Use
+       gnus-sorted-intersection and gnus-sorted-ndifference.
+       (gnus-list-of-read-articles): Use gnus-list-range-difference.
+       (gnus-summary-insert-articles): Use gnus-sorted-difference.
+
        * gnus-sum.el (gnus-summary-update-info): Use gnus-sorted-union.
-       
+
 2002-01-30  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-art.el (gnus-article-wash-html-with-w3m): Add keymap
index 698b6dc..822e41b 100644 (file)
@@ -1848,7 +1848,7 @@ The following commands are available:
            (forward-line 1))
          (setq cached-articles (nreverse cached-articles))))
       (if (setq uncached-articles 
-               (gnus-set-difference articles cached-articles))
+               (gnus-sorted-difference articles cached-articles))
          (progn
            (set-buffer nntp-server-buffer)
            (erase-buffer)
index 574821e..a59526e 100644 (file)
@@ -279,9 +279,7 @@ it's not cached."
        ;; the normal way.
        (let ((gnus-use-cache nil))
          (gnus-retrieve-headers articles group fetch-old))
-      (let ((uncached-articles (gnus-sorted-intersection
-                               (gnus-sorted-complement articles cached)
-                               articles))
+      (let ((uncached-articles (gnus-sorted-difference articles cached))
            (cache-file (gnus-cache-file-name group ".overview"))
            type)
        ;; We first retrieve all the headers that we don't have in
index 43aa8b2..14cc416 100644 (file)
@@ -61,6 +61,43 @@ If RANGE is a single range, return (RANGE). Otherwise, return RANGE."
       (setq list2 (cdr list2)))
     list1))
 
+;;;###autoload
+(defun gnus-sorted-difference (list1 list2)
+  "Return a list of elements of LIST1 that do not appear in LIST2.
+Both lists have to be sorted over <.
+The tail of LIST1 is not copied."
+  (let (out)
+    (while (and list1 list2)
+      (cond ((= (car list1) (car list2))
+            (setq list1 (cdr list1)
+                  list2 (cdr list2)))
+           ((< (car list1) (car list2))
+            (setq out (cons (car list1) out))
+            (setq list1 (cdr list1)))
+           (t
+            (setq list2 (cdr list2)))))
+    (nconc (nreverse out) list1)))
+
+;;;###autoload
+(defun gnus-sorted-ndifference (list1 list2)
+  "Return a list of elements of LIST1 that do not appear in LIST2.
+Both lists have to be sorted over <.
+LIST1 is modified."
+  (let* ((top (cons nil list1))
+        (prev top))
+    (while (and list1 list2)
+      (cond ((= (car list1) (car list2))
+            (setcdr prev (cdr list1))
+            (setq list1 (cdr list1)
+                  list2 (cdr list2)))
+           ((< (car list1) (car list2))
+            (setq prev list1
+                  list1 (cdr list1)))
+           (t
+            (setq list2 (cdr list2)))))
+    (cdr top)))
+
+;;;###autoload
 (defun gnus-sorted-complement (list1 list2)
   "Return a list of elements that are in LIST1 or LIST2 but not both.
 Both lists have to be sorted over <."
@@ -79,6 +116,7 @@ Both lists have to be sorted over <."
               (setq list2 (cdr list2)))))
       (nconc (nreverse out) (or list1 list2)))))
 
+;;;###autoload
 (defun gnus-intersection (list1 list2)
   (let ((result nil))
     (while list2
@@ -87,6 +125,7 @@ Both lists have to be sorted over <."
       (setq list2 (cdr list2)))
     result))
 
+;;;###autoload
 (defun gnus-sorted-intersection (list1 list2)
   "Return intersection of LIST1 and LIST2.
 LIST1 and LIST2 have to be sorted over <."
@@ -102,7 +141,11 @@ LIST1 and LIST2 have to be sorted over <."
             (setq list2 (cdr list2)))))
     (nreverse out)))
 
-(defun gnus-set-sorted-intersection (list1 list2)
+;;;###autoload
+(defalias 'gnus-set-sorted-intersection 'gnus-sorted-nintersection)
+
+;;;###autoload
+(defun gnus-sorted-nintersection (list1 list2)
   "Return intersection of LIST1 and LIST2 by modifying cdr pointers of LIST1.
 LIST1 and LIST2 have to be sorted over <."
   (let* ((top (cons nil list1))
@@ -120,6 +163,7 @@ LIST1 and LIST2 have to be sorted over <."
     (setcdr prev nil)
     (cdr top)))
 
+;;;###autoload
 (defun gnus-sorted-union (list1 list2)
   "Return union of LIST1 and LIST2.
 LIST1 and LIST2 have to be sorted over <."
@@ -143,7 +187,8 @@ LIST1 and LIST2 have to be sorted over <."
            list2 (cdr list2)))
     (nreverse out)))
 
-(defun gnus-set-sorted-union (list1 list2)
+;;;###autoload
+(defun gnus-sorted-nunion (list1 list2)
   "Return union of LIST1 and LIST2 by modifying cdr pointers of LIST1.
 LIST1 and LIST2 have to be sorted over <."
   (let* ((top (cons nil list1))
@@ -392,7 +437,9 @@ LIST is a sorted list."
        (push number result)))
     (nreverse result)))
 
-(defun gnus-inverse-list-range-intersection (list ranges)
+(defalias 'gnus-inverse-list-range-intersection 'gnus-list-range-difference)
+
+(defun gnus-list-range-difference (list ranges)
   "Return a list of numbers in LIST that are not members of RANGES.
 LIST is a sorted list."
   (setq ranges (gnus-range-normalize ranges))
index 9fa61b5..529b2f2 100644 (file)
@@ -4699,8 +4699,9 @@ If SELECT-ARTICLES, only select those articles from GROUP."
       (setq cached gnus-newsgroup-cached))
 
     (setq gnus-newsgroup-unreads
-         (gnus-set-difference
-          (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
+         (gnus-sorted-ndifference
+          (gnus-sorted-ndifference gnus-newsgroup-unreads
+                                   gnus-newsgroup-marked)
           gnus-newsgroup-dormant))
 
     (setq gnus-newsgroup-processable nil)
@@ -4713,9 +4714,7 @@ If SELECT-ARTICLES, only select those articles from GROUP."
 
     (if (setq articles select-articles)
        (setq gnus-newsgroup-unselected
-             (gnus-sorted-intersection
-              gnus-newsgroup-unreads
-              (gnus-sorted-complement gnus-newsgroup-unreads articles)))
+             (gnus-sorted-difference gnus-newsgroup-unreads articles))
       (setq articles (gnus-articles-to-read group read-all)))
 
     (cond
@@ -4747,13 +4746,13 @@ If SELECT-ARTICLES, only select those articles from GROUP."
                    gnus-newsgroup-headers))
       (setq gnus-newsgroup-articles fetched-articles)
       (setq gnus-newsgroup-unreads
-           (gnus-set-sorted-intersection
+           (gnus-sorted-nintersection
             gnus-newsgroup-unreads fetched-articles))
       (gnus-compute-unseen-list)
 
       ;; Removed marked articles that do not exist.
       (gnus-update-missing-marks
-       (gnus-sorted-complement fetched-articles articles))
+       (gnus-sorted-difference articles fetched-articles))
       ;; We might want to build some more threads first.
       (when (and gnus-fetch-old-headers
                 (eq gnus-headers-retrieved-by 'nov))
@@ -4920,9 +4919,7 @@ If SELECT-ARTICLES, only select those articles from GROUP."
          ;; Select the N most recent articles.
          (setq articles (nthcdr (- number select) articles))))
       (setq gnus-newsgroup-unselected
-           (gnus-sorted-intersection
-            gnus-newsgroup-unreads
-            (gnus-sorted-complement gnus-newsgroup-unreads articles)))
+           (gnus-sorted-difference gnus-newsgroup-unreads articles))
       (when gnus-alter-articles-to-read-function
        (setq gnus-newsgroup-unreads
              (sort
@@ -5904,13 +5901,13 @@ displayed, no centering will be performed."
         (marked (gnus-info-marks info))
         (active (gnus-active group)))
     (and info active
-        (gnus-set-difference
-         (gnus-sorted-complement
-          (gnus-uncompress-range active)
-          (gnus-list-of-unread-articles group))
-         (append
-          (gnus-uncompress-range (cdr (assq 'dormant marked)))
-          (gnus-uncompress-range (cdr (assq 'tick marked))))))))
+        (gnus-list-range-difference
+         (gnus-list-range-difference
+          (gnus-sorted-complement
+           (gnus-uncompress-range active)
+           (gnus-list-of-unread-articles group))
+          (cdr (assq 'dormant marked)))
+         (cdr (assq 'tick marked))))))
 
 ;; Various summary commands
 
@@ -7265,15 +7262,17 @@ fetched for this group."
   "Mark all unread excluded articles as read.
 If ALL, mark even excluded ticked and dormants as read."
   (interactive "P")
-  (let ((articles (gnus-sorted-complement
+  (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
+  (let ((articles (gnus-sorted-ndifference
                   (sort
                    (mapcar (lambda (h) (mail-header-number h))
                            gnus-newsgroup-headers)
                    '<)
-                  (sort gnus-newsgroup-limit '<)))
+                  gnus-newsgroup-limit))
        article)
     (setq gnus-newsgroup-unreads
-         (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
+         (gnus-sorted-intersection gnus-newsgroup-unreads
+                                   gnus-newsgroup-limit))
     (if all
        (setq gnus-newsgroup-dormant nil
              gnus-newsgroup-marked nil
@@ -10802,9 +10801,10 @@ returned."
 
 (defun gnus-summary-insert-articles (articles)
   (when (setq articles
-             (gnus-set-difference articles
-                                  (mapcar (lambda (h) (mail-header-number h))
-                                          gnus-newsgroup-headers)))
+             (gnus-sorted-difference articles
+                                     (mapcar (lambda (h) 
+                                               (mail-header-number h))
+                                             gnus-newsgroup-headers)))
     (setq gnus-newsgroup-headers
          (merge 'list
                 gnus-newsgroup-headers
@@ -10843,17 +10843,17 @@ If ALL is a number, fetch this number of articles."
   (interactive "P")
   (prog1
       (let ((old (mapcar 'car gnus-newsgroup-data))
-           (i (car gnus-newsgroup-active))
            older len)
-       (while (<= i (cdr gnus-newsgroup-active))
-         (or (memq i old) (push i older))
-         (incf i))
+       (setq older
+             (gnus-sorted-difference
+              (gnus-uncompress-range (list gnus-newsgroup-active))
+              old))
        (setq len (length older))
        (cond
         ((null older) nil)
         ((numberp all)
          (if (< all len)
-             (setq older (subseq older 0 all))))
+             (setq older (last older all))))
         (all nil)
         (t
          (if (and (numberp gnus-large-newsgroup)
@@ -10868,12 +10868,11 @@ If ALL is a number, fetch this number of articles."
                (unless (string-match "^[ \t]*$" input)
                  (setq all (string-to-number input))
                  (if (< all len)
-                     (setq older (subseq older 0 all))))))))
+                     (setq older (last older all))))))))
        (if (not older)
            (message "No old news.")
-         (let ((gnus-fetch-old-headers t))
-           (gnus-summary-insert-articles older))
-         (gnus-summary-limit (gnus-union older old))))
+         (gnus-summary-insert-articles older)
+         (gnus-summary-limit (gnus-sorted-union older old))))
     (gnus-summary-position-point)))
 
 (defun gnus-summary-insert-new-articles ()
index 5ec2055..6b6a79a 100644 (file)
        arts n)
     (save-excursion
       (gnus-agent-load-alist group)
-      (setq arts (gnus-set-difference articles 
-                                     (mapcar 'car gnus-agent-article-alist)))
+      (setq arts (gnus-sorted-difference 
+                 articles (mapcar 'car gnus-agent-article-alist)))
       (set-buffer nntp-server-buffer)
       (erase-buffer)
       (nnheader-insert-nov-file file (car articles))
index 3e7d591..f31f2d4 100644 (file)
@@ -428,7 +428,7 @@ the group.  Then the marks file will be regenerated properly by Gnus.")
       (nnfolder-save-buffer)
       (nnfolder-adjust-min-active newsgroup)
       (nnfolder-save-active nnfolder-group-alist nnfolder-active-file)
-      (gnus-sorted-complement articles (nreverse deleted-articles)))))
+      (gnus-sorted-difference articles (nreverse deleted-articles)))))
 
 (deffoo nnfolder-request-move-article (article group server
                                               accept-form &optional last)
index efa1fde..3e7ffed 100644 (file)
@@ -40,7 +40,8 @@
 (eval-and-compile
   (autoload 'gnus-sorted-intersection "gnus-range")
   (autoload 'gnus-intersection "gnus-range")
-  (autoload 'gnus-sorted-complement "gnus-range"))
+  (autoload 'gnus-sorted-complement "gnus-range")
+  (autoload 'gnus-sorted-difference "gnus-range"))
 
 (defcustom gnus-verbose-backends 7
   "Integer that says how verbose the Gnus backends should be.
index d68794c..306235b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; nnsoup.el --- SOUP access for Gnus
 
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
 ;;     Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -337,7 +337,7 @@ backend for the messages.")
                  (delete-file (nnsoup-file prefix t)))
                t)
          (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))
-         (setq articles (gnus-sorted-complement articles range-list))))
+         (setq articles (gnus-sorted-difference articles range-list))))
       (when (not mod-time)
        (setcdr (cdr total-infolist) (delq info (cddr total-infolist)))))
     (if (cddr total-infolist)