From 83dcd2c86093008c82241447681ce60dd2b9c51f Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Tue, 29 Jan 2002 17:55:11 +0000 Subject: [PATCH] * gnus-sum.el (gnus-summary-update-info): Use gnus-list-range-intersection. * gnus-agent.el (gnus-agent-fetch-headers): Use gnus-list-range-intersection. * gnus-range.el (gnus-range-normalize): Use correct predicate. (gnus-list-range-intersection): Use it. (gnus-inverse-list-range-intersection): Ditto. (gnus-sorted-intersection): Add doc. (gnus-set-sorted-intersection): Add doc. (gnus-sorted-union): New function. (gnus-set-sorted-union): New function. --- lisp/ChangeLog | 16 ++++++++++++- lisp/gnus-agent.el | 4 ++-- lisp/gnus-range.el | 58 ++++++++++++++++++++++++++++++++++++++++++---- lisp/gnus-sum.el | 6 ++--- 4 files changed, 74 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c91c1ae0f..46cbef512 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,19 @@ 2002-01-29 ShengHuo ZHU + * gnus-sum.el (gnus-summary-update-info): Use + gnus-list-range-intersection. + + * gnus-agent.el (gnus-agent-fetch-headers): Use + gnus-list-range-intersection. + + * gnus-range.el (gnus-range-normalize): Use correct predicate. + (gnus-list-range-intersection): Use it. + (gnus-inverse-list-range-intersection): Ditto. + (gnus-sorted-intersection): Add doc. + (gnus-set-sorted-intersection): Add doc. + (gnus-sorted-union): New function. + (gnus-set-sorted-union): New function. + * gnus-range.el (gnus-list-range-intersection): Correct the logic. (gnus-inverse-list-range-intersection): Ditto. @@ -1200,7 +1214,7 @@ (gnus-convert-image-to-gray-x-face): Ditto. * gnus-sum.el (gnus-summary-make-menu-bar): Add a :keys to - gnus-summary0show-raw-article. + gnus-summary-show-raw-article. 2002-01-02 ShengHuo ZHU diff --git a/lisp/gnus-agent.el b/lisp/gnus-agent.el index f3db90f6e..698b6dc79 100644 --- a/lisp/gnus-agent.el +++ b/lisp/gnus-agent.el @@ -1033,9 +1033,9 @@ the actual number of articles toggled is returned." (setq articles (sort (gnus-uncompress-sequence articles) '<)) ;; Remove known articles. (when (gnus-agent-load-alist group) - (setq articles (gnus-sorted-intersection + (setq articles (gnus-list-range-intersection articles - (gnus-uncompress-range + (list (cons (1+ (caar (last gnus-agent-article-alist))) (cdr (gnus-active group))))))) ;; Fetch them. diff --git a/lisp/gnus-range.el b/lisp/gnus-range.el index 75d6685c0..43aa8b219 100644 --- a/lisp/gnus-range.el +++ b/lisp/gnus-range.el @@ -34,7 +34,7 @@ (defsubst gnus-range-normalize (range) "Normalize RANGE. If RANGE is a single range, return (RANGE). Otherwise, return RANGE." - (if (listp (cdr range)) (list range) range)) + (if (listp (cdr-safe range)) range (list range))) (defun gnus-last-element (list) "Return last element of LIST." @@ -88,7 +88,8 @@ Both lists have to be sorted over <." result)) (defun gnus-sorted-intersection (list1 list2) - ;; LIST1 and LIST2 have to be sorted over <. + "Return intersection of LIST1 and LIST2. +LIST1 and LIST2 have to be sorted over <." (let (out) (while (and list1 list2) (cond ((= (car list1) (car list2)) @@ -102,8 +103,8 @@ Both lists have to be sorted over <." (nreverse out))) (defun gnus-set-sorted-intersection (list1 list2) - ;; LIST1 and LIST2 have to be sorted over <. - ;; This function modifies LIST1. + "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)) (prev top)) (while (and list1 list2) @@ -119,6 +120,53 @@ Both lists have to be sorted over <." (setcdr prev nil) (cdr top))) +(defun gnus-sorted-union (list1 list2) + "Return union of LIST1 and LIST2. +LIST1 and LIST2 have to be sorted over <." + (let (out) + (while (and list1 list2) + (cond ((= (car list1) (car list2)) + (setq out (cons (car list1) out) + list1 (cdr list1) + list2 (cdr list2))) + ((< (car list1) (car list2)) + (setq out (cons (car list1) out) + list1 (cdr list1))) + (t + (setq out (cons (car list2) out) + list2 (cdr list2))))) + (while list1 + (setq out (cons (car list1) out) + list1 (cdr list1))) + (while list2 + (setq out (cons (car list2) out) + list2 (cdr list2))) + (nreverse out))) + +(defun gnus-set-sorted-union (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)) + (prev top)) + (while (and list1 list2) + (cond ((= (car list1) (car list2)) + (setq prev list1 + list1 (cdr list1) + list2 (cdr list2))) + ((< (car list1) (car list2)) + (setq prev list1 + list1 (cdr list1))) + (t + (setcdr prev (list (car list2))) + (setq prev (cdr prev) + list2 (cdr list2)) + (setcdr prev list1)))) + (while list2 + (setcdr prev (list (car list2))) + (setq prev (cdr prev) + list2 (cdr list2))) + (cdr top))) + (defun gnus-compress-sequence (numbers &optional always-list) "Convert list of numbers to a list of ranges or a single range. If ALWAYS-LIST is non-nil, this function will always release a list of @@ -328,6 +376,7 @@ modified." (defun gnus-list-range-intersection (list ranges) "Return a list of numbers in LIST that are members of RANGES. LIST is a sorted list." + (setq ranges (gnus-range-normalize ranges)) (let (number result) (while (setq number (pop list)) (while (and ranges @@ -346,6 +395,7 @@ LIST is a sorted list." (defun gnus-inverse-list-range-intersection (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)) (let (number result) (while (setq number (pop list)) (while (and ranges diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 86afe0a36..98f18141f 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -5985,10 +5985,10 @@ The prefix argument ALL means to select all articles." (setq gnus-newsgroup-killed (gnus-compress-sequence (nconc - (gnus-set-sorted-intersection - (gnus-uncompress-range gnus-newsgroup-killed) + (gnus-list-range-intersection (setq gnus-newsgroup-unselected - (sort gnus-newsgroup-unselected '<))) + (sort gnus-newsgroup-unselected '<)) + gnus-newsgroup-killed) (setq gnus-newsgroup-unreads (sort gnus-newsgroup-unreads '<))) t))) -- 2.34.1