From: Mark Walters Date: Fri, 14 Jun 2013 07:37:51 +0000 (+0100) Subject: [PATCH v3 1/2] contrib: pick: add thread based utility functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=15f8bb6bf4db53c3f04cb3ce8bf35a446be117db;p=notmuch-archives.git [PATCH v3 1/2] contrib: pick: add thread based utility functions --- diff --git a/05/505a268d29b02de067c042bb616b6a1529bee7 b/05/505a268d29b02de067c042bb616b6a1529bee7 new file mode 100644 index 000000000..bf60392a4 --- /dev/null +++ b/05/505a268d29b02de067c042bb616b6a1529bee7 @@ -0,0 +1,119 @@ +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 CDE87429E41 + for ; Fri, 14 Jun 2013 00:38:07 -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 CLJ3Rr96uVlU for ; + Fri, 14 Jun 2013 00:38:00 -0700 (PDT) +Received: from mail-we0-f170.google.com (mail-we0-f170.google.com + [74.125.82.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1D374431FC2 + for ; Fri, 14 Jun 2013 00:37:59 -0700 (PDT) +Received: by mail-we0-f170.google.com with SMTP id w57so188347wes.1 + for ; Fri, 14 Jun 2013 00:37:58 -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=gRT8SnnoIz4++qpuHXKdocgzEyqLCygvGYeZdU3SZVo=; + b=e7OIyflnR0v54dqrWEgJLAKqHmy+BFqyf+t3B8MJLjpgHCF6AWUhfkgYnOwEsaJlXf + R+l/z/oeJU2MaICr6wXu2gdqw+cKHLrr4ArXsjklAZkP0HXRvwJVEIILMlqkaKXPQFqi + 8hGCi7mC1i8At0HxD7HN67xAXu3WSnqgujkVmpjk+GrLK04DsoRl+OxJuJz0gQFiUBhj + tYGJalYWzScGkPF4xCWjVwlVauVyiOwUCYQONRwelkDpZ2ivZZMUnz9/d6M9eYRX1FdD + v4kLneRvmQ9C/g0TL72oN0/pn/ixHkDjylul1nqNxsOdtOwTd7x6lfuvV2JVUy6bnXat + Sfmg== +X-Received: by 10.194.123.9 with SMTP id lw9mr632485wjb.24.1371195478882; + Fri, 14 Jun 2013 00:37:58 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id ay7sm1169657wib.9.2013.06.14.00.37.57 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Fri, 14 Jun 2013 00:37:58 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v3 1/2] contrib: pick: add thread based utility functions +Date: Fri, 14 Jun 2013 08:37:51 +0100 +Message-Id: <1371195472-441-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1371195472-441-1-git-send-email-markwalters1009@gmail.com> +References: <1371195472-441-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: Fri, 14 Jun 2013 07:38:08 -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..af117ba 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 () ++ (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 +@@ -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 +