From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/53087 Path: main.gmane.org!not-for-mail From: Hanak David Newsgroups: gmane.emacs.gnus.general Subject: Re: emacs.gnus Date: Tue, 10 Jun 2003 15:33:44 +0200 Sender: ding-owner@lists.math.uh.edu Message-ID: References: <84of182xjx.fsf@lucy.is.informatik.uni-duisburg.de> <84znkrk3vr.fsf@lucy.is.informatik.uni-duisburg.de> <84ptln1ik5.fsf@lucy.is.informatik.uni-duisburg.de> <84u1azm9y8.fsf@lucy.is.informatik.uni-duisburg.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1055252321 4414 80.91.224.249 (10 Jun 2003 13:38:41 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 10 Jun 2003 13:38:41 +0000 (UTC) Original-X-From: ding-owner+M1631@lists.math.uh.edu Tue Jun 10 15:38:38 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19PjEM-0000cs-00 for ; Tue, 10 Jun 2003 15:32:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 19PjGC-0007tt-00; Tue, 10 Jun 2003 08:34:01 -0500 Original-Received: from sclp3.sclp.com ([64.157.176.121]) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 19PjG3-0007tl-00 for ding@lists.math.uh.edu; Tue, 10 Jun 2003 08:33:51 -0500 Original-Received: (qmail 74921 invoked by alias); 10 Jun 2003 13:33:51 -0000 Original-Received: (qmail 74916 invoked from network); 10 Jun 2003 13:33:50 -0000 Original-Received: from quimby.gnus.org (80.91.224.244) by sclp3.sclp.com with SMTP; 10 Jun 2003 13:33:50 -0000 Original-Received: from news by quimby.gnus.org with local (Exim 3.12 #1 (Debian)) id 19PjY1-0003vp-00 for ; Tue, 10 Jun 2003 15:52:25 +0200 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 165 Original-NNTP-Posting-Host: adsl244254.vnet.hu Original-X-Trace: quimby.gnus.org 1055253145 15115 62.77.244.254 (10 Jun 2003 13:52:25 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: 10 Jun 2003 13:52:25 GMT Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAwBAMAAACRVSWoAAAAGFBMVEWNZFgtIyTy9fEjGhx0 UUdMNjKajYXCxsNbs5ZQAAAByElEQVR4nG3SwY7bIBAGYFqR9NqRQ8+rSI3PiBcgKuxeiwQ5p6td cl1ZqXn9/jPYiluVHGx/mpkfE6vjuk5Tv453UqvN9xzqq+DQca4qJhrITONx/OiVp2uiRM65cpmB vfL+Tryco+KnpXJEK1mudM6sKHUWOkD3HUdEWH52PMG0K+MT7q111jlLg7MXwe/Yy1I54PJV8B33 Vpjb3aEyRpIibuUJh+qAZ+Q4pMsES0ZQwpG1IAmSVGKA69vaA0fi0C64DFIJRCnHEJmE3dWhI+GQ LKVSCm55S4wmF14hroggKjmAsArZvvk0mJhjyV6HgBf5VhPwkz2E4JVSHV8Ef1NWWskKIdmb4Amo HvilI2Ky39eqS8ln09ufzhm5fq84PpqlMnolSSHFEPOCO2wmB6Wfd8j/+Vlw3Cm9vyiv1ZXHME7H cYnWXvJfga21v1BNjPN8/Q/etuhr6+11W1mr4NzelpfcYNugDmj8Abz9g/MvQZ6m++F7aeR2IAsO KTzjce4YVIlAnNbLBnEgweMXbvwMPLa3/h8Fnbl7RR0zH3EsLytO7UNhYjSlHNoWteEvJF02OCt1 hia6PXDkE8XXRUvhAzG2LIXtDwR0zVR+ZiQLAAAAAElFTkSuQmCC User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux) Cancel-Lock: sha1:8ZzyNpIwcZCrkLz8xY6ueXHp0CU= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:53087 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:53087 --=-=-= Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gnus.patch *** /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 --=-=-=--