From 66512e177390aedb4a9380484230768621528e57 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 23 Aug 2022 08:31:56 +0000 Subject: view: generate query in single-message and commit views The dfblob: search prefix is probably under-utilized, but is extremely powerful IMHO. To make it easier-to-use, add a search textarea with it prefilled with values for the existing patch message. This allows users to easily run a query for all patches which alter or result in either pre or post-image blobs in the current patch. Behavior changes are as follows: "changed" in the diffstat jumps to the bottom of the message. For /T/ and /t/, it goes to the "related" anchor which is just above the reply instructions in the single-message view. For the single message view, it'll jump to the textarea search form. I initially wanted to use a normal `{mhref} = $mhref; + $ctx->{end_id} = "e$id"; $ctx->{obuf} = \$rv; $eml->each_part(\&add_text_body, $ctx, 1); delete $ctx->{obuf}; @@ -256,6 +258,9 @@ sub eml_entry { " raw" . " reply"; + delete($ctx->{-qry}) and + $rv .= qq[ related]; + my $hr; if (defined(my $pct = $smsg->{pct})) { # used by SearchView.pm $rv .= "\t[relevance $pct%]"; @@ -820,15 +825,38 @@ sub _parent_headers { # returns a string buffer sub html_footer { my ($ctx, $hdr) = @_; - my $ibx = $ctx->{ibx}; my $upfx = '../'; my $skel; my $rv = '
';
-	if ($ibx->over) {
+	my $related;
+	my $qry = delete $ctx->{-qry};
+	if ($qry && $ctx->{ibx}->isrch) {
+		my $q = ''; # search for either ancestor or descendent patches
+		for (@{$qry->{dfpre}}, @{$qry->{dfpost}}) {
+			chop if length > 7; # include 1 abbrev "older" patches
+			$q .= "dfblob:$_ ";
+		}
+		chop $q; # omit trailing SP
+		local $Text::Wrap::columns = COLS;
+		local $Text::Wrap::huge = 'overflow';
+		$q = wrap('', '', $q);
+		my $rows = ($q =~ tr/\n/\n/) + 1;
+		$q = ascii_html($q);
+		$related = <
find likely ancestor, descendant, or conflicting patches:
+
+\t(help)
+EOM + } + if ($ctx->{ibx}->over) { my $t = ts2str($ctx->{-t_max}); my $t_fmt = fmt_ts($ctx->{-t_max}); - $skel .= <\t"; + $skel = <~$t_fmt UTC|newest] EOF @@ -869,6 +897,7 @@ EOF $rv .= qq(reply); $rv .= $skel; $rv .= '
'; + $rv .= $related // ''; $rv .= msg_reply($ctx, $hdr); } -- cgit v1.2.3-24-ge0c7