+sub quote_hdr_buf ($$) {
+ my ($self, $eml) = @_;
+ my $hbuf = '';
+ my $to = $eml->header_raw('Reply-To') //
+ $eml->header_raw('From') //
+ $eml->header_raw('Sender');
+ my $cc = '';
+ for my $f (qw(To Cc)) {
+ for my $v ($eml->header_raw($f)) {
+ next if $v !~ /\S/;
+ $cc .= ", $v";
+ $to //= $v;
+ }
+ }
+ substr($cc, 0, 2, ''); # s/^, //;
+ PublicInbox::View::fold_addresses($to);
+ PublicInbox::View::fold_addresses($cc);
+ _xs($to);
+ _xs($cc);
+ $hbuf .= "To: $to\n" if defined $to && $to =~ /\S/;
+ $hbuf .= "Cc: $cc\n" if $cc =~ /\S/;
+ my $s = $eml->header_str('Subject') // 'your mail';
+ _xs($s);
+ substr($s, 0, 0, 'Re: ') if $s !~ /\bRe:/i;
+ $hbuf .= "Subject: $s\n";
+ if (defined(my $irt = $eml->header_raw('Message-ID'))) {
+ _xs($irt);
+ $hbuf .= "In-Reply-To: $irt\n";
+ }
+ $self->{-colored}->($self, 'hdrdefault', $hbuf);
+ my ($n) = PublicInbox::Address::names($eml->header_str('From') //
+ $eml->header_str('Sender') //
+ $eml->header_str('Reply-To') //
+ 'unknown sender');
+ my $d = $eml->header_raw('Date') // 'some unknown date';
+ _xs($d);
+ _xs($n);
+ ${delete $self->{obuf}} . "\nOn $d, $n wrote:\n";
+}
+