From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-ua0-x22b.google.com (mail-ua0-x22b.google.com [IPv6:2607:f8b0:400c:c08::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C58AD1F404 for ; Sun, 21 Jan 2018 09:41:24 +0000 (UTC) Received: by mail-ua0-x22b.google.com with SMTP id n2so3919556uak.9 for ; Sun, 21 Jan 2018 01:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=KUx0ZwBQR5XFj5GxoelNiVnOq2ufkkRHrQL5Dkc82jo=; b=cs/Kn/AO8eEXP73eGiHfxRYzmP+V2f6rlhslZqsBHxbm8Rn6z9es2A7/6KBmy9t6uS ZFh3lYGs1BCqtBZOw+O/aZ9oMG8fLMeBodA10T+X6yKRHMRQyPFoOE3Iks9ISWTZ6ulL AOYRx097KokVSHSnGSAGYD2Ot3M/NPqMMTxNuRWHdbrTQVvO9POD+3uZrNlw9LT45Eed OEpRmJZuwGY0O2cHhrNZw86z8GOCvmWM0LnX4d/yzi1omFmNLGh+QcAIzftmisY4ySeR SxQn3LORCsao9dVNeMk+sFWaRSUG/AaGa8pRhsFyvfXaExpVrg7aZ3UpwfKvEOPyjiUp a3KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=KUx0ZwBQR5XFj5GxoelNiVnOq2ufkkRHrQL5Dkc82jo=; b=GX9QwV/LgKF8HyQMtr74b9bXBd7d25bIv54Um/65zOImvaawwoiDUmOLvn90DKndBz CQaiu6i7d8Xr1XzKPL92k/MUrEFQsq9D+cyFEzPE5YHON+SZWOMArSqw7M5MDitietaM 7bR5i1BVOoKtzHuGfjBu5V2cAy7YDvaBJCHrLI9ejgbPYTxBx+PInHBJWCeuqCumGzwt 0XuvVqMzRn2sBsfepDY+gMTPqHUSLpyKVALAjvYiz0jwkW9eMxhIJzndpgApThlMfqMj NpBfjg12OOewaeduG7Wsot4EwhjbZIYAjDEXfpdD5HGOc3zMm+6kHcamyksf6WAN3N37 kZCQ== X-Gm-Message-State: AKwxytdD+OzwredretTvj6AkzeUkcx73wZ7pWqFDU7QcKgCQxBpoE/30 FmnN6uouwQn1v8mooHcatc9nTA8HRQArWcBnOqgP7g== X-Google-Smtp-Source: AH8x225x4HhBZLnQdB+EaKDcA6fASdzfciLJzDBzdPvzH0LFxgTV9k+aUH6UmcFUuxiz+F9yq+BxS6NF44HGF1zM0Hc= X-Received: by 10.176.77.230 with SMTP id b38mr2604918uah.113.1516527682275; Sun, 21 Jan 2018 01:41:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.21.2 with HTTP; Sun, 21 Jan 2018 01:40:41 -0800 (PST) From: Dimid Duchovny Date: Sun, 21 Jan 2018 11:40:41 +0200 Message-ID: Subject: Feature Request: thread grouping To: msgthr-public Content-Type: text/plain; charset="UTF-8" List-Id: Hello Eric, When using the library, I'd like to eventually know which mail belongs to each thread (The motivation is to use a Union-Find data structure). Thus, I'm doing the following: * adding messages * threading * ordering * walking I.e. something like this: all_comms.each do |comm| [...] if in_reply_to && !in_reply_to.empty? refs = [in_reply_to] else refs = [] end msgthr.add msg_id, refs, comm end msgthr.thread! msgthr.order!{ |_| } threads = {} # We want to account for cases where the head of the thread is missing, but still referenced. last_thread = nil msgthr.walk_thread do |level, container, index| msg = container.msg mid = container.mid if 0 == level threads[mid] = [] last_thread = mid else threads[last_thread] << mid end end However, I realized that the last step (walking) is redundant, since that could be done by the library itself in the threading or ordering stages. E.g. keeping track of each container's thread, and when adding a message A as a child of message B, to point A's thread to B's one. We could use an array with a single element, or some other solution to have pass-by-reference semantics. Finally, all top-level containers should have their own msg_id as the thread, and all their descendants will point to it as well. Would you consider adding such a feature? If so, I'll be happy to work out the details and submit a patch. Thanks, and have a nice weekend.