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 B3941429E42 for ; Thu, 13 Jun 2013 16:37:20 -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 0MwLyXS1WKGe for ; Thu, 13 Jun 2013 16:37:13 -0700 (PDT) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id F2F84431E62 for ; Thu, 13 Jun 2013 16:37:12 -0700 (PDT) Received: by mail-ee0-f44.google.com with SMTP id c13so5485298eek.3 for ; Thu, 13 Jun 2013 16:37:11 -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:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=HbG7QsR8M+EuFbvv621BfikqtDHpk2uDmulxUiZR8E0=; b=tnxWTj8ImPdRURnE9CPZstkTZwGOv3bbgSSnDSFg1g7siic+9E20gEYe4NHuKNwTfK bhbn38nRQ4elwsXUlu4BctsygwZKyfWlzXH+Nwzh+PKKrMD7+P9uYGAOoggjXo+fmez5 zURRj+WnHa2FfVNwfsLNH4EFKw/62ozGRdUaBMV01Wsjdq8+A0/5u2pmtvZYM0hq3Sz4 k+63SWdrsrKlmd+pjN8pO2HE1q9WNqucJUaj89mHgRt6e2zUBaJ+47RimzKxzurx0uxY R7wM/lolMRmC8BtbT03aFGCARrekfDHbnnIly60bnp0JEu3f99uyxA8kesKCmTz+aIZi EJqA== X-Received: by 10.14.115.9 with SMTP id d9mr3679053eeh.87.1371166631917; Thu, 13 Jun 2013 16:37:11 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id x4sm13494278eej.9.2013.06.13.16.37.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 16:37:11 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v2 1/2] contrib: pick: add thread based utility functions Date: Fri, 14 Jun 2013 00:36:57 +0100 Message-Id: <1371166618-27196-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1371166618-27196-1-git-send-email-markwalters1009@gmail.com> References: <1371166618-27196-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: Thu, 13 Jun 2013 23:37:21 -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 10a2bf7..8030842 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -583,6 +583,29 @@ than only the current message." (message (format "Command '%s' exited abnormally with code %d" shell-command exit-code))))))) +(defun notmuch-pick-thread-top () + (interactive) + (while (not (notmuch-pick-get-prop :first)) + (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 @@ -680,6 +703,7 @@ unchanged ADDRESS if parsing fails." (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