From: Mark Walters Date: Sun, 25 Aug 2013 19:55:32 +0000 (+0100) Subject: [Patch v4 1/3] contrib: pick: add thread based utility functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=66ab4d7a3746bdb5122ca8f47d8fb619fb96e634;p=notmuch-archives.git [Patch v4 1/3] contrib: pick: add thread based utility functions --- diff --git a/fb/fce43529f25d5d785f581b990e973ce1a00434 b/fb/fce43529f25d5d785f581b990e973ce1a00434 new file mode 100644 index 000000000..123c23baf --- /dev/null +++ b/fb/fce43529f25d5d785f581b990e973ce1a00434 @@ -0,0 +1,118 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 9C47E431FD7 + for ; Mon, 26 Aug 2013 10:43:25 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id fg8rK2QmZJZH for ; + Mon, 26 Aug 2013 10:43:19 -0700 (PDT) +Received: from mail-we0-f182.google.com (mail-we0-f182.google.com + [74.125.82.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id E7321431FD5 + for ; Mon, 26 Aug 2013 10:43:18 -0700 (PDT) +Received: by mail-we0-f182.google.com with SMTP id q59so2964368wes.41 + for ; Mon, 26 Aug 2013 10:43:17 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references + :mime-version:content-type:content-transfer-encoding; + bh=NX6yahz8R5mcHCvlP05C32RqztR1iAyYxHfcgUy7hlo=; + b=U4Dq845xot8EsukT4luWC/Wf2ohhPsgeoDikLew+Fl/2frBetyy5bz5wgXPfd5vSAO + wQjWeZlJUtMa9oOJbjrYuvREv6/Ow5f7WAbcGL7UK+kLfKKZ0pp6siJBMM0mH1zUsdJ0 + /nrXanXL2zkCfJCDoMNV3XveCpyyxXhI9APOstHh8AMxx1NRoeHet5vcw/UTSIrtLv7p + 9ecY9uW6mNtRDkZeAr2CZQcrE1s389qszP2b2bCGKARs3G7Y5DwOSHshF0N7h29NTKWI + 2D6hFsY4RkdZUTEl0oqRdqN5YPQHSzUhUSQL64AhXCOPQ5a+Hzx3KUUwB2Ms4lyzfzsd + Hj2A== +X-Received: by 10.180.182.15 with SMTP id ea15mr5083570wic.16.1377460543598; + Sun, 25 Aug 2013 12:55:43 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id i12sm13287468wiw.3.1969.12.31.16.00.00 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 25 Aug 2013 12:55:43 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v4 1/3] contrib: pick: add thread based utility functions +Date: Sun, 25 Aug 2013 20:55:32 +0100 +Message-Id: <1377460534-6022-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1377460534-6022-1-git-send-email-markwalters1009@gmail.com> +References: <1377460534-6022-1-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 26 Aug 2013 17:43:25 -0000 + +Previously notmuch-pick had no thread based functionality. This adds a +macro to iterate through all messages in a thread. To simplify this it +adds a text-property marker to the first message of each thread. +--- + contrib/notmuch-pick/notmuch-pick.el | 24 ++++++++++++++++++++++++ + 1 files changed, 24 insertions(+), 0 deletions(-) + +diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el +index 37dc161..fea118f 100644 +--- a/contrib/notmuch-pick/notmuch-pick.el ++++ b/contrib/notmuch-pick/notmuch-pick.el +@@ -599,6 +599,29 @@ message will be \"unarchived\", i.e. the tag changes in + target + (get-buffer buffer-name)))) + ++(defun notmuch-pick-thread-top () ++ (when (notmuch-pick-get-message-properties) ++ (while (not (or (notmuch-pick-get-prop :first) (eobp))) ++ (forward-line -1)))) ++ ++(defun notmuch-pick-thread-mapcar (function) ++ "Iterate through all messages in the current thread ++ and call FUNCTION for side effects." ++ (save-excursion ++ (notmuch-pick-thread-top) ++ (loop collect (funcall function) ++ do (forward-line) ++ while (and (notmuch-pick-get-message-properties) ++ (not (notmuch-pick-get-prop :first)))))) ++ ++(defun notmuch-pick-get-messages-ids-thread-search () ++ "Return a search string for all message ids of messages in the current thread." ++ (mapconcat 'identity ++ (notmuch-pick-thread-mapcar 'notmuch-pick-get-message-id) ++ " or ")) ++ ++;; Functions below here display the pick buffer itself. ++ + (defun notmuch-pick-clean-address (address) + "Try to clean a single email ADDRESS for display. Return + AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return +@@ -707,6 +730,7 @@ message together with all its descendents." + (push "├" tree-status))) + + (push (concat (if replies "┬" "─") "►") tree-status) ++ (plist-put msg :first (and first (eq 0 depth))) + (notmuch-pick-goto-and-insert-msg (plist-put msg :tree-status tree-status)) + (pop tree-status) + (pop tree-status) +-- +1.7.9.1 +