From eb1bc5a18a6693c8a19224f6427ffc74919f9538 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins Date: Tue, 10 Apr 2012 00:15:15 +1700 Subject: [PATCH] Re: [PATCH 7/8] emacs: modify show tag functions to use new notmuch-tag interface --- 4e/f3d8f5b61738462990cee02944dc2c7d39e155 | 156 ++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 4e/f3d8f5b61738462990cee02944dc2c7d39e155 diff --git a/4e/f3d8f5b61738462990cee02944dc2c7d39e155 b/4e/f3d8f5b61738462990cee02944dc2c7d39e155 new file mode 100644 index 000000000..48aed75a4 --- /dev/null +++ b/4e/f3d8f5b61738462990cee02944dc2c7d39e155 @@ -0,0 +1,156 @@ +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 6C198418C31 + for ; Mon, 9 Apr 2012 00:15:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.29 +X-Spam-Level: +X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 9ZQ4XpWdA12P for ; + Mon, 9 Apr 2012 00:15:23 -0700 (PDT) +Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu + [131.215.239.19]) + by olra.theworths.org (Postfix) with ESMTP id B696F418C2C + for ; Mon, 9 Apr 2012 00:15:23 -0700 (PDT) +Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) + by earth-doxen-postvirus (Postfix) with ESMTP id 3700C66E00FE; + Mon, 9 Apr 2012 00:15:21 -0700 (PDT) +X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new +Received: from finestructure.net (unknown [76.89.193.65]) + (Authenticated sender: jrollins) + by earth-doxen-submit (Postfix) with ESMTP id 291B566E00DD; + Mon, 9 Apr 2012 00:15:18 -0700 (PDT) +Received: by finestructure.net (Postfix, from userid 1000) + id CEF3B360; Mon, 9 Apr 2012 00:15:17 -0700 (PDT) +From: Jameson Graef Rollins +To: Mark Walters , + Notmuch Mail +Subject: Re: [PATCH 7/8] emacs: modify show tag functions to use new + notmuch-tag interface +In-Reply-To: <87zkam6fn3.fsf@qmul.ac.uk> +References: <1333354853-25729-1-git-send-email-jrollins@finestructure.net> + <1333845338-22960-1-git-send-email-jrollins@finestructure.net> + <1333845338-22960-2-git-send-email-jrollins@finestructure.net> + <1333845338-22960-3-git-send-email-jrollins@finestructure.net> + <1333845338-22960-4-git-send-email-jrollins@finestructure.net> + <1333845338-22960-5-git-send-email-jrollins@finestructure.net> + <1333845338-22960-6-git-send-email-jrollins@finestructure.net> + <1333845338-22960-7-git-send-email-jrollins@finestructure.net> + <1333845338-22960-8-git-send-email-jrollins@finestructure.net> + <87zkam6fn3.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.12+108~g7bdb40c (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 09 Apr 2012 00:15:15 -0700 +Message-ID: <87d37hl6kc.fsf@servo.finestructure.net> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +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: Mon, 09 Apr 2012 07:15:24 -0000 + +--=-=-= + +On Sat, Apr 07 2012, Mark Walters wrote: +> I think this is what is making the two tests fail: they count the number +> of invocations of notmuch and in case there is one invocation of notmuch +> show and one of notmuch tag -unread message-id, where before it was just +> the single notmuch show. + +Good call, Mark. After a bit of testing it looks like that is what's +going on. I was confused, since I had thought that the call to +notmuch-show should have involved two notmuch calls originally as well, +one for retrieving the message and the other removing the unread tag. +However, it appears the messages in those tests don't have unread tags +after all. Not sure why, but that explains it. + +So I guess the upshot is that moving all the common prompting and tag +validation stuff into notmuch-tag means that in certain cases there will +be extra notmuch calls, even if no tags are changed. Is that a problem? + +What I can do, though, is add extra validation to notmuch-tag to not +actually call notmuch tag, or any of the pre- and post- tagging hooks, +if no tags are changing. This will still require one call to notmuch to +retrieve the current set of tags for the query, but at least it wont tag +or call the hooks if nothing is changing. That seems reasonable to me, +but please let me know if you think it's not. + +I've pasted below a new version of notmuch-tag that addresses these +issues. Let me know what you think, and I'll resubmit the series. + +jamie. + + +(defun notmuch-tag (query &optional tag-changes) + "Add/remove tags in TAG-CHANGES to messages matching QUERY. + +QUERY should be a string containing the search-terms. +TAG-CHANGES can take multiple forms. If TAG-CHANGES is a list of +strings of the form \"+tag\" or \"-tag\" then those are the tag +changes applied. If TAG-CHANGES is a string then it is +interpreted as a single tag change. If TAG-CHANGES is the string +\"-\" or \"+\", or null, then the user is prompted to enter the +tag changes. + +Note: Other code should always use this function alter tags of +messages instead of running (notmuch-call-notmuch-process \"tag\" ..) +directly, so that hooks specified in notmuch-before-tag-hook and +notmuch-after-tag-hook will be run." + ;; Perform some validation + (if (string-or-null-p tag-changes) + (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes)) + (setq tag-changes (notmuch-read-tag-changes tag-changes query)) + (setq tag-changes (list tag-changes)))) + (mapc (lambda (tag-change) + (unless (string-match-p "^[-+]\\S-+$" tag-change) + (error "Tag must be of the form `+this_tag' or `-that_tag'"))) + tag-changes) + (let* ((current-tags (notmuch-tag-completions (list query))) + (new-tags (notmuch-update-tags current-tags tag-changes))) + (if (equal current-tags new-tags) + ;; if no tags are changing, return nil + nil + (run-hooks 'notmuch-before-tag-hook) + (apply 'notmuch-call-notmuch-process "tag" + (append tag-changes (list "--" query))) + (run-hooks 'notmuch-after-tag-hook) + ;; otherwise, return the list of actual changed tags + tag-changes))) + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iQIcBAEBCAAGBQJPgoyDAAoJEO00zqvie6q88ksP/3IfJ97TQK/1FFlqom2AbXye +1GuTX/i5IfNO7RHOB7e3t0xRLuEKuAavpgMXM/MiCg1Wwemd7/Zdlqy23aFvfpw6 +vzwvt2MRov+I4qs8CEL4Jxwx6rtxBa482+m4CYmPnPNtQZ0Ni+GfHGC1+6LAKmN3 +6dTUsPeJGqu2Z+GTCG7q1zEQC+LMju3QM2M2ryhWmaPd54thfKGkSgkFjrqwuooh +h5+JsmmwaRJLw3eGozl8LQFH18/pi5xRyCJjBZeBqQM0ANRsewJxfEXno2Kx4XHo +8t9GXJoEnQsWAZMy7jQH9GbJ33qHdq2EIX5OzNQyRWBMhe6AdDwX0FEL7QiUCyd4 +mimpq26jHCg2fZrpD5W33Xym0XYIsLIpgVJqLz3+6BGbOlyjtaBDi/+ol+Mugwp5 +bqlXj/2BYZK673DqxmzSatEHZECxcJ9dQ6dfWaxQS/4rl0C2crlif6CASU3SsL63 +Ba/jPMUt1wlxM/YzoHwiLVxGmvln/ri0enRW6k87snTMR8pBmt10qXHBuLl5J4E0 +WfQjE/yLvoP/xjiddJo7tdnKDRmGsu++obiP0Hcvexr1/dqRyfFXOfsEWFXEKjUi +spQ75Q9qYv/hUSRD87XZpJBQ76NaUK+HNACZ7EFTaotlpsTwLbGd0pqdtPFw9mVS +RLVGTsX/alSrNDzr9IIr +=zAnc +-----END PGP SIGNATURE----- +--=-=-=-- -- 2.26.2