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 54347431FAF for ; Sat, 14 Apr 2012 13:34:57 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 U762HNNAJI82 for ; Sat, 14 Apr 2012 13:34:56 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7AAA0431FAE for ; Sat, 14 Apr 2012 13:34:56 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1SJ9gJ-0000Gy-RD; Sat, 14 Apr 2012 21:34:52 +0100 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1SJ9gJ-0006OO-Hi; Sat, 14 Apr 2012 21:34:51 +0100 From: Mark Walters To: Jameson Graef Rollins , Notmuch Mail Subject: Re: [PATCH 2/5] emacs: allow notmuch-tag to accept string inputs and prompt for tags In-Reply-To: <1334429574-12918-3-git-send-email-jrollins@finestructure.net> References: <1333845338-22960-1-git-send-email-jrollins@finestructure.net> <1334429574-12918-1-git-send-email-jrollins@finestructure.net> <1334429574-12918-2-git-send-email-jrollins@finestructure.net> <1334429574-12918-3-git-send-email-jrollins@finestructure.net> User-Agent: Notmuch/0.12+110~gbc97b4a (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Sat, 14 Apr 2012 21:35:09 +0100 Message-ID: <878vhyt5ky.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 94.192.233.223 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: e0635b4381a868d44440cf1ae961df84 (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay * domain * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sat, 14 Apr 2012 20:34:57 -0000 On Sat, 14 Apr 2012, Jameson Graef Rollins wrote: > notmuch-tag is extended to accept various formats of the tag changes. > In particular, user prompting for tag changes is now incorporated > here, so it is common for modes. > > The tag binary and the notmuch-{before,after}-tag-hooks are only > called if tag changes is non-nil. > > The actual tag-changes applied are returned by the function. > --- > emacs/notmuch-tag.el | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el > index c25cff8..dd7f9d7 100644 > --- a/emacs/notmuch-tag.el > +++ b/emacs/notmuch-tag.el > @@ -108,18 +108,26 @@ from TAGS if present." > (error "Changed tag must be of the form `+this_tag' or `-that_tag'"))))) > (sort result-tags 'string<))) > > -(defun notmuch-tag (query &rest tag-changes) > +(defun notmuch-tag (query &optional tag-changes) > "Add/remove tags in TAG-CHANGES to messages matching QUERY. > > -TAG-CHANGES should be a list of strings of the form \"+tag\" or > -\"-tag\" and QUERY should be a string containing the > -search-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'"))) > @@ -128,7 +136,9 @@ notmuch-after-tag-hook will be run." > (run-hooks 'notmuch-before-tag-hook) > (apply 'notmuch-call-notmuch-process "tag" > (append tag-changes (list "--" query))) > - (run-hooks 'notmuch-after-tag-hook))) > + (run-hooks 'notmuch-after-tag-hook)) Hi The series looks good to me with one minor point: > + ;; return the list of actual changed tags > + tag-changes) I found the comment confusing: I read it as the function looked at the tags the message had before and after and returned the difference. Perhaps something like "in all cases we return tag-changes as a list" (and a similar comment for the commit message). Best wishes Mark