Subject: Re: bug#72949: Gnus sometimes reports new messages but not showing them on IMAP server

From: Dan Christensen <[email-masked]>
Date: Sat, 14 Sep 2024 17:46:52 +0000

On Sep 12, 2024, James Thomas <[email-masked]> wrote:

>> Sorry! I got confused again... Please try the other patch in that bug
>> report (the one that swaps the car and cdr). I find that it works with
>> your use case!

Yes, that patch fixes the problem I've had for ages.  But I don't think
that it's correct.  Here's what is done in nnml.el:

	  (nnheader-insert "211 %d %d %d %s\n"
			   (max (1+ (- (cdr active) (car active))) 0)
			   (car active) (cdr active) group)))))))

Notice that the car comes before the cdr, and that you have to add 1
to the difference between the cdr and the car, since if the active
range is 2 . 3, then there are 2 active articles, which is one more
than 3 - 2.  So I suspect that the patch attached below might be
correct.  Someone who knows more about what the "211" line should
contain should review this.

My patch also fixes the problem I've had.  With either patch, after
moving or copying an article to a new group, the new group has (active 1
. 1) as expected, with no unexist entry.

But the two patches would behave differently when active was already set.

Dan

diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 17a55f98..cdd9f01f 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -918,10 +918,10 @@ nnimap-request-group
 	    (nnimap-finish-retrieve-group-infos server info sequences
 						t)
 	    (setq active (nth 2 (assoc group nnimap-current-infos)))))
-	(setq active (or active '(0 . 1)))
+	(setq active (or active '(1 . 0)))
 	(erase-buffer)
 	(insert (format "211 %d %d %d %S\n"
-			(- (cdr active) (car active))
+			(max (1+ (- (cdr active) (car active))) 0)
 			(car active)
 			(cdr active)
 			group))