From d505ddab799c521c2f0ec97089c58c1abe9ba44d Mon Sep 17 00:00:00 2001 From: Kevin Greiner Date: Sun, 13 Nov 2005 04:13:46 +0000 Subject: [PATCH] * gnus-agent.el (gnus-agent-braid-nov): Now tests new nov entries for duplicates which are removed. The invalid sort check then triggers a rescan after the sort as sorting may have moved duplicate entries such that they can be cheaply detected. --- lisp/ChangeLog | 7 ++++ lisp/gnus-agent.el | 82 +++++++++++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a339a9e8e..654d468d6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2005-11-12 Kevin Greiner + + * gnus-agent.el (gnus-agent-braid-nov): Now tests new nov entries + for duplicates which are removed. The invalid sort check then + triggers a rescan after the sort as sorting may have moved + duplicate entries such that they can be cheaply detected. + 2005-11-13 Katsumi Yamaoka * gnus-start.el (gnus-dribble-read-file): Quote file-precious-flag. diff --git a/lisp/gnus-agent.el b/lisp/gnus-agent.el index 3e39b7c74..a7769aee0 100644 --- a/lisp/gnus-agent.el +++ b/lisp/gnus-agent.el @@ -1866,7 +1866,7 @@ article numbers will be returned." (defsubst gnus-agent-read-article-number () "Reads the article number at point. Returns nil when a valid article number can not be read." - ;; It is unfortunite but the read function quietly overflows + ;; It is unfortunate but the read function quietly overflows ;; integer. As a result, I have to use string operations to test ;; for overflow BEFORE calling read. (when (looking-at "[0-9]+\t") @@ -1925,21 +1925,21 @@ doesn't exist, to valid the overview buffer." (gnus-agent-copy-nov-line (pop articles)) (ignore-errors - (while articles - (while (let ((art (read (current-buffer)))) - (cond ((< art (car articles)) - (forward-line 1) - t) - ((= art (car articles)) - (beginning-of-line) - (delete-region - (point) (progn (forward-line 1) (point))) - nil) - (t - (beginning-of-line) - nil)))) - - (gnus-agent-copy-nov-line (pop articles))))) + (while articles + (while (let ((art (read (current-buffer)))) + (cond ((< art (car articles)) + (forward-line 1) + t) + ((= art (car articles)) + (beginning-of-line) + (delete-region + (point) (progn (forward-line 1) (point))) + nil) + (t + (beginning-of-line) + nil)))) + + (gnus-agent-copy-nov-line (pop articles))))) (goto-char (point-max)) @@ -1955,23 +1955,39 @@ doesn't exist, to valid the overview buffer." (goto-char p)) (setq last (or last -134217728)) - (let (sort art) - (while (not (eobp)) - (setq art (gnus-agent-read-article-number)) - (cond ((not art) - ;; Bad art num - delete this line - (beginning-of-line) - (delete-region (point) (progn (forward-line 1) (point)))) - ((< art last) - ;; Art num out of order - enable sort - (setq sort t) - (forward-line 1)) - (t - ;; Good art num - (setq last art) - (forward-line 1)))) - (when sort - (sort-numeric-fields 1 (point-min) (point-max))))))) + (while (catch 'problems + (let (sort art) + (while (not (eobp)) + (setq art (gnus-agent-read-article-number)) + (cond ((not art) + ;; Bad art num - delete this line + (beginning-of-line) + (delete-region (point) (progn (forward-line 1) (point)))) + ((< art last) + ;; Art num out of order - enable sort + (setq sort t) + (forward-line 1)) + ((= art last) + ;; Bad repeat of art number - delete this line + (beginning-of-line) + (delete-region (point) (progn (forward-line 1) (point)))) + (t + ;; Good art num + (setq last art) + (forward-line 1)))) + (when sort + ;; something is seriously wrong as we simply shouldn't see out-of-order data. + ;; First, we'll fix the sort. + (sort-numeric-fields 1 (point-min) (point-max)) + + ;; but now we have to consider that we may have duplicate rows... + ;; so reset to beginning of file + (goto-char (point-min)) + (setq last -134217728) + + ;; and throw a code that restarts this scan + (throw 'problems t)) + nil)))))) ;; Keeps the compiler from warning about the free variable in ;; gnus-agent-read-agentview. -- 2.34.1