Re: [PATCH 1/6] emacs: move tag format validation to `notmuch-tag' function
[notmuch-archives.git] / 56 / 6d2b4b1078d819f8dac77979875e27f705f947
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 8A747429E3B\r
6         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 13:35:20 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id FAYIoFoNxKmy for <notmuch@notmuchmail.org>;\r
16         Sun, 29 Jan 2012 13:35:20 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id DEB15431E64\r
20         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 13:35:19 -0800 (PST)\r
21 X-AuditID: 1209190e-b7f7c6d0000008c3-c1-4f25bb956449\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id BA.7F.02243.59BB52F4; Sun, 29 Jan 2012 16:35:17 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0TLZH8h031110; \r
27         Sun, 29 Jan 2012 16:35:17 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0TLZFii008701\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Sun, 29 Jan 2012 16:35:16 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1RrcOJ-0008VB-HD; Sun, 29 Jan 2012 16:34:27 -0500\r
37 Date: Sun, 29 Jan 2012 16:34:27 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
40 Subject: Re: [PATCH 1/6] emacs: move tag format validation to `notmuch-tag'\r
41         function\r
42 Message-ID: <20120129213427.GF17991@mit.edu>\r
43 References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 Content-Disposition: inline\r
47 In-Reply-To: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com>\r
48 User-Agent: Mutt/1.5.21 (2010-09-15)\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT0Z26W9Xf4Ot1fYurW/vZLa7fnMns\r
51         wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGXsXryPvWCeQMWN7xOZGhj7eLsYOTkkBEwk\r
52         tm2cywJhi0lcuLeerYuRi0NIYB+jxLK7z1kgnA2MEhOunmSHcE4ySax/u5wRwlnCKHHk/nSw\r
53         fhYBVYnj66+B2WwCGhLb9oMUcXKICBhK3Lr4ihnEZhaQlvj2u5kJxBYWCJPo2n6ODcTmFdCR\r
54         WD33LFiNkICnxNE9Hxkh4oISJ2c+YYHo1ZK48e8lUC8H2Jzl/zhAwpwCXhIXZu1kB7FFBVQk\r
55         ppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGusl5tZopeaUrqJ\r
56         ERTYnJJ8Oxi/HlQ6xCjAwajEw6u4QsVfiDWxrLgy9xCjJAeTkijv2R2q/kJ8SfkplRmJxRnx\r
57         RaU5qcWHGCU4mJVEeOcsA8rxpiRWVqUW5cOkpDlYlMR51bTe+QkJpCeWpGanphakFsFkZTg4\r
58         lCR4P+8CahQsSk1PrUjLzClBSDNxcIIM5wEafgGkhre4IDG3ODMdIn+KUVFKHCIhAJLIKM2D\r
59         64UlnleM4kCvCPPeBaniASYtuO5XQIOZgAY/ZwAbXJKIkJJqYHRhubyweD+DsE3Lc71LE5In\r
60         eFnMVch84fyxe/58B+1jj8tuXi8puKAudJj3/qX0U4s0ctKbtn9LK55x7UPDacls5kn7N6d6\r
61         X/00b969wzEP2xeXPN15J+N/j09z5tw5+Vt/MP67PTFH5OXUDsZzGb7LL+w49ZlFv3zt8/Td\r
62         1v+Ot77f9aHrWflyJZbijERDLeai4kQA6RFXthcDAAA=\r
63 Cc: notmuch@notmuchmail.org\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Sun, 29 Jan 2012 21:35:20 -0000\r
77 \r
78 One philosophical nit below, but not enough to hold this up.\r
79 \r
80 Quoth Dmitry Kurochkin on Jan 28 at  8:41 am:\r
81 > Before the change, tag format validation was done in\r
82 > `notmuch-search-operate-all' function only.  The patch moves it down\r
83 > to `notmuch-tag', so that all users of that function get input\r
84 > validation.\r
85 > ---\r
86 >  emacs/notmuch.el |   12 ++++++------\r
87 >  1 files changed, 6 insertions(+), 6 deletions(-)\r
88\r
89 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
90 > index 72f78ed..84d7d0a 100644\r
91 > --- a/emacs/notmuch.el\r
92 > +++ b/emacs/notmuch.el\r
93 > @@ -522,6 +522,12 @@ Note: Other code should always use this function alter tags of\r
94 >  messages instead of running (notmuch-call-notmuch-process \"tag\" ..)\r
95 >  directly, so that hooks specified in notmuch-before-tag-hook and\r
96 >  notmuch-after-tag-hook will be run."\r
97 > +  ;; Perform some validation\r
98 > +  (when (null tags) (error "No tags given"))\r
99 \r
100 Since this is a non-interactive function and hence is meant to be\r
101 invoked programmatically, I would expect it to accept zero tags.\r
102 Unlike the following check, this is a UI-level check and thus, I\r
103 believe, belongs in interactive functions (even if that requires a\r
104 little duplication).\r
105 \r
106 > +  (mapc (lambda (tag)\r
107 > +       (unless (string-match-p "^[-+][-+_.[:word:]]+$" tag)\r
108 > +         (error "Tag must be of the form `+this_tag' or `-that_tag'")))\r
109 > +     tags)\r
110 >    (run-hooks 'notmuch-before-tag-hook)\r
111 >    (apply 'notmuch-call-notmuch-process\r
112 >        (append (list "tag") tags (list "--" query)))\r
113 > @@ -890,12 +896,6 @@ characters as well as `_.+-'.\r
114 >    (interactive (notmuch-select-tags-with-completion\r
115 >               "Operations (+add -drop): notmuch tag "\r
116 >               '("+" "-")))\r
117 > -  ;; Perform some validation\r
118 > -  (when (null actions) (error "No operations given"))\r
119 > -  (mapc (lambda (action)\r
120 > -       (unless (string-match-p "^[-+][-+_.[:word:]]+$" action)\r
121 > -         (error "Action must be of the form `+this_tag' or `-that_tag'")))\r
122 > -     actions)\r
123 >    (apply 'notmuch-tag notmuch-search-query-string actions))\r
124 >  \r
125 >  (defun notmuch-search-buffer-title (query)\r