From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] view: avoid excessive indentation in thread summary
Date: Wed, 30 Dec 2015 22:32:38 +0000 [thread overview]
Message-ID: <20151230223238.5469-1-e@80x24.org> (raw)
We already use "` " (backtick + space) to denote one indentation
level, so do not excessively indent and always pad with one
level less of spaces.
The 'x' operator in Perl handles negative values, so subtracting
one from level=0 will result in an empty string without spaces.
---
lib/PublicInbox/View.pm | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index bcd2ebc..ad03cfe 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -684,6 +684,11 @@ sub __thread_entry {
1;
}
+sub indent_for {
+ my ($level) = @_;
+ INDENT x ($level - 1);
+}
+
sub __ghost_prepare {
my ($state, $node, $level) = @_;
my $ghost = $state->{ghost} ||= [];
@@ -753,7 +758,7 @@ sub _inline_header {
my $d = _msg_date($mime);
$f = PublicInbox::Hval->new($f)->as_html;
$d = PublicInbox::Hval->new($d)->as_html;
- my $pfx = ' ' . $d . ' ' . (INDENT x $level);
+ my $pfx = ' ' . $d . ' ' . indent_for($level);
my $attr = $f;
$state->{first_level} ||= $level;
@@ -809,7 +814,7 @@ sub inline_dump {
} else {
my $dot = $level == 0 ? '' : '` ';
my $pfx = (' ' x length(' 1970-01-01 13:37 ')).
- (INDENT x $level) . $dot;
+ indent_for($level) . $dot;
$$dst .= $pfx;
$$dst .= ghost_parent("$upfx../", $node->messageid) . "\n";
}
@@ -887,7 +892,7 @@ sub dump_topics {
my ($mid, $ts) = @{delete $latest->{$topic}};
$mid = PublicInbox::Hval->new($mid)->as_href;
$subj = PublicInbox::Hval->new($subj)->as_html;
- $pfx = INDENT x ($level - 1);
+ $pfx = indent_for($level);
my $nl = $level == $prev ? "\n" : '';
my $dot = $level == 0 ? '' : '` ';
$dst .= "$nl$pfx$dot<a\nhref=\"$mid/t/#u\"><b>$subj</b></a>\n";
--
EW
reply other threads:[~2015-12-30 22:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151230223238.5469-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.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.
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).