--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 674D3431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 15 Jul 2012 09:27:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 0CY2ZGFC5ioU for <notmuch@notmuchmail.org>;\r
+ Sun, 15 Jul 2012 09:27:25 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 529F6431FBC\r
+ for <notmuch@notmuchmail.org>; Sun, 15 Jul 2012 09:27:25 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SqRfE-0006Au-0G; Sun, 15 Jul 2012 17:27:20 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+ helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SqRfD-0005Qe-I0; Sun, 15 Jul 2012 17:27:19 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3 0/8] emacs: JSON-based search cleanups\r
+In-Reply-To: <1342306940-7499-1-git-send-email-amdragon@mit.edu>\r
+References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
+ <1342306940-7499-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.13.2+90~g84fa1ef (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 15 Jul 2012 17:27:17 +0100\r
+Message-ID: <87a9z1at22.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 61aa3a54130196eb864a56ca4ab759c4 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.8 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ * domain\r
+ * 0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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, 15 Jul 2012 16:27:26 -0000\r
+\r
+\r
+On Sun, 15 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> This version swaps out the notmuch-search-do-results macro for a\r
+> higher-order function, notmuch-search-foreach-result. This requires\r
+> less squiting to understand and clearly distinguishes the arguments\r
+> passed in to the function from the arguments passed to the callback.\r
+> This version also updates the docstring for\r
+> notmuch-search-result-format to mention that multi-line result formats\r
+> work and how to enter them, and it adds a NEWS patch.\r
+\r
+Hello\r
+\r
+I am afraid I have found a minor (but reproducible) bug in the line\r
+re-drawing even with single line results. Find a search result with a\r
+partially elided author field and put the cursor after the ellipsis in\r
+that line. Then update the tags. The result gets redrawn with ellipsis\r
+written out in full. Re-redrawing with the cursor after the author field\r
+redraws the line with the keeping the ellipsis written out in full,\r
+whereas re-redrawing the line with cursor before the author field gets\r
+it written with the correct ellipsis.\r
+\r
+Best wishes\r
+\r
+Mark\r
+>\r
+> Diff from v2:\r
+>\r
+> diff --git a/NEWS b/NEWS\r
+> index a1a6e93..7b33f0d 100644\r
+> --- a/NEWS\r
+> +++ b/NEWS\r
+> @@ -17,6 +17,20 @@ Maildir tag synchronization\r
+> Emacs Interface\r
+> ---------------\r
+> \r
+> +Search results now get re-colored when tags are updated\r
+> +\r
+> +The formatting of tags in search results can now be customized\r
+> +\r
+> + Previously, attempting to change the format of tags in\r
+> + `notmuch-search-result-format` would usually break tagging from\r
+> + search-mode. We no longer make assumptions about the format.\r
+> +\r
+> +Multi-line search result formats are now supported\r
+> +\r
+> + It is now possible to embed newlines in\r
+> + `notmuch-search-result-format` to make individual search results\r
+> + span multiple lines.\r
+> +\r
+> Search now uses the JSON format internally\r
+> \r
+> This should address problems with unusual characters in authors and\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 7302fa7..ec760dc 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -69,7 +69,13 @@\r
+> date, count, authors, subject, tags\r
+> For example:\r
+> (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)\r
+> - \(\"subject\" . \"%s\"\)\)\)"\r
+> + \(\"subject\" . \"%s\"\)\)\)\r
+> +Line breaks are permitted in format strings. Note that a line\r
+> +break at the end of an \"authors\" field will get elided if the\r
+> +authors list is long; place it instead at the beginning of the\r
+> +following field. To enter a line break when setting this\r
+> +variable with setq, use \\n. To enter a line break in customize,\r
+> +press \\[quoted-insert] C-j."\r
+> :type '(alist :key-type (string) :value-type (string))\r
+> :group 'notmuch-search)\r
+> \r
+> @@ -433,32 +439,39 @@ returns nil"\r
+> (next-single-property-change (or pos (point)) 'notmuch-search-result\r
+> nil (point-max))))\r
+> \r
+> -(defmacro notmuch-search-do-results (beg end pos-sym &rest body)\r
+> - "Invoke BODY for each result between BEG and END.\r
+> -\r
+> -POS-SYM will be bound to the point at the beginning of the\r
+> -current result."\r
+> - (declare (indent 3))\r
+> - (let ((end-sym (make-symbol "end"))\r
+> - (first-sym (make-symbol "first")))\r
+> - `(let ((,pos-sym (notmuch-search-result-beginning ,beg))\r
+> - ;; End must be a marker in case body changes the text\r
+> - (,end-sym (copy-marker ,end))\r
+> - ;; Make sure we examine one result, even if (= beg end)\r
+> - (,first-sym t))\r
+> - ;; We have to be careful if the region extends beyond the\r
+> - ;; results. In this case, pos could be null or there could be\r
+> - ;; no result at pos.\r
+> - (while (and ,pos-sym (or (< ,pos-sym ,end-sym) ,first-sym))\r
+> - (when (notmuch-search-get-result ,pos-sym)\r
+> - ,@body)\r
+> - (setq ,pos-sym (notmuch-search-result-end ,pos-sym)\r
+> - ,first-sym nil)))))\r
+> +(defun notmuch-search-foreach-result (beg end function)\r
+> + "Invoke FUNCTION for each result between BEG and END.\r
+> +\r
+> +FUNCTION should take one argument. It will be applied to the\r
+> +character position of the beginning of each result that overlaps\r
+> +the region between points BEG and END. As a special case, if (=\r
+> +BEG END), FUNCTION will be applied to the result containing point\r
+> +BEG."\r
+> +\r
+> + (lexical-let ((pos (notmuch-search-result-beginning beg))\r
+> + ;; End must be a marker in case function changes the\r
+> + ;; text.\r
+> + (end (copy-marker end))\r
+> + ;; Make sure we examine at least one result, even if\r
+> + ;; (= beg end).\r
+> + (first t))\r
+> + ;; We have to be careful if the region extends beyond the results.\r
+> + ;; In this case, pos could be null or there could be no result at\r
+> + ;; pos.\r
+> + (while (and pos (or (< pos end) first))\r
+> + (when (notmuch-search-get-result pos)\r
+> + (funcall function pos))\r
+> + (setq pos (notmuch-search-result-end pos)\r
+> + first nil))))\r
+> +;; Unindent the function argument of notmuch-search-foreach-result so\r
+> +;; the indentation of callers doesn't get out of hand.\r
+> +(put 'notmuch-search-foreach-result 'lisp-indent-function 2)\r
+> \r
+> (defun notmuch-search-properties-in-region (property beg end)\r
+> (let (output)\r
+> - (notmuch-search-do-results beg end pos\r
+> - (push (plist-get (notmuch-search-get-result pos) property) output))\r
+> + (notmuch-search-foreach-result beg end\r
+> + (lambda (pos)\r
+> + (push (plist-get (notmuch-search-get-result pos) property) output)))\r
+> output))\r
+> \r
+> (defun notmuch-search-find-thread-id ()\r
+> @@ -542,18 +555,20 @@ and will also appear in a buffer named \"*Notmuch errors*\"."\r
+> \r
+> (defun notmuch-search-get-tags-region (beg end)\r
+> (let (output)\r
+> - (notmuch-search-do-results beg end pos\r
+> - (setq output (append output (notmuch-search-get-tags pos))))\r
+> + (notmuch-search-foreach-result beg end\r
+> + (lambda (pos)\r
+> + (setq output (append output (notmuch-search-get-tags pos)))))\r
+> output))\r
+> \r
+> (defun notmuch-search-tag-region (beg end &optional tag-changes)\r
+> "Change tags for threads in the given region."\r
+> (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))\r
+> (setq tag-changes (funcall 'notmuch-tag search-string tag-changes))\r
+> - (notmuch-search-do-results beg end pos\r
+> - (notmuch-search-set-tags\r
+> - (notmuch-update-tags (notmuch-search-get-tags pos) tag-changes)\r
+> - pos))))\r
+> + (notmuch-search-foreach-result beg end\r
+> + (lambda (pos)\r
+> + (notmuch-search-set-tags\r
+> + (notmuch-update-tags (notmuch-search-get-tags pos) tag-changes)\r
+> + pos)))))\r
+> \r
+> (defun notmuch-search-tag (&optional tag-changes)\r
+> "Change tags for the currently selected thread or region.\r