+sub list {
+ my ($lei, $pfx) = @_;
+ my $lss_dir = $lei->share_path.'/saved-searches/';
+ return () unless -d $lss_dir;
+ # TODO: persist the cache? Use another format?
+ my $f = $lei->cache_dir."/saved-tmp.$$.".time.'.config';
+ open my $fh, '>', $f or die "open $f: $!";
+ print $fh "[include]\n";
+ for my $p (glob("$lss_dir/*/lei.saved-search")) {
+ print $fh "\tpath = ", cquote_val($p), "\n";
+ }
+ close $fh or die "close $f: $!";
+ my $cfg = PublicInbox::Config::git_config_dump($f);
+ unlink($f);
+ bless $cfg, 'PublicInbox::Config';
+ my $out = $cfg->get_all('lei.q.output') or return ();
+ map {;
+ if (s!\A(?:maildir|mh|mbox.+|mmdf):!!i) {
+ -e $_ ? $_ : (); # TODO auto-prune somewhere?
+ } else { # IMAP, maybe JMAP
+ $_;
+ }
+ } @$out
+}
+