[Patch v4 1/3] contrib: pick: add thread based utility functions
authorMark Walters <markwalters1009@gmail.com>
Sun, 25 Aug 2013 19:55:32 +0000 (20:55 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:39 +0000 (09:56 -0800)
fb/fce43529f25d5d785f581b990e973ce1a00434 [new file with mode: 0644]

diff --git a/fb/fce43529f25d5d785f581b990e973ce1a00434 b/fb/fce43529f25d5d785f581b990e973ce1a00434
new file mode 100644 (file)
index 0000000..123c23b
--- /dev/null
@@ -0,0 +1,118 @@
+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 9C47E431FD7\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Aug 2013 10:43:25 -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 fg8rK2QmZJZH for <notmuch@notmuchmail.org>;\r
+       Mon, 26 Aug 2013 10:43:19 -0700 (PDT)\r
+Received: from mail-we0-f182.google.com (mail-we0-f182.google.com\r
+       [74.125.82.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id E7321431FD5\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Aug 2013 10:43:18 -0700 (PDT)\r
+Received: by mail-we0-f182.google.com with SMTP id q59so2964368wes.41\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Aug 2013 10:43:17 -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:in-reply-to:references\r
+       :mime-version:content-type:content-transfer-encoding;\r
+       bh=NX6yahz8R5mcHCvlP05C32RqztR1iAyYxHfcgUy7hlo=;\r
+       b=U4Dq845xot8EsukT4luWC/Wf2ohhPsgeoDikLew+Fl/2frBetyy5bz5wgXPfd5vSAO\r
+       wQjWeZlJUtMa9oOJbjrYuvREv6/Ow5f7WAbcGL7UK+kLfKKZ0pp6siJBMM0mH1zUsdJ0\r
+       /nrXanXL2zkCfJCDoMNV3XveCpyyxXhI9APOstHh8AMxx1NRoeHet5vcw/UTSIrtLv7p\r
+       9ecY9uW6mNtRDkZeAr2CZQcrE1s389qszP2b2bCGKARs3G7Y5DwOSHshF0N7h29NTKWI\r
+       2D6hFsY4RkdZUTEl0oqRdqN5YPQHSzUhUSQL64AhXCOPQ5a+Hzx3KUUwB2Ms4lyzfzsd\r
+       Hj2A==\r
+X-Received: by 10.180.182.15 with SMTP id ea15mr5083570wic.16.1377460543598;\r
+       Sun, 25 Aug 2013 12:55:43 -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 i12sm13287468wiw.3.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 25 Aug 2013 12:55:43 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 1/3] contrib: pick: add thread based utility functions\r
+Date: Sun, 25 Aug 2013 20:55:32 +0100\r
+Message-Id: <1377460534-6022-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1377460534-6022-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1377460534-6022-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: Mon, 26 Aug 2013 17:43:25 -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 37dc161..fea118f 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -599,6 +599,29 @@ message will be \"unarchived\", i.e. the tag changes in\r
+                        target\r
+                        (get-buffer buffer-name))))\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
+@@ -707,6 +730,7 @@ message together with all its descendents."\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