unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	notmuch@notmuchmail.org
Subject: [PATCH] devel: add new tool to draw thread structure
Date: Mon,  9 Apr 2018 22:45:39 -0300	[thread overview]
Message-ID: <20180410014539.24717-1-david@tethera.net> (raw)
In-Reply-To: <878t9wvbmu.fsf@tethera.net>

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

  reply	other threads:[~2018-04-10  1:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06  9:46 'notmuch search thread:<>' lists multiple threads Naveen N. Rao
2018-04-06 10:23 ` Naveen N. Rao
2018-04-08  3:04 ` David Bremner
2018-04-09 11:54   ` David Bremner
2018-04-10  1:45     ` David Bremner [this message]
2018-10-08  3:30       ` [PATCH] devel: add new tool to draw thread structure Daniel Kahn Gillmor
2018-04-18 10:18     ` 'notmuch search thread:<>' lists multiple threads Naveen N. Rao
2018-04-22  0:45       ` David Bremner
2018-06-28 10:36         ` Naveen N. Rao
2018-06-30 13:42           ` David Bremner
2018-08-30 12:52             ` David Bremner
2018-09-06 10:50               ` Naveen N. Rao
2019-06-27 14:45                 ` Naveen N. Rao
2019-06-27 14:53                   ` Naveen N. Rao
2021-12-23 18:00       ` David Bremner
2022-01-14 11:26         ` Naveen N. Rao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180410014539.24717-1-david@tethera.net \
    --to=david@tethera.net \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).