[PATCH 1/2] contrib: pick: add thread based utility functions
authorMark Walters <markwalters1009@gmail.com>
Sat, 8 Dec 2012 12:48:33 +0000 (12:48 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:46 +0000 (09:51 -0800)
3b/38f773a9af9c0fa96a85242348d31268942905 [new file with mode: 0644]

diff --git a/3b/38f773a9af9c0fa96a85242348d31268942905 b/3b/38f773a9af9c0fa96a85242348d31268942905
new file mode 100644 (file)
index 0000000..f923e88
--- /dev/null
@@ -0,0 +1,122 @@
+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 B9E40431FB6\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 04:48:39 -0800 (PST)\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 1+4BV2bKk9hk for <notmuch@notmuchmail.org>;\r
+       Sat,  8 Dec 2012 04:48:39 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 23611431FAE\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 04:48:39 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id t11so646760wey.26\r
+       for <notmuch@notmuchmail.org>; Sat, 08 Dec 2012 04:48:38 -0800 (PST)\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=4G9o5uz8HJDpQO+rw7wUt3bt5Yl+1HAl0KLaxP4vKhc=;\r
+       b=JsQUEVNJ86dOhJiTOLSh2I6z8CxUinTB9aNSHV/F+i7bD2ORyy0I2S2Qe63Fo9925U\r
+       s+3NEue3370mXoeOZoZNJuLDMC/TtKfsO/tqxNcXSs9aTjWL2mbJo3+V+mFdYO/ctqRh\r
+       9eRZf4EwJo9QN9VtSfWIJlVXyhoBQwKiBJswn4ZLoUsGwgbvvmCzQkoGRqSet7Lj+hfe\r
+       Bl6PyjGNRthWU6UMfvm6lluTUGc2qUKD0SG9q+nKca4udSBzFAWCE/xLys8j715FZs6l\r
+       Se1Imte7+ii2OPC376XJcHQVhFohRGku2CKjIaOQghuvQjJCMAzb4mTrS3uh+VYKciE+\r
+       3D6w==\r
+Received: by 10.216.200.6 with SMTP id y6mr3324397wen.131.1354970918788;\r
+       Sat, 08 Dec 2012 04:48:38 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id bd7sm2417828wib.8.2012.12.08.04.48.37\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 08 Dec 2012 04:48:38 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] contrib: pick: add thread based utility functions\r
+Date: Sat,  8 Dec 2012 12:48:33 +0000\r
+Message-Id: <1354970914-18342-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354970914-18342-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354970914-18342-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: Sat, 08 Dec 2012 12:48:39 -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 |   28 ++++++++++++++++++++++++++++\r
+ 1 files changed, 28 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index b474231..77e15bb 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -552,6 +552,33 @@ 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
++(defmacro notmuch-pick-thread-mapc (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 do (progn\r
++             (funcall function)\r
++             (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 ()\r
++  "Return all id: queries of messages in the current thread."\r
++  (let ((message-ids))\r
++    (notmuch-pick-thread-mapc\r
++     (lambda () (push (notmuch-pick-get-message-id) message-ids)))\r
++    message-ids))\r
++\r
++(defun notmuch-pick-get-messages-ids-thread-search ()\r
++  "Return a search string for all message ids of messages in the\r
++current thread."\r
++  (mapconcat 'identity (notmuch-pick-get-messages-ids-thread) " or "))\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
+@@ -638,6 +665,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-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