unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] view: avoid excessive indentation in thread summary
@ 2015-12-30 22:32 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-12-30 22:32 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-30 22:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-30 22:32 [PATCH] view: avoid excessive indentation in thread summary Eric Wong

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).