--- /dev/null
+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 464EA431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Oct 2013 07:14:33 -0700 (PDT)\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 QI2Cz-hAIl6c for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Oct 2013 07:14:28 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id 69794431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Oct 2013 07:14:28 -0700 (PDT)\r
+X-AuditID: 12074423-b7fc98e0000009a2-5c-525564c306d9\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id E7.CF.02466.3C465525; Wed, 9 Oct 2013 10:14:27 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r99EEQHb006239; \r
+ Wed, 9 Oct 2013 10:14:27 -0400\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.8/8.12.4) with ESMTP id r99EEPCp021588\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Wed, 9 Oct 2013 10:14:26 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1VTuWu-00050f-UC; Wed, 09 Oct 2013 10:14:24 -0400\r
+Date: Wed, 9 Oct 2013 10:14:24 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 07/11] emacs: Use notmuch tag --batch for large tag\r
+ queries\r
+Message-ID: <20131009141424.GP21611@mit.edu>\r
+References: <1381185201-25197-1-git-send-email-amdragon@mit.edu>\r
+ <1381185201-25197-8-git-send-email-amdragon@mit.edu>\r
+ <87iox6ap58.fsf@nikula.org> <87d2ne28sj.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87d2ne28sj.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFuphleLIzCtJLcpLzFFi42IR4hTV1j2cEhpksPSglkXTdGeL1XN5LK7f\r
+ nMnswOyxc9Zddo9b91+zezxbdYs5gDmKyyYlNSezLLVI3y6BK6P55VKmgq+SFTum9rM2MG4Q\r
+ 6WLk5JAQMJHoP3eLDcIWk7hwbz2QzcUhJLCPUeLn/A52CGcDo8SP+2+ZIZxTTBLHtzSyQjhL\r
+ GCXmr+1hBOlnEVCReNc1CWwWm4CGxLb9y8HiIgI6ErcPLWAHsZkFrCQatnwAiwsLBEpc3dwO\r
+ NIiDgxeoZk5jGcTMzYwSe45OYgap4RUQlDg58wkLRK+WxI1/L5lA6pkFpCWW/+MACXMCrbrS\r
+ 28MKYosCnTDl5Da2CYxCs5B0z0LSPQuhewEj8ypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdM73c\r
+ zBK91JTSTYygQGd3Ud7B+Oeg0iFGAQ5GJR7eDt6QICHWxLLiytxDjJIcTEqivNtjQoOE+JLy\r
+ UyozEosz4otKc1KLDzFKcDArifAaRwPleFMSK6tSi/JhUtIcLErivLc47IOEBNITS1KzU1ML\r
+ UotgsjIcHEoSvD3JQI2CRanpqRVpmTklCGkmDk6Q4TxAw7eB1PAWFyTmFmemQ+RPMSpKifMe\r
+ B0kIgCQySvPgemGJ6BWjONArwry7QKp4gEkMrvsV0GAmoMHbv4eADC5JREhJNTAGrP+oJt/w\r
+ WOPYf5EIE73sPTcPfyyq3pW2dddB5QXWez8miL4+LrQhdFtc9fSieo3ffbu9D0keuD9fTvpG\r
+ 6dfe3BlXZbZtecki/mfLVSbO1D8yn9m7v9wPf8J80TxaymPdQ53lmleWdU15KMD8/2J3+7Nj\r
+ q08/Clc4udDv4fpujsi9z5R7O7jMlViKMxINtZiLihMB5Mwz8x8DAAA=\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: Wed, 09 Oct 2013 14:14:33 -0000\r
+\r
+Quoth Mark Walters on Oct 09 at 8:38 am:\r
+> \r
+> On Wed, 09 Oct 2013, Jani Nikula <jani@nikula.org> wrote:\r
+> > On Tue, 08 Oct 2013, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> >> (Unfortunately, it's difficult to first demonstrate this problem with\r
+> >> a known-broken test because modern Linux kernels have argument length\r
+> >> limits in the megabytes, which makes Emacs really slow!)\r
+> >> ---\r
+> >> emacs/notmuch-lib.el | 8 ++++++++\r
+> >> emacs/notmuch-tag.el | 12 ++++++++++--\r
+> >> test/emacs | 8 ++++++++\r
+> >> 3 files changed, 26 insertions(+), 2 deletions(-)\r
+> >>\r
+> >> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+> >> index 22156f1..348112b 100644\r
+> >> --- a/emacs/notmuch-lib.el\r
+> >> +++ b/emacs/notmuch-lib.el\r
+> >> @@ -261,6 +261,14 @@ user-friendly queries."\r
+> >> "Return a query that matches the message with id ID."\r
+> >> (concat "id:" (notmuch-escape-boolean-term id)))\r
+> >> \r
+> >> +(defun notmuch-hex-encode (str)\r
+> >> + "Hex-encode STR (e.g., as used by batch tagging).\r
+> >> +\r
+> >> +This replaces spaces, percents, and double quotes in STR with\r
+> >> +%NN where NN is the hexadecimal value of the character."\r
+> >> + (replace-regexp-in-string\r
+> >> + "[ %\"]" (lambda (match) (format "%%%02x" (aref match 0))) str))\r
+> >> +\r
+> >> ;;\r
+> >> \r
+> >> (defun notmuch-common-do-stash (text)\r
+> >> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
+> >> index 064cfa8..a4eec14 100644\r
+> >> --- a/emacs/notmuch-tag.el\r
+> >> +++ b/emacs/notmuch-tag.el\r
+> >> @@ -242,6 +242,8 @@ from TAGS if present."\r
+> >> (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))\r
+> >> (sort result-tags 'string<)))\r
+> >> \r
+> >> +(defconst notmuch-tag-argument-limit 1000)\r
+> >> +\r
+> >> (defun notmuch-tag (query &optional tag-changes)\r
+> >> "Add/remove tags in TAG-CHANGES to messages matching QUERY.\r
+> >> \r
+> >> @@ -268,8 +270,14 @@ notmuch-after-tag-hook will be run."\r
+> >> tag-changes)\r
+> >> (unless (null tag-changes)\r
+> >> (run-hooks 'notmuch-before-tag-hook)\r
+> >> - (apply 'notmuch-call-notmuch-process "tag"\r
+> >> - (append tag-changes (list "--" query)))\r
+> >> + (if (<= (length query) notmuch-tag-argument-limit)\r
+> >> + (apply 'notmuch-call-notmuch-process "tag"\r
+> >> + (append tag-changes (list "--" query)))\r
+> >> + ;; Use batch tag mode to avoid argument length limitations\r
+> >> + (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")\r
+> >> + " -- " query)))\r
+> >> + (message "Batch tagging with %s" batch-op)\r
+> >\r
+> > Why the message?\r
+> >\r
+> > Jani.\r
+> \r
+> I had missed that: this message is presumably for debugging as it\r
+> includes the (possibly megabyte sized) query. I think some message would\r
+> be sensible as this could be a slow operation so it's probably worth\r
+> telling the user why the interface has locked.\r
+\r
+You're right, this was a leftover debug message. While I wouldn't\r
+mind a progress message for long tagging operations, query length\r
+isn't a good approximation of how long it's going to take. I was\r
+planning to include messages on tagging operations in my undo series,\r
+which I think can do it in a more principled way (assuming I can find\r
+a clean way to update tags in the UI on undo).\r
+\r
+> Best wishes\r
+> \r
+> Mark\r