Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C9CA8431FD0 for ; Wed, 7 Dec 2011 12:10:17 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pa6+3yCnrE44 for ; Wed, 7 Dec 2011 12:10:15 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id B3F20431FB6 for ; Wed, 7 Dec 2011 12:10:15 -0800 (PST) X-AuditID: 1209190c-b7f806d0000008d6-a9-4edfc82741a7 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 9F.B9.02262.728CFDE4; Wed, 7 Dec 2011 15:10:15 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id pB7KAECu006091; Wed, 7 Dec 2011 15:10:14 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pB7KABeh009577 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 7 Dec 2011 15:10:12 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RYNqK-0002iz-4Y; Wed, 07 Dec 2011 15:11:52 -0500 Date: Wed, 7 Dec 2011 15:11:52 -0500 From: Austin Clements To: Jani Nikula Subject: Re: [PATCH v3 0/2] notmuch hooks Message-ID: <20111207201152.GA3787@mit.edu> References: <7fbe6befcf31881a9bca672f55b93501249a220c.1322859389.git.jani@nikula.org> <87d3c1rtcq.fsf@servo.finestructure.net> <87borlf4ve.fsf@hermes.hocat.ca> <87mxb4b6l9.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mxb4b6l9.fsf@nikula.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGKsWRmVeSWpSXmKPExsUixG6noqt+4r6fwYMl/BZN050t9uzzsrh+ cyazxf29C9gdWDzunubyuHX/NbvHs1W3mD0mPJ7PFMASxWWTkpqTWZZapG+XwJXx4MAX9oIm sYqe9XINjIcEuxg5OSQETCT2PfrEBmGLSVy4tx7I5uIQEtjHKLH20FEWCGc9o8S/Q9eYIJwT TBKHdl9mhnCWMEo8WvSOEaSfRUBFYuv6FewgNpuAhsS2/cvB4iICihKbT+5nBGlgFmhnlHjy dhMzSEJYQFPix6xGsCJeAW2JVdc2MEJMfQW0b+cGNoiEoMTJmU9YQGxmAS2JG/9eAt3BAWRL Syz/xwES5gRaduPeRLASUaAjppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxb nJyYl5dapGuol5tZopeaUrqJERT8nJI8OxjfHFQ6xCjAwajEw+u1/L6fEGtiWXFl7iFGSQ4m JVHexgNAIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8X2YB5XhTEiurUovyYVLSHCxK4rwHdzj4 CQmkJ5akZqemFqQWwWRlODiUJHi7jgM1ChalpqdWpGXmlCCkmTg4QYbzAA2vBanhLS5IzC3O TIfIn2JUlBLnXQ6SEABJZJTmwfXCktMrRnGgV4R5N+8BquIBJja4bmDoA30kwssXdRdkcEki QkqqgXFKZ/cWe7/soh/yF5TFb/6vjY58IX5w3RqjWBl1m1+zLNR8Vc6tC7M7IOjSlno9ZPqM ZQ87tMw2M5bc3iMt/zSiXmtrmFc///v0uj9TMnbwMS3j3WWz539skfIOgezSEmf1+l3/DZIC j+6Id3sqsOXqQ6NFN/dYFnXN+r5QIuutUviig3/nOyixFGckGmoxFxUnAgDAzzKrKQMAAA== Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2011 20:10:17 -0000 Quoth Jani Nikula on Dec 07 at 8:05 pm: > On Tue, 06 Dec 2011 22:16:37 -0500, Tom Prince wrote: > > On Tue, 06 Dec 2011 18:47:01 -0800, Jameson Graef Rollins wrote: > > > Also, what if we make it so that the post-new hook script only runs if > > > notmuch new processes new messages? All of my post-new functions don't > > > need to be run at all if there is no new mail. > > I think the post-new hook should be run always (provided there have been > no errors). I think it might be surprising not to, and some users might > use the hook for something other than tagging. > > > Or would it make sense to pass this information to the hook somehow? > > It would, but as I wrote in id:"87mxb8kt5r.fsf@nikula.org", I think that > should come as another patch afterwards. I know I can't decide yet what > should be passed and how. Processed message counts (added, deleted, > renamed) could be passed on the command line, but how useful is that > really? The same can be easily achieved through initial tagging. I would worry about creating any hook interface that's difficult to use correctly. For example, notmuch new could be interrupted right between processing all new messages and calling the hook; then, on the next run, it'll tell the hook that nothing happened. More generally, any message counts passed to a hook can't be better than lower bounds and I don't see how you could use such information correctly in a hook. Using an initial "new" tag that you remove at the end of a hook, though, is stable. It guarantees that the hook is aware of any new messages at least once. If a hook needs a new message count, it should run notmuch count tag:new. > Message-ids could not be passed on the command line (there just can be > too many of them) so it would require setting up a pipe and feeding them > to stdin of the hook. The post-new hook should be run after the database > has been closed, but the message-ids are not saved during notmuch new > processing. Saving them for later gets complicated for not much extra > benefit in addition to creative use of initial tagging, as far as I can > see. Plus interrupting the post-new hook with this setup would screw up > your processing if it only depended on the message-ids. I think this would have to be a separate hook that runs concurrently with new, both so that new doesn't have to buffer this information and so that the majority of post-new hooks that don't need this information don't have to deal with it. Though, as with passing message counts to post-new, I worry about actually do anything correctly in such a hook in the presence of interruptions and failures. > All in all, I'd postpone all of this until later. That sounds wise.