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