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 8A747429E3B for ; Sun, 29 Jan 2012 13:35:20 -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 FAYIoFoNxKmy for ; Sun, 29 Jan 2012 13:35:20 -0800 (PST) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id DEB15431E64 for ; Sun, 29 Jan 2012 13:35:19 -0800 (PST) X-AuditID: 1209190e-b7f7c6d0000008c3-c1-4f25bb956449 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id BA.7F.02243.59BB52F4; Sun, 29 Jan 2012 16:35:17 -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 q0TLZH8h031110; Sun, 29 Jan 2012 16:35:17 -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 q0TLZFii008701 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 29 Jan 2012 16:35:16 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RrcOJ-0008VB-HD; Sun, 29 Jan 2012 16:34:27 -0500 Date: Sun, 29 Jan 2012 16:34:27 -0500 From: Austin Clements To: Dmitry Kurochkin Subject: Re: [PATCH 1/6] emacs: move tag format validation to `notmuch-tag' function Message-ID: <20120129213427.GF17991@mit.edu> References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT0Z26W9Xf4Ot1fYurW/vZLa7fnMns wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGXsXryPvWCeQMWN7xOZGhj7eLsYOTkkBEwk tm2cywJhi0lcuLeerYuRi0NIYB+jxLK7z1kgnA2MEhOunmSHcE4ySax/u5wRwlnCKHHk/nSw fhYBVYnj66+B2WwCGhLb9oMUcXKICBhK3Lr4ihnEZhaQlvj2u5kJxBYWCJPo2n6ODcTmFdCR WD33LFiNkICnxNE9Hxkh4oISJ2c+YYHo1ZK48e8lUC8H2Jzl/zhAwpwCXhIXZu1kB7FFBVQk ppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGusl5tZopeaUrqJ ERTYnJJ8Oxi/HlQ6xCjAwajEw6u4QsVfiDWxrLgy9xCjJAeTkijv2R2q/kJ8SfkplRmJxRnx RaU5qcWHGCU4mJVEeOcsA8rxpiRWVqUW5cOkpDlYlMR51bTe+QkJpCeWpGanphakFsFkZTg4 lCR4P+8CahQsSk1PrUjLzClBSDNxcIIM5wEafgGkhre4IDG3ODMdIn+KUVFKHCIhAJLIKM2D 64UlnleM4kCvCPPeBaniASYtuO5XQIOZgAY/ZwAbXJKIkJJqYHRhubyweD+DsE3Lc71LE5In eFnMVch84fyxe/58B+1jj8tuXi8puKAudJj3/qX0U4s0ctKbtn9LK55x7UPDacls5kn7N6d6 X/00b969wzEP2xeXPN15J+N/j09z5tw5+Vt/MP67PTFH5OXUDsZzGb7LL+w49ZlFv3zt8/Td 1v+Ot77f9aHrWflyJZbijERDLeai4kQA6RFXthcDAAA= 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: Sun, 29 Jan 2012 21:35:20 -0000 One philosophical nit below, but not enough to hold this up. Quoth Dmitry Kurochkin on Jan 28 at 8:41 am: > Before the change, tag format validation was done in > `notmuch-search-operate-all' function only. The patch moves it down > to `notmuch-tag', so that all users of that function get input > validation. > --- > emacs/notmuch.el | 12 ++++++------ > 1 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index 72f78ed..84d7d0a 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -522,6 +522,12 @@ 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 > + (when (null tags) (error "No tags given")) Since this is a non-interactive function and hence is meant to be invoked programmatically, I would expect it to accept zero tags. Unlike the following check, this is a UI-level check and thus, I believe, belongs in interactive functions (even if that requires a little duplication). > + (mapc (lambda (tag) > + (unless (string-match-p "^[-+][-+_.[:word:]]+$" tag) > + (error "Tag must be of the form `+this_tag' or `-that_tag'"))) > + tags) > (run-hooks 'notmuch-before-tag-hook) > (apply 'notmuch-call-notmuch-process > (append (list "tag") tags (list "--" query))) > @@ -890,12 +896,6 @@ characters as well as `_.+-'. > (interactive (notmuch-select-tags-with-completion > "Operations (+add -drop): notmuch tag " > '("+" "-"))) > - ;; Perform some validation > - (when (null actions) (error "No operations given")) > - (mapc (lambda (action) > - (unless (string-match-p "^[-+][-+_.[:word:]]+$" action) > - (error "Action must be of the form `+this_tag' or `-that_tag'"))) > - actions) > (apply 'notmuch-tag notmuch-search-query-string actions)) > > (defun notmuch-search-buffer-title (query)