Gnus development mailing list
 help / color / mirror / Atom feed
From: David Engster <deng@randomsample.de>
To: ding@gnus.org
Subject: Re: gnus and imap
Date: Mon, 25 Aug 2008 21:50:29 +0200	[thread overview]
Message-ID: <87prnwvpq2.fsf@randomsample.de> (raw)
In-Reply-To: <868wulotw7.fsf@lifelogs.com> (Ted Zlatanov's message of "Mon, 25 Aug 2008 13:02:16 -0500")

Ted Zlatanov <tzz@lifelogs.com> writes:
> DE> Thanks for your explanation. While this behavior of Zimbra might be
> DE> peculiar, it's in accordance with the IMAP RFC, which only demands UIDs
> DE> to be unique and ascending. So I'm afraid it is Gnus which will have to
> DE> be fixed here, which - being originally only a nntp client - still
> DE> assumes that article numbers are more or less contiguous.
>
> I would appreciate a quick primer:
>
> What elements of the Gnus data formats enforce this assumption currently?
>
> What backend functions make this assumption?  Which functions outside
> the backends have knowledge of the data format internals?

As far as I see, Gnus almost always tries to determine article counts
from the active data and the stuff that is saved in the group's
info[1]. However, all you can get from this data are upper bounds. It
will only be exact in the case of strictly contiguous article numbers.

For example:

In `gnus-articles-to-read', the total number of articles in a group is
simply the length of

(setq articles (gnus-uncompress-range (gnus-active group)))

With 'select' being the number of articles you want to retrieve from a
group, Gnus queries the backend with the following article list:

;; Select the N most recent articles.
(setq articles (nthcdr (- number select) articles))))

(where 'number' is the length of 'articles').

Similarly, unread articles are determined in
`gnus-list-of-unread-articles' by doing the following:

;; This function returns a list of article numbers based on the
;; difference between the ranges of read articles in this group and
;; the range of active articles.

In the case of nnimap, this estimate is currently "fixed" (in fact
overridden) through an imap-search for UNSEEN, which is done when
closing a nnimap group and saved in a separate hash table.

Article counts are done in the backend interface. AFAIK, the backends
itself don't assume much about article numbers. They just have to be
unique there.

I agree with Vitaly that the best way to solve this is to give the
backend interface complete knowledge of the available article numbers in
a group. We could use an additional backend function for this,
nnchoke-request-group-articles, which already exists for nntp, but
somehow isn't used further in Gnus. Based on what
nntp-request-group-articles returns, the function for nnimap would
roughly look like this

(deffoo nnimap-request-group-articles (group &optional server)
  (nnimap-possibly-change-group group server)
  (let ((articles (with-current-buffer nnimap-server-buffer
		    (imap-search "ALL"))))
    (if articles
      (with-current-buffer nntp-server-buffer
	(erase-buffer)
	(insert 
	 (format "211 %d %d %d %s\n"
		 (length articles)
		 (car articles)
		 (car (last articles))
		 group))
	(insert (mapconcat
		 'number-to-string
		 articles
		 "\n"))
	(insert "\n.\n")
	t)
      nil)))

Using this function will make backend access slower, so it should be
optional, maybe configurable through an additional server variable.

As Vitaly mentioned, this information should be cached so that we don't
have to get it every time a group is accessed.

-David



  reply	other threads:[~2008-08-25 19:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-19 16:14 Vitaly Mayatskikh
2008-08-19 20:12 ` Frank Schmitt
2008-08-19 22:24   ` Vitaly Mayatskikh
2008-08-20  6:42     ` Vegard Vesterheim
2008-08-20  7:41       ` Vitaly Mayatskikh
2008-08-20 16:16 ` David Engster
2008-08-21  6:26   ` Vitaly Mayatskikh
2008-08-21 11:27     ` David Engster
2008-08-21 12:57       ` Tibor Simko
2008-08-22  8:44         ` Vitaly Mayatskikh
2008-08-22  8:54           ` David Engster
2008-08-22 15:35           ` Tibor Simko
2008-08-21 15:06       ` Vitaly Mayatskikh
2008-08-21 21:15       ` Frank Schmitt
2008-08-22 12:13       ` Reiner Steib
2008-08-22 12:30         ` Vitaly Mayatskikh
2008-08-22 15:50           ` Ted Zlatanov
2008-08-22 16:10             ` Vitaly Mayatskikh
2008-08-22 16:21         ` David Engster
2008-08-22 16:27           ` Vitaly Mayatskikh
2008-08-22 17:33             ` David Engster
2008-08-22 18:11               ` Vitaly Mayatskikh
2008-08-23  9:19                 ` David Engster
2008-08-23 11:32                   ` Vitaly Mayatskikh
2008-08-23 14:52                     ` David Engster
2008-08-24  8:47                       ` Vitaly Mayatskikh
2008-08-24 18:09                         ` David Engster
2008-08-24 19:29                           ` Reiner Steib
2008-08-24 23:39                             ` David Engster
2008-08-25 19:22                               ` James Cloos
2008-08-25  0:00                           ` Daniel Pittman
2008-08-25  9:46                             ` David Engster
2008-08-25 18:02                               ` Ted Zlatanov
2008-08-25 19:50                                 ` David Engster [this message]
2008-08-25  8:05                           ` Vitaly Mayatskikh
2008-08-25 12:25                             ` David Engster
2008-08-25 13:17                               ` Vitaly Mayatskikh
2008-08-25 17:53                         ` Ted Zlatanov
2008-08-24  9:18                       ` Vitaly Mayatskikh
2008-08-24 10:08                         ` David Engster
2008-08-26 20:40                           ` Vitaly Mayatskikh
2008-09-03 11:55                             ` David Engster
2008-09-21  9:57                               ` David Engster
2009-12-07 18:57                                 ` Dan Christensen
2009-12-10 20:08                                   ` Dan Christensen
2009-12-11 20:36                                     ` David Engster
  -- strict thread matches above, loose matches on Subject: below --
2002-07-09  8:52 gnus and IMAP me
2002-07-09  9:29 ` Niklas Morberg
2002-07-09 10:17   ` me
2002-07-09 10:27   ` me
2002-07-09 10:52   ` me

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prnwvpq2.fsf@randomsample.de \
    --to=deng@randomsample.de \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).