Gnus development mailing list
 help / color / mirror / Atom feed
* emacs.gnus
@ 2003-06-08 13:04 Hanak David
  2003-06-08 19:12 ` emacs.gnus Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Hanak David @ 2003-06-08 13:04 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 3821 bytes --]

Greetings,

I find it annoying that Gnus cannot determine the exact article count for
nnml groups.  Since I often move messages from one group to another, or
expire articles, the active range is full of holes.  Therefore, when I ask
Gnus for, say, 50 articles, it might happen that I only get 5.  And the
estimate for the number of artciles can also become very wild.

I've hacked this for myself quite a while ago, but very recently I've
joined the Gnus newsgroups, and decided to send a patch that would solve
the problem for others, too.  The patches are up to date, they are based on
the CVS version.  Please feel free to modify them.

I modified two files, gnus-sum.el and nnml.el.  The patches follow.

David

---------- cut here ----------

*** /usr/share/emacs/site-lisp/gnus/lisp/gnus-sum.el	2003-06-07 19:40:22.000000000 +0200
--- ./gnus-sum.el	2003-06-08 14:35:43.000000000 +0200
***************
*** 5226,5231 ****
--- 5226,5241 ----
        (memq article gnus-newsgroup-recent))
       (t t))))
  
+ (defun gnus-group-article-list (group)
+   "Return a list of all article numbers in GROUP.  If
+ <method>-group-article-list exists and returns non-nil, returns that value,
+ otherwise returns the range stored in the active info."
+   (let* ((method (symbol-name (car (gnus-find-method-for-group group))))
+ 	 (listf (intern (concat method "-group-article-list"))))
+     (or (and (functionp listf)
+ 	     (funcall listf group))
+ 	(gnus-uncompress-range (gnus-active group)))))
+ 
  (defun gnus-articles-to-read (group &optional read-all)
    "Find out what articles the user wants to read."
    (let* ((display (gnus-group-find-parameter group 'display))
***************
*** 5242,5248 ****
  	      ;; articles in the group, or (if that's nil), the
  	      ;; articles in the cache.
  	      (or
! 	       (gnus-uncompress-range (gnus-active group))
  	       (gnus-cache-articles-in-group group))
  	    ;; Select only the "normal" subset of articles.
  	    (gnus-sorted-nunion
--- 5252,5258 ----
  	      ;; articles in the group, or (if that's nil), the
  	      ;; articles in the cache.
  	      (or
! 	       (gnus-group-article-list group)
  	       (gnus-cache-articles-in-group group))
  	    ;; Select only the "normal" subset of articles.
  	    (gnus-sorted-nunion


*** /usr/share/emacs/site-lisp/gnus/lisp/nnml.el	2003-05-01 16:23:15.000000000 +0200
--- ./nnml.el	2003-06-08 14:32:27.000000000 +0200
***************
*** 84,89 ****
--- 84,96 ----
  (defvoo nnml-use-compressed-files nil
    "If non-nil, allow using compressed message files.")
  
+ (defvoo nnml-ignore-active-file nil
+   "If non-nil or matches the group name as a regexp, the active file is
+ ignored.  This causes nnml to do some extra work in order to determine the
+ true active ranges of a group.  Note that the active file is still saved,
+ but its values are not used.  This costs some extra time when scanning a
+ group when opening it.")
+ 
  \f
  
  (defconst nnml-version "nnml 1.0"
***************
*** 1007,1012 ****
--- 1014,1031 ----
  	(nnml-save-marks group server)
  	(nnheader-message 7 "Bootstrapping marks for %s...done" group)))))
  
+ (deffoo nnml-group-article-list (group)
+   "Return a list of all article numbers in group if
+ `nnml-ignore-active-file' is t or matches the group name as a regexp,
+ otherwise return nil.  Called from `gnus-group-article-list'."
+   (if (or (eq nnml-ignore-active-file t)
+ 	  (and (stringp nnml-ignore-active-file)
+ 	       (string-match nnml-ignore-active-file group)))
+       (sort (nnheader-directory-articles
+ 	     (nnheader-group-pathname (gnus-group-real-name group)
+ 				      nnml-directory))
+ 	    '<)))
+ 
  (provide 'nnml)
  
  ;;; nnml.el ends here

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-08 13:04 emacs.gnus Hanak David
@ 2003-06-08 19:12 ` Kai Großjohann
  2003-06-08 21:04   ` emacs.gnus Hanak David
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-06-08 19:12 UTC (permalink / raw)


Hanak David <dhanak@inf.bme.hu> writes:

> I've hacked this for myself quite a while ago, but very recently
> I've joined the Gnus newsgroups, and decided to send a patch that
> would solve the problem for others, too.  The patches are up to
> date, they are based on the CVS version.  Please feel free to modify
> them.

I haven't tested it, only skimmed the source.  It looks way cool.  Do
you have paperwork on file?  It would be just dandy if it could be
incorporated.

One minor thing: it seems that the function has a similar purpose as
other backend functions, which are conventionally called
nnchoke-request-foo or nnchoke-retrieve-bar, it seems.  Also, I
wonder if you used the same mechanism as for the other backend
functions?  If not, it might be useful to do that.

(I know that maybe I should look closer, but just in case there are
problems with the paperwork, I'm putting the closer look off a little
bit.)
-- 
This line is not blank.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-08 19:12 ` emacs.gnus Kai Großjohann
@ 2003-06-08 21:04   ` Hanak David
  2003-06-09  9:16     ` emacs.gnus Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Hanak David @ 2003-06-08 21:04 UTC (permalink / raw)


On Sun, 08 Jun 2003, Kai Großjohann wrote:

> I haven't tested it, only skimmed the source.  It looks way cool.  Do
> you have paperwork on file?  It would be just dandy if it could be
> incorporated.

I'm glad you liked it.  But what do you exactly mean by "paperwork on
file"?  Do you need my official permission to incorporate my patch?  If
this mail is enough, you have it.

> One minor thing: it seems that the function has a similar purpose as
> other backend functions, which are conventionally called
> nnchoke-request-foo or nnchoke-retrieve-bar, it seems.  Also, I
> wonder if you used the same mechanism as for the other backend
> functions?  If not, it might be useful to do that.

I'm not very familiar with the interior design of Gnus, so I didn't notice
the request and retreive functions.  If you feel that a name like that
would suit your taste (or Gnus) better, go ahead, rename it.  But again, I
fail to understand what do you mean by the "same mechanism as for the other
backend functions".  I admit that I took the name and docstring of
nnml-ignore-active-file from nnfolder-ignore-active-file, because I felt
they express something very similar, but I might be wrong at that, too.

David



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-08 21:04   ` emacs.gnus Hanak David
@ 2003-06-09  9:16     ` Kai Großjohann
  2003-06-09 12:24       ` emacs.gnus Hanak David
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-06-09  9:16 UTC (permalink / raw)


Hanak David <dhanak@inf.bme.hu> writes:

> On Sun, 08 Jun 2003, Kai Großjohann wrote:
>
>> I haven't tested it, only skimmed the source.  It looks way cool.  Do
>> you have paperwork on file?  It would be just dandy if it could be
>> incorporated.
>
> I'm glad you liked it.  But what do you exactly mean by "paperwork on
> file"?  Do you need my official permission to incorporate my patch?  If
> this mail is enough, you have it.

The FSF wants to have a copyright assignment for everything that is
part of Emacs.  This way, when somebody violates the GPL, the FSF can
defend it.  I understand that if many people hold the copyright for
pieces of Emacs, then those people would have to cooperate to defend
the copyright.

>> One minor thing: it seems that the function has a similar purpose as
>> other backend functions, which are conventionally called
>> nnchoke-request-foo or nnchoke-retrieve-bar, it seems.  Also, I
>> wonder if you used the same mechanism as for the other backend
>> functions?  If not, it might be useful to do that.
>
> I'm not very familiar with the interior design of Gnus, so I didn't notice
> the request and retreive functions.  If you feel that a name like that
> would suit your taste (or Gnus) better, go ahead, rename it.

He he, I was hoping I could be lazy and let you rename it :-)

> But again, I fail to understand what do you mean by the "same
> mechanism as for the other backend functions".  I admit that I took
> the name and docstring of nnml-ignore-active-file from
> nnfolder-ignore-active-file, because I felt they express something
> very similar, but I might be wrong at that, too.

As an example, here is how Gnus invokes nnchoke-request-article:

(defun gnus-request-article (article group &optional buffer)
  "Request the ARTICLE in GROUP.
ARTICLE can either be an article number or an article Message-ID.
If BUFFER, insert the article in that group."
  (let ((gnus-command-method (gnus-find-method-for-group group)))
    (funcall (gnus-get-function gnus-command-method 'request-article)
	     article (gnus-group-real-name group)
	     (nth 1 gnus-command-method) buffer)))

You have a function gnus-group-article-list which is intended to do
the same, but it uses a different mechanism.  For example, the
variable gnus-command-method is special and referenced in a number of
places, so it's probably useful to let-bind it for
gnus-group-article-list, as well (instead of method).  And you don't
use gnus-get-function to find the right function to invoke.

It might be possible to slightly tweak the documentation for
nnml-ignore-active file to make it clear that any non-nil value is
not sufficient, it has to be t according to your code.  Or maybe
change the code instead :-)

I hope I'm not offending you with this stuff, I think you have a
really great idea here and it seems you could implement it without
loss in efficiency, which is quite nifty.  I'm just talking about
little technicalities, not intending to belittle your achievement.
-- 
This line is not blank.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-09  9:16     ` emacs.gnus Kai Großjohann
@ 2003-06-09 12:24       ` Hanak David
  2003-06-09 13:34         ` emacs.gnus Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Hanak David @ 2003-06-09 12:24 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

On Mon, 09 Jun 2003, Kai Großjohann wrote:

> The FSF wants to have a copyright assignment for everything that is
> part of Emacs.  This way, when somebody violates the GPL, the FSF can
> defend it.  I understand that if many people hold the copyright for
> pieces of Emacs, then those people would have to cooperate to defend
> the copyright.

That sounds perfectly reasonable.  But what do I have to do to assign all
copyrights to the FSF?  (I've checked the FSF homepage, but haven't found
the HOW, only the WHY.)

> As an example, here is how Gnus invokes nnchoke-request-article:
[...]
> You have a function gnus-group-article-list which is intended to do
> the same, but it uses a different mechanism.  For example, the

Wow, that's cool.  Thanks for letting me know.

> I hope I'm not offending you with this stuff, I think you have a

Not offended, on the contrary.


So, I've recoded it following your guidelines.  In fact, I've found a
function called gnus-request-group-articles, which, according to its
docstring, is doing the same as gnus-group-article-list.  There was no
equivalent backend function for nnml, so I've done that, but there *was*
one for the nntp backend, which always returned t instead of a list of
article numbers.  As far as I could tell, these functions weren't used at
all, so I removed nntp-request-group-articles with another patch. :-{

I could have taken the other road and added a new function (say,
gnus-request-group-artcile-list) to gnus-int.el which seemingly does the
same, but that doesn't sound good either.  What do you think?

New patches are attached.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus.patch --]
[-- Type: text/x-patch, Size: 2562 bytes --]

*** /usr/share/emacs/site-lisp/gnus/lisp/gnus-sum.el	2003-06-07 19:40:22.000000000 +0200
--- ./gnus-sum.el	2003-06-09 12:05:22.000000000 +0200
***************
*** 5242,5247 ****
--- 5242,5248 ----
  	      ;; articles in the group, or (if that's nil), the
  	      ;; articles in the cache.
  	      (or
+ 	       (gnus-request-group-articles group)
  	       (gnus-uncompress-range (gnus-active group))
  	       (gnus-cache-articles-in-group group))
  	    ;; Select only the "normal" subset of articles.
*** /usr/share/emacs/site-lisp/gnus/lisp/nnml.el	2003-05-01 16:23:15.000000000 +0200
--- ./nnml.el	2003-06-09 13:29:21.000000000 +0200
***************
*** 84,89 ****
--- 84,96 ----
  (defvoo nnml-use-compressed-files nil
    "If non-nil, allow using compressed message files.")
  
+ (defvoo nnml-ignore-active-file nil
+   "If t or matches the group name as a regexp, the active file is ignored
+ when retrieving the list of existing articles.  This causes nnml to do some
+ extra work in order to determine the true active ranges of a group.  Note
+ that the active file is still saved, but its values are not used.  This
+ costs some extra time when scanning a group when opening it.")
+ 
  \f
  
  (defconst nnml-version "nnml 1.0"
***************
*** 1007,1012 ****
--- 1014,1031 ----
  	(nnml-save-marks group server)
  	(nnheader-message 7 "Bootstrapping marks for %s...done" group)))))
  
+ (deffoo nnml-request-group-articles (group &optional server)
+   "Return the list of existing articles in GROUP if
+ `nnml-ignore-active-file' is t or matches the group name as a regexp,
+ otherwise return nil."
+   (if (or (eq nnml-ignore-active-file t)
+ 	  (and (stringp nnml-ignore-active-file)
+ 	       (string-match nnml-ignore-active-file group)))
+       (sort (nnheader-directory-articles
+ 	     (nnheader-group-pathname (gnus-group-real-name group)
+ 				      nnml-directory))
+ 	    '<)))
+ 
  (provide 'nnml)
  
  ;;; nnml.el ends here
*** /usr/share/emacs/site-lisp/gnus/lisp/nntp.el	2003-05-02 19:55:56.000000000 +0200
--- ./nntp.el	2003-06-09 13:31:08.000000000 +0200
***************
*** 845,856 ****
     nil server
     (nntp-send-command "^\\.*\r?\n" "LIST ACTIVE" group)))
  
- (deffoo nntp-request-group-articles (group &optional server)
-   "Return the list of existing articles in GROUP."
-   (nntp-with-open-group
-    nil server
-    (nntp-send-command "^\\.*\r?\n" "LISTGROUP" group)))
- 
  (deffoo nntp-request-article (article &optional group server buffer command)
    (nntp-with-open-group
      group server
--- 845,850 ----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-09 12:24       ` emacs.gnus Hanak David
@ 2003-06-09 13:34         ` Kai Großjohann
  2003-06-09 15:00           ` emacs.gnus Hanak David
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-06-09 13:34 UTC (permalink / raw)


Hanak David <dhanak@inf.bme.hu> writes:

> On Mon, 09 Jun 2003, Kai Großjohann wrote:
>
>> The FSF wants to have a copyright assignment for everything that is
>> part of Emacs.  This way, when somebody violates the GPL, the FSF can
>> defend it.  I understand that if many people hold the copyright for
>> pieces of Emacs, then those people would have to cooperate to defend
>> the copyright.
>
> That sounds perfectly reasonable.  But what do I have to do to assign all
> copyrights to the FSF?  (I've checked the FSF homepage, but haven't found
> the HOW, only the WHY.)

Sent by private mail.

> So, I've recoded it following your guidelines.  In fact, I've found a
> function called gnus-request-group-articles, which, according to its
> docstring, is doing the same as gnus-group-article-list.  There was no
> equivalent backend function for nnml, so I've done that, but there *was*
> one for the nntp backend, which always returned t instead of a list of
> article numbers.  As far as I could tell, these functions weren't used at
> all, so I removed nntp-request-group-articles with another patch. :-{

I think that it is okay for the function to return t.  The Gnus
manual also has some stuff on how the nnchoke-request-foo functions
work.  In particular, see the node (gnus)Back End Interface, which
says:

/----
|    There are two groups of interface functions: "required functions",
| which must be present, and "optional functions", which Gnus will always
| check for presence before attempting to call 'em.
| 
|    All these functions are expected to return data in the buffer
| `nntp-server-buffer' (` *nntpd*'), which is somewhat unfortunately
| named, but we'll have to live with it.  When I talk about "resulting
| data", I always refer to the data in that buffer.  When I talk about
| "return value", I talk about the function value returned by the
| function call.  Functions that fail should return `nil' as the return
| value.
\----

So t means success, and the "return value" needs to be grabbed from
the server buffer.

> I could have taken the other road and added a new function (say,
> gnus-request-group-artcile-list) to gnus-int.el which seemingly does the
> same, but that doesn't sound good either.  What do you think?

I think the right thing to do is to use the existing function.

> *** /usr/share/emacs/site-lisp/gnus/lisp/gnus-sum.el	2003-06-07 19:40:22.000000000 +0200
> --- ./gnus-sum.el	2003-06-09 12:05:22.000000000 +0200
> ***************
> *** 5242,5247 ****
> --- 5242,5248 ----
>   	      ;; articles in the group, or (if that's nil), the
>   	      ;; articles in the cache.
>   	      (or
> + 	       (gnus-request-group-articles group)

Here, you should probably call gnus-request-group-articles and then
snarf the data from the nntp-server-buffer.  Or, maybe make a
convenience function which does this.

-- 
This line is not blank.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-09 13:34         ` emacs.gnus Kai Großjohann
@ 2003-06-09 15:00           ` Hanak David
  2003-06-09 17:34             ` emacs.gnus Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Hanak David @ 2003-06-09 15:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

On Mon, 09 Jun 2003, Kai Großjohann wrote:

> Hanak David <dhanak@inf.bme.hu> writes:
>
>> That sounds perfectly reasonable.  But what do I have to do to assign all
>> copyrights to the FSF?  (I've checked the FSF homepage, but haven't found
>> the HOW, only the WHY.)
>
> Sent by private mail.

Thanks, request submitted, waiting.  (Boy, this is complicated!)

> I think that it is okay for the function to return t.  The Gnus
> manual also has some stuff on how the nnchoke-request-foo functions
> work.  In particular, see the node (gnus)Back End Interface, which

Ah.  I must remember to RTFM before asking stupid questions and making even
more stupid suggestions.

> I think the right thing to do is to use the existing function.

Yep, we agree.  Although this way we loose efficiency, because first we
print the article list into the nntp buffer and then reparse this buffer
and convert it back to a list.

The "third generation" of patches follow.

David

P.S.: I'm begginning to think that it would have taken you less time to
implement the idea yourself than to instruct me how to do it. ;-)  Thanks
for "investing" in me.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus.patch --]
[-- Type: text/x-patch, Size: 3027 bytes --]

*** /usr/share/emacs/site-lisp/gnus/lisp/gnus-sum.el	2003-06-07 19:40:22.000000000 +0200
--- ./gnus-sum.el	2003-06-09 16:44:28.000000000 +0200
***************
*** 1092,1097 ****
--- 1092,1106 ----
    :type 'boolean
    :group 'gnus-article-mime)
  
+ (defcustom gnus-count-articles-in-groups nil
+ "*Regexp to match groups whose article count should be determined
+ accurately upon entering the group.  Non-matching groups are conventionally
+ looked up in the active info.
+ 
+ If t, matches all groups, if nil, matches none."
+   :type '(choice regexp (const t) (const nil))
+   :group 'gnus-summary)
+ 
  ;;; Internal variables
  
  (defvar gnus-summary-display-cache nil)
***************
*** 5226,5231 ****
--- 5235,5261 ----
        (memq article gnus-newsgroup-recent))
       (t t))))
  
+ (defun gnus-get-group-articles (group)
+   "Return a list of group articles if `gnus-count-articles-in-groups'
+ matches GROUP as a regexp.  Otherwise return nil."
+   (when (and gnus-count-articles-in-groups
+ 	     (or (eq gnus-count-articles-in-groups t)
+ 		 (string-match gnus-count-articles-in-groups group)))
+     (let ((article-list))
+       (save-excursion
+ 	(gnus-request-group-articles group)
+ 	(set-buffer nntp-server-buffer)
+ 	(goto-char (point-max))
+ 	(forward-line -2)		; skip "."
+ 	(while (not (looking-at "^211 Article list follows$"))
+ 	  (setq article-list
+ 		(cons (string-to-number (buffer-substring-no-properties
+ 					 (line-beginning-position)
+ 					 (line-end-position)))
+ 		      article-list))
+ 	  (forward-line -1)))
+       article-list)))
+ 	
  (defun gnus-articles-to-read (group &optional read-all)
    "Find out what articles the user wants to read."
    (let* ((display (gnus-group-find-parameter group 'display))
***************
*** 5242,5247 ****
--- 5272,5278 ----
  	      ;; articles in the group, or (if that's nil), the
  	      ;; articles in the cache.
  	      (or
+ 	       (gnus-get-group-articles group)
  	       (gnus-uncompress-range (gnus-active group))
  	       (gnus-cache-articles-in-group group))
  	    ;; Select only the "normal" subset of articles.
*** /usr/share/emacs/site-lisp/gnus/lisp/nnml.el	2003-05-01 16:23:15.000000000 +0200
--- ./nnml.el	2003-06-09 16:10:57.000000000 +0200
***************
*** 1007,1012 ****
--- 1007,1029 ----
  	(nnml-save-marks group server)
  	(nnheader-message 7 "Bootstrapping marks for %s...done" group)))))
  
+ (deffoo nnml-request-group-articles (group &optional server)
+   "Return the list of existing articles in GROUP."
+   (let ((article-list (sort (nnheader-directory-articles
+ 			     (nnheader-group-pathname
+ 			      (gnus-group-real-name group)
+ 			      nnml-directory))
+ 			    '<)))
+     (condition-case ()
+ 	(save-excursion
+ 	  (set-buffer nntp-server-buffer)
+ 	  (erase-buffer)
+ 	  (insert "211 Article list follows\n")
+ 	  (mapcar '(lambda (x) (insert (number-to-string x) "\n")) article-list)
+ 	  (insert ".\n")
+ 	  t)
+       (error nil))))
+ 
  (provide 'nnml)
  
  ;;; nnml.el ends here

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-09 15:00           ` emacs.gnus Hanak David
@ 2003-06-09 17:34             ` Kai Großjohann
  2003-06-10 13:33               ` emacs.gnus Hanak David
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-06-09 17:34 UTC (permalink / raw)


Hanak David <dhanak@inf.bme.hu> writes:

> On Mon, 09 Jun 2003, Kai Großjohann wrote:
>
>> Hanak David <dhanak@inf.bme.hu> writes:
>>
>>> That sounds perfectly reasonable.  But what do I have to do to assign all
>>> copyrights to the FSF?  (I've checked the FSF homepage, but haven't found
>>> the HOW, only the WHY.)
>>
>> Sent by private mail.
>
> Thanks, request submitted, waiting.  (Boy, this is complicated!)

Wait till you find out about German bureaucracy....

>> I think that it is okay for the function to return t.  The Gnus
>> manual also has some stuff on how the nnchoke-request-foo functions
>> work.  In particular, see the node (gnus)Back End Interface, which
>
> Ah.  I must remember to RTFM before asking stupid questions and making even
> more stupid suggestions.

It's not easy to RTFM because it's long.

>> I think the right thing to do is to use the existing function.
>
> Yep, we agree.  Although this way we loose efficiency, because first we
> print the article list into the nntp buffer and then reparse this buffer
> and convert it back to a list.

Yes, it appears inconvenient, but consider the other backends.  In
particular, NNTP.

Hm.

We could still offer two alternative functions,
nnchoke-request-group-articles and nnchoke-get-group-articles-list,
say.  Then gnus-get-group-articles could call the latter if it
exists, and the former if not.

Sounds like a plan.  WDYT?

A remark on the code: you could try to delete junk from the beginning
and the end of the buffer, giving you just the list of numbers.  Then
you add "(" at the beginning and ")" at the end (sans quotes).  Then
you go to the "(" and invoke `read', and lo! there's your list.

The Emacs Lisp reader is not quite as powerful as the Common Lisp
reader, but still it's a nifty tool, not to be underestimated.

> P.S.: I'm begginning to think that it would have taken you less time to
> implement the idea yourself than to instruct me how to do it. ;-)  Thanks
> for "investing" in me.

Thank YOU for contributing!

-- 
This line is not blank.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-09 17:34             ` emacs.gnus Kai Großjohann
@ 2003-06-10 13:33               ` Hanak David
  2003-06-10 16:58                 ` emacs.gnus Kai Großjohann
  0 siblings, 1 reply; 10+ messages in thread
From: Hanak David @ 2003-06-10 13:33 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1927 bytes --]

On Mon, 09 Jun 2003, Kai Großjohann wrote:

> We could still offer two alternative functions,
> nnchoke-request-group-articles and nnchoke-get-group-articles-list,
> say.  Then gnus-get-group-articles could call the latter if it
> exists, and the former if not.
>
> Sounds like a plan.  WDYT?

I like it.  So I renamed gnus-get-group-articles to
gnus-get-group-artiles-list, which calls nnchoke-get-group-articles-list if
it exists, otherwise calls nnchoke-request-group-articles and parses the
nntp-server-buffer.  How does it sound?

> A remark on the code: you could try to delete junk from the beginning
> and the end of the buffer, giving you just the list of numbers.  Then
> you add "(" at the beginning and ")" at the end (sans quotes).  Then
> you go to the "(" and invoke `read', and lo! there's your list.

Right!  Done that, too.  So, again, here's the patch.

One remark, though.  The following pattern:

/----
|  (let ((gnus-command-method (gnus-find-method-for-group group))
|	(func 'wild-and-crazy-things))
|    (when (gnus-check-backend-function func group)
|      (funcall (gnus-get-function gnus-command-method func)
|	       (gnus-group-real-name group) (nth 1 gnus-command-method)))))
\----

occurs very often in gnus-int.el, and now (with my contribution) appears in
gnus-sum.el, too.  Wouldn't it be reasonable to create a general purpose
function for this, like:

(defun gnus-group-backend-function (func group)
  "Call backend function FUNC on GROUP."
  (let ((gnus-command-method (gnus-find-method-for-group group)))
    (when (gnus-check-backend-function func group)
      (funcall (gnus-get-function gnus-command-method func)
	       (gnus-group-real-name group) (nth 1 gnus-command-method)))))

And then it would be enough to write:

(defun gnus-request-group-articles (group)
  "Request a list of existing articles in GROUP."
  (gnus-group-backend-function 'request-group-articles group))

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus.patch --]
[-- Type: text/x-patch, Size: 3844 bytes --]

*** /usr/share/emacs/site-lisp/gnus/lisp/gnus-sum.el	2003-06-07 19:40:22.000000000 +0200
--- ./gnus-sum.el	2003-06-10 15:07:41.000000000 +0200
***************
*** 1092,1097 ****
--- 1092,1106 ----
    :type 'boolean
    :group 'gnus-article-mime)
  
+ (defcustom gnus-count-articles-in-groups nil
+ "*Regexp to match groups whose article count should be determined
+ accurately upon entering the group.  Non-matching groups are conventionally
+ looked up in the active info.
+ 
+ If t, matches all groups, if nil, matches none."
+   :type '(choice regexp (const t) (const nil))
+   :group 'gnus-summary)
+ 
  ;;; Internal variables
  
  (defvar gnus-summary-display-cache nil)
***************
*** 5226,5231 ****
--- 5235,5273 ----
        (memq article gnus-newsgroup-recent))
       (t t))))
  
+ (defun gnus-get-group-articles-list (group)
+   "Return a list of group articles if `gnus-count-articles-in-groups'
+ matches GROUP as a regexp.  Otherwise return nil."
+   (let ((group-real-name (gnus-group-real-name group)))
+     (when (and gnus-count-articles-in-groups
+ 	       (or (eq gnus-count-articles-in-groups t)
+ 		   (string-match gnus-count-articles-in-groups group)))
+       (let ((gnus-command-method (gnus-find-method-for-group group))
+ 	    (func1 'get-group-articles-list)
+ 	    (func2 'request-group-articles))
+ 	(or (and (gnus-check-backend-function func1 group)
+ 		 (funcall (gnus-get-function gnus-command-method func1)
+ 			  group-real-name (nth 1 gnus-command-method)))
+ 	    (and (gnus-check-backend-function func2 group)
+ 		 (funcall (gnus-get-function gnus-command-method func2)
+ 			  group-real-name (nth 1 gnus-command-method))
+ 		 (gnus-parse-group-articles-list)))))))
+ 
+ (defun gnus-parse-group-articles-list ()
+   "Parse article list from `nntp-server-buffer'."
+   (condition-case ()
+       (save-excursion
+ 	(set-buffer nntp-server-buffer)
+ 	(goto-char (point-min))		; first line contains comment
+ 	(delete-region (point) (line-end-position))
+ 	(insert "(")
+ 	(goto-char (point-max))
+ 	(forward-line -1)		; last line contains "."
+ 	(delete-region (point) (line-end-position))
+ 	(insert ")")
+ 	(read (point-min-marker)))
+     (error nil)))
+ 
  (defun gnus-articles-to-read (group &optional read-all)
    "Find out what articles the user wants to read."
    (let* ((display (gnus-group-find-parameter group 'display))
***************
*** 5242,5247 ****
--- 5284,5290 ----
  	      ;; articles in the group, or (if that's nil), the
  	      ;; articles in the cache.
  	      (or
+ 	       (gnus-get-group-articles-list group)
  	       (gnus-uncompress-range (gnus-active group))
  	       (gnus-cache-articles-in-group group))
  	    ;; Select only the "normal" subset of articles.
*** /usr/share/emacs/site-lisp/gnus/lisp/nnml.el	2003-05-01 16:23:15.000000000 +0200
--- ./nnml.el	2003-06-10 15:11:41.000000000 +0200
***************
*** 1007,1012 ****
--- 1007,1033 ----
  	(nnml-save-marks group server)
  	(nnheader-message 7 "Bootstrapping marks for %s...done" group)))))
  
+ (deffoo nnml-get-group-articles-list (group &optional server)
+   "Return the list of existing articles in GROUP directly.  See also
+ `nnml-request-group-articles'."
+   (sort (nnheader-directory-articles
+ 	 (nnheader-group-pathname group nnml-directory))
+ 	'<))
+ 
+ (deffoo nnml-request-group-articles (group &optional server)
+   "Return the list of existing articles in GROUP in `nntp-server-buffer'."
+   (let ((article-list (nnml-get-group-articles-list group server)))
+     (condition-case ()
+ 	(save-excursion
+ 	  (set-buffer nntp-server-buffer)
+ 	  (erase-buffer)
+ 	  (insert "211 Article list follows\n")
+ 	  (mapcar '(lambda (x) (insert (number-to-string x) "\n"))
+ 		  article-list)
+ 	  (insert ".\n")
+ 	  t)
+       (error nil))))
+ 
  (provide 'nnml)
  
  ;;; nnml.el ends here

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: emacs.gnus
  2003-06-10 13:33               ` emacs.gnus Hanak David
@ 2003-06-10 16:58                 ` Kai Großjohann
  0 siblings, 0 replies; 10+ messages in thread
From: Kai Großjohann @ 2003-06-10 16:58 UTC (permalink / raw)


Hanak David <dhanak@inf.bme.hu> writes:

> Right!  Done that, too.  So, again, here's the patch.

Okay, I have now marked the patch as todo.  Could you tell when the
copyright assignment thing has been processed?  I gather you sent the
request to the FSF, so they have to send you a form to sign.  I guess
it's okay to incorporate the patch at that time, though technically
we should wait until they have recorded everything...

> One remark, though.  The following pattern: [...]
> occurs very often in gnus-int.el, and now (with my contribution) appears in
> gnus-sum.el, too.  Wouldn't it be reasonable to create a general purpose
> function for this, like: [...]

Good idea!

[X] send patch
-- 
This line is not blank.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-06-10 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-08 13:04 emacs.gnus Hanak David
2003-06-08 19:12 ` emacs.gnus Kai Großjohann
2003-06-08 21:04   ` emacs.gnus Hanak David
2003-06-09  9:16     ` emacs.gnus Kai Großjohann
2003-06-09 12:24       ` emacs.gnus Hanak David
2003-06-09 13:34         ` emacs.gnus Kai Großjohann
2003-06-09 15:00           ` emacs.gnus Hanak David
2003-06-09 17:34             ` emacs.gnus Kai Großjohann
2003-06-10 13:33               ` emacs.gnus Hanak David
2003-06-10 16:58                 ` emacs.gnus Kai Großjohann

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).