From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8787D1FD74; Sun, 7 Sep 2014 22:58:40 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Cc: Eric Wong Subject: [PATCH 1/2] feed: sort child messages (forward) chronologically Date: Sun, 7 Sep 2014 22:58:35 +0000 Message-Id: <1410130716-9033-1-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.1.0.3.g7cd1957.dirty List-Id: Only root messages should be sorted in reverse chronological order, child messages should be chronological. This gives precedence to _topics_, but also for initial replies. This improves readability when several messages appear at the same nesting level, and helps git patch series' appear correctly as: [PATCH 0/3] ... [PATCH 1/3] ... [PATCH 2/3] ... [PATCH 3/3] ... Instead of (what it was previously): [PATCH 0/3] ... [PATCH 3/3] ... [PATCH 2/3] ... [PATCH 1/3] ... --- lib/PublicInbox/Feed.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 646c85c..1f1c0d6 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -77,15 +77,21 @@ sub generate_html_index { $feed_opts->{atomurl} . '" type="application/atom+xml"/>' . '' . PRE_WRAP; - # sort by date, most recent at top + # sort child messages in chronological order $th->order(sub { sort { - $b->topmost->message->header('X-PI-Date') <=> - $a->topmost->message->header('X-PI-Date') + $a->topmost->message->header('X-PI-Date') <=> + $b->topmost->message->header('X-PI-Date') } @_; }); + my %seen; - dump_msg($_, 0, \$html, time, \%seen) for $th->rootset; + # except we sort top-level messages reverse chronologically + for (sort { (eval { $b->message->header('X-PI-Date') } || 0) <=> + (eval { $a->message->header('X-PI-Date') } || 0) + } $th->rootset) { + dump_msg($_, 0, \$html, time, \%seen); + } Email::Address->purge_cache; -- EW