From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Gnus: Thread notes? Date: Wed, 13 Dec 2017 10:03:06 -0800 Message-ID: <87po7io691.fsf@ericabrahamsen.net> References: <87o9pc359b.fsf@web.de> <874lr3pz2q.fsf@ericabrahamsen.net> <87o9p6zy4f.fsf@web.de> <878tgavoio.fsf@ericabrahamsen.net> <87fu93ulhz.fsf@web.de> <87o9nq50hi.fsf@ericabrahamsen.net> <877eudsj2x.fsf@web.de> <874lpfjgb2.fsf@ericabrahamsen.net> <87indv6iup.fsf@web.de> <87wp2agxo5.fsf@ericabrahamsen.net> <87mv2om8tj.fsf@web.de> <874lovrhl1.fsf@ericabrahamsen.net> <87o9n27q9z.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1513188241 13912 195.159.176.226 (13 Dec 2017 18:04:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Dec 2017 18:04:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 13 19:03:57 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePBNt-0003Mr-FS for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Dec 2017 19:03:57 +0100 Original-Received: from localhost ([::1]:36722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBO0-0007Y2-EN for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Dec 2017 13:04:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBNM-0007SC-Qd for help-gnu-emacs@gnu.org; Wed, 13 Dec 2017 13:03:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePBNJ-0000e0-N2 for help-gnu-emacs@gnu.org; Wed, 13 Dec 2017 13:03:24 -0500 Original-Received: from [195.159.176.226] (port=46526 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePBNJ-0000cg-EK for help-gnu-emacs@gnu.org; Wed, 13 Dec 2017 13:03:21 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ePBN5-0001Ba-T3 for help-gnu-emacs@gnu.org; Wed, 13 Dec 2017 19:03:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 86 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:wYLKV2pxi9WQ6jSDRVcOcA6OPD0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115342 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: > Eric Abrahamsen writes: > >> > `gnus-alter-articles-to-read-function' [...] >> >> Interesting! I'd never looked at that option before. I'd still like to >> keep the manual command, for those who don't want this to happen >> automatically, but yes, it wouldn't be hard to refactor. > > Yes, I agree we should keep it. > >> It would also require some sort of internal caching first -- right now >> it's too slow to have it running each time you enter a group. > > In my tests, I didn't see a delay. It probably depends on how much you > used the registry. I use it pretty heavily! I'll implement this and test, and see how it shakes out. A big slow-down comes in doing the message-id-->article-number lookup each time. In the past I saved article numbers to the registry, before realizing that was a bad idea, but I've been considering re-introducing a per-Gnus-session cache, which would be almost as helpful. >> > (1) I think `gnus-alter-articles-to-read-function' should better >> > default to a function (lambda (_group-name article-list) >> > article-list), not to nil, so that one could use `add-function' on >> > it. >> >> Or the code could coerce the value to a list, and map all the functions. >> Maybe that would be more intuitive than `add-function'? > > But for a list, you can't control how the functions are combined. It is > always the same, e.g., all the return values are appended. Then it is > impossible to use the thing for limiting shown articles. That's quite a > limitation. With `add-function', there would not be such a restriction > - and one could use priorities (aka advice depth) to control the order > of processing. > > But I know some people refrain from using `add-function'. We could > support both mechanisms at the same time: If > `gnus-alter-articles-to-read-function' is `functionp', call it as a > function, else, treat it as a list (of functions). Right, that's what I was thinking of. I do think it's bad in principle to expect uses of `add-function'. The following feels awkward to me, but I can't find any sort of "reverse reduce" function in the libs. Is there a sexier way of doing this? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=alter-articles.diff diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 4dee306c81..eae0ebf130 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -5917,8 +5917,12 @@ gnus-articles-to-read (when gnus-alter-articles-to-read-function (setq articles (sort - (funcall gnus-alter-articles-to-read-function - gnus-newsgroup-name articles) + (if (functionp gnus-alter-articles-to-read-function) + (funcall gnus-alter-articles-to-read-function + gnus-newsgroup-name articles) + (let ((ret articles)) + (dolist (f gnus-alter-articles-to-read-function) + (setq ret (funcall f gnus-newsgroup-name ret))))) '<))) articles))) --=-=-= Content-Type: text/plain Eric --=-=-=--