Re: [PATCH 1/6] emacs: move tag format validation to `notmuch-tag' function
authorAustin Clements <amdragon@MIT.EDU>
Sun, 29 Jan 2012 21:34:27 +0000 (16:34 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:31 +0000 (09:43 -0800)
56/6d2b4b1078d819f8dac77979875e27f705f947 [new file with mode: 0644]

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