From 9dd7af89584a7acb525ed2c3a4fbd88f2014dfd4 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Mon, 25 Nov 2002 22:27:59 +0000 Subject: [PATCH] Synch with Oort Gnus. --- lisp/ChangeLog | 6 ++++++ lisp/gnus-range.el | 42 ++++++++++++++++++++++++++++++++++++++++++ lisp/gnus-sum.el | 3 ++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9f21bee..e06ddcd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2002-11-25 Kai Gro,A_(Bjohann + From Kevin Greiner . + + * gnus-range.el (gnus-range-difference): New function. + * gnus-sum.el (gnus-summary-insert-old-articles): Use it. + 2002-11-24 Kai Gro,A_(Bjohann * gnus-sum.el (gnus-summary-insert-old-articles): Use diff --git a/lisp/gnus-range.el b/lisp/gnus-range.el index b609074..2e0a988 100644 --- a/lisp/gnus-range.el +++ b/lisp/gnus-range.el @@ -61,6 +61,48 @@ If RANGE is a single range, return (RANGE). Otherwise, return RANGE." (setq list2 (cdr list2))) list1)) +(defun gnus-range-difference (range1 range2) + "Return the range of elements in RANGE1 that do not appear in RANGE2. +Both ranges must be in ascending order." + (setq range1 (gnus-range-normalize range1)) + (setq range2 (gnus-range-normalize range2)) + (let* ((new-range (cons nil (copy-sequence range1))) + (r new-range) + (safe t)) + (while (cdr r) + (let* ((r1 (cadr r)) + (r2 (car range2)) + (min1 (if (numberp r1) r1 (car r1))) + (max1 (if (numberp r1) r1 (cdr r1))) + (min2 (if (numberp r2) r2 (car r2))) + (max2 (if (numberp r2) r2 (cdr r2)))) + + (cond ((> min1 max1) + ;; Invalid range: may result from overlap condition (below) + ;; remove Invalid range + (setcdr r (cddr r))) + ((and (= min1 max1) + (listp r1)) + ;; Inefficient representation: may result from overlap condition (below) + (setcar (cdr r) min1)) + ((not min2) + ;; All done with range2 + (setq r nil)) + ((< max1 min2) + ;; No overlap: range1 preceeds range2 + (pop r)) + ((< max2 min1) + ;; No overlap: range2 preceeds range1 + (pop range2)) + ((and (<= min2 min1) (<= max1 max2)) + ;; Complete overlap: range1 removed + (setcdr r (cddr r))) + (t + (setcdr r (nconc (list (cons min1 (1- min2)) (cons (1+ max2) max1)) (cddr r))))))) + (cdr new-range))) + + + ;;;###autoload (defun gnus-sorted-difference (list1 list2) "Return a list of elements of LIST1 that do not appear in LIST2. diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 952b901..1fabdbd 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -11505,7 +11505,8 @@ If ALL is a number, fetch this number of articles." ;;; (gnus-sorted-difference ;;; (gnus-uncompress-range (list gnus-newsgroup-active)) ;;; old) - (gnus-remove-from-range (list gnus-newsgroup-active) old) + (gnus-range-difference + (gnus-remove-from-range (list gnus-newsgroup-active) old)) ) (setq len (gnus-range-length older)) (cond -- 1.7.10.4