From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id BBFC86DE00F2 for ; Mon, 9 Apr 2018 18:45:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z-jpoI6VqtJU for ; Mon, 9 Apr 2018 18:45:49 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 7F2CE6DE0068 for ; Mon, 9 Apr 2018 18:45:49 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1f5iLy-0006es-D6; Mon, 09 Apr 2018 21:45:46 -0400 Received: (nullmailer pid 24763 invoked by uid 1000); Tue, 10 Apr 2018 01:45:45 -0000 From: David Bremner To: David Bremner , "Naveen N. Rao" , notmuch@notmuchmail.org Subject: [PATCH] devel: add new tool to draw thread structure Date: Mon, 9 Apr 2018 22:45:39 -0300 Message-Id: <20180410014539.24717-1-david@tethera.net> X-Mailer: git-send-email 2.16.3 In-Reply-To: <878t9wvbmu.fsf@tethera.net> References: <878t9wvbmu.fsf@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Tue, 10 Apr 2018 01:45:50 -0000 This is useful for understanding the case where different message-files with the same message-id have distinct reference headers. --- devel/draw-thread | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 devel/draw-thread diff --git a/devel/draw-thread b/devel/draw-thread new file mode 100755 index 00000000..628dcff4 --- /dev/null +++ b/devel/draw-thread @@ -0,0 +1,35 @@ +#!/bin/bash + +# This script can be used like +# NOTMUCH_CONFIG=test/tmp.T580-thread-search/notmuch-config \ +# devel/draw-thread thread:0000000000000002 | dot -Tpdf > thread2.pdf + +# In addition to notmuch, you will need the following tools installed +# - graphviz +# - formail (part of procmail) + +threadid=$1 + +declare -a edges + +declare -a dest +echo "digraph \"$threadid\" {" +for messageid in $(notmuch search --output=messages $threadid); do + echo "subgraph \"cluster_$messageid\" {" + printf "\"%s\" [shape=folder];\n" ${messageid#id:} + for file in $(notmuch search --output=files $messageid); do + node=$(basename $file) + printf "\"%s\" [shape=note];\n" $node + + mapfile -t dest < <(formail -x references < $file | tr '<>,' '"" ') + edge="\"$node\" -> { ${dest[*]} }" + edges+=($edge) + done + echo "}" +done + +for edge in "${edges[*]}"; do + echo $edge +done + +echo "}" -- 2.16.3