--- /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 CDE87429E41\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Jun 2013 00:38:07 -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 CLJ3Rr96uVlU for <notmuch@notmuchmail.org>;\r
+ Fri, 14 Jun 2013 00:38:00 -0700 (PDT)\r
+Received: from mail-we0-f170.google.com (mail-we0-f170.google.com\r
+ [74.125.82.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 1D374431FC2\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Jun 2013 00:37:59 -0700 (PDT)\r
+Received: by mail-we0-f170.google.com with SMTP id w57so188347wes.1\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Jun 2013 00:37:58 -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=gRT8SnnoIz4++qpuHXKdocgzEyqLCygvGYeZdU3SZVo=;\r
+ b=e7OIyflnR0v54dqrWEgJLAKqHmy+BFqyf+t3B8MJLjpgHCF6AWUhfkgYnOwEsaJlXf\r
+ R+l/z/oeJU2MaICr6wXu2gdqw+cKHLrr4ArXsjklAZkP0HXRvwJVEIILMlqkaKXPQFqi\r
+ 8hGCi7mC1i8At0HxD7HN67xAXu3WSnqgujkVmpjk+GrLK04DsoRl+OxJuJz0gQFiUBhj\r
+ tYGJalYWzScGkPF4xCWjVwlVauVyiOwUCYQONRwelkDpZ2ivZZMUnz9/d6M9eYRX1FdD\r
+ v4kLneRvmQ9C/g0TL72oN0/pn/ixHkDjylul1nqNxsOdtOwTd7x6lfuvV2JVUy6bnXat\r
+ Sfmg==\r
+X-Received: by 10.194.123.9 with SMTP id lw9mr632485wjb.24.1371195478882;\r
+ Fri, 14 Jun 2013 00:37:58 -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 ay7sm1169657wib.9.2013.06.14.00.37.57\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Fri, 14 Jun 2013 00:37:58 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/2] contrib: pick: add thread based utility functions\r
+Date: Fri, 14 Jun 2013 08:37:51 +0100\r
+Message-Id: <1371195472-441-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1371195472-441-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1371195472-441-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: Fri, 14 Jun 2013 07:38:08 -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..af117ba 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
++ (when (notmuch-pick-get-message-properties)\r
++ (while (not (or (notmuch-pick-get-prop :first) (eobp)))\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