Gnus development mailing list
 help / color / mirror / Atom feed
* Exact article count for nnml groups
@ 2004-03-12 18:51 David Hanak
  2004-03-12 22:23 ` Jesper Harder
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Hanak @ 2004-03-12 18:51 UTC (permalink / raw)


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

Hi,

Here's a patch I submitted last June which allows the group buffer to show
exact article counts for nnml groups instead of the estimate based on the
difference of the greatest and smallest article numbers.  Kai then helped
me to improve it a bit, and then suggested to wait until the feature freeze
is over.  I guess it is over now, and it would be nice if it could be
integrated into No Gnus.  (I have all the paperwork done.)

It is fairly simple, and perhaps a little bit out of date (after all, the
lisp files I patched were probably modified since then), but since they're
only additions, it shouldn't be too hard to merge them.  Also, if anyone
writes functions to retrieve the list of existing article numbers for any
other backend than nnml, i.e., nnimap, then it should be able to display
exact article counts for those backends, too.

Cheers,

-- 
David Hanak - Research Engineer
Institute for Software Integrated Systems  |  http://www.isis.vanderbilt.edu
Vanderbilt University                      |      Work phone: (615) 343 1319
Box 1829, Station B, Nashville, TN 37235   |            PGP key ID: 266BC45F

P.S.: I tried to post this message two times before, first to the
newsgroup, second time to the ding@gnus.org list address.  However, my
posting didn't appear on the newsgroup, while other postings kept coming.
Is it because I used a spamified sender address?  I try to post with my
real address this time, hope it works.


[-- 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] 8+ messages in thread

end of thread, other threads:[~2004-05-16 14:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-12 18:51 Exact article count for nnml groups David Hanak
2004-03-12 22:23 ` Jesper Harder
2004-03-13 16:07   ` Michael Schierl
2004-03-15 17:03   ` David Hanak
2004-03-17 16:04     ` Kai Grossjohann
2004-03-12 23:56 ` Kevin Greiner
2004-05-16 14:38   ` Lars Magne Ingebrigtsen
2004-03-13 12:15 ` Kai Grossjohann

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