--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 B3941429E42\r
+ for <notmuch@notmuchmail.org>; Thu, 13 Jun 2013 16:37:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 0MwLyXS1WKGe for <notmuch@notmuchmail.org>;\r
+ Thu, 13 Jun 2013 16:37:13 -0700 (PDT)\r
+Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com\r
+ [74.125.83.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ F2F84431E62 for <notmuch@notmuchmail.org>; Thu, 13 Jun 2013 16:37:12 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f44.google.com with SMTP id c13so5485298eek.3\r
+ for <notmuch@notmuchmail.org>; Thu, 13 Jun 2013 16:37:11 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+ :mime-version:content-type:content-transfer-encoding;\r
+ bh=HbG7QsR8M+EuFbvv621BfikqtDHpk2uDmulxUiZR8E0=;\r
+ b=tnxWTj8ImPdRURnE9CPZstkTZwGOv3bbgSSnDSFg1g7siic+9E20gEYe4NHuKNwTfK\r
+ bhbn38nRQ4elwsXUlu4BctsygwZKyfWlzXH+Nwzh+PKKrMD7+P9uYGAOoggjXo+fmez5\r
+ zURRj+WnHa2FfVNwfsLNH4EFKw/62ozGRdUaBMV01Wsjdq8+A0/5u2pmtvZYM0hq3Sz4\r
+ k+63SWdrsrKlmd+pjN8pO2HE1q9WNqucJUaj89mHgRt6e2zUBaJ+47RimzKxzurx0uxY\r
+ R7wM/lolMRmC8BtbT03aFGCARrekfDHbnnIly60bnp0JEu3f99uyxA8kesKCmTz+aIZi\r
+ EJqA==\r
+X-Received: by 10.14.115.9 with SMTP id d9mr3679053eeh.87.1371166631917;\r
+ Thu, 13 Jun 2013 16:37:11 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id x4sm13494278eej.9.2013.06.13.16.37.10\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Thu, 13 Jun 2013 16:37:11 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/2] contrib: pick: add thread based utility functions\r
+Date: Fri, 14 Jun 2013 00:36:57 +0100\r
+Message-Id: <1371166618-27196-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1371166618-27196-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1371166618-27196-1-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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: Thu, 13 Jun 2013 23:37:21 -0000\r
+\r
+Previously notmuch-pick had no thread based functionality. This adds a\r
+macro to iterate through all messages in a thread. To simplify this it\r
+adds a text-property marker to the first message of each thread.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el | 24 ++++++++++++++++++++++++\r
+ 1 files changed, 24 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index 10a2bf7..8030842 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -583,6 +583,29 @@ than only the current message."\r
+ (message (format "Command '%s' exited abnormally with code %d"\r
+ shell-command exit-code)))))))\r
+ \r
++(defun notmuch-pick-thread-top ()\r
++ (interactive)\r
++ (while (not (notmuch-pick-get-prop :first))\r
++ (forward-line -1)))\r
++\r
++(defun notmuch-pick-thread-mapcar (function)\r
++ "Iterate through all messages in the current thread\r
++ and call FUNCTION for side effects."\r
++ (save-excursion\r
++ (notmuch-pick-thread-top)\r
++ (loop collect (funcall function)\r
++ do (forward-line)\r
++ while (and (notmuch-pick-get-message-properties)\r
++ (not (notmuch-pick-get-prop :first))))))\r
++\r
++(defun notmuch-pick-get-messages-ids-thread-search ()\r
++ "Return a search string for all message ids of messages in the current thread."\r
++ (mapconcat 'identity\r
++ (notmuch-pick-thread-mapcar 'notmuch-pick-get-message-id)\r
++ " or "))\r
++\r
++;; Functions below here display the pick buffer itself.\r
++\r
+ (defun notmuch-pick-clean-address (address)\r
+ "Try to clean a single email ADDRESS for display. Return\r
+ AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return\r
+@@ -680,6 +703,7 @@ unchanged ADDRESS if parsing fails."\r
+ (push "├" tree-status)))\r
+ \r
+ (push (concat (if replies "┬" "─") "►") tree-status)\r
++ (plist-put msg :first (and first (eq 0 depth)))\r
+ (notmuch-pick-goto-and-insert-msg (plist-put msg :tree-status tree-status))\r
+ (pop tree-status)\r
+ (pop tree-status)\r
+-- \r
+1.7.9.1\r
+\r