-
- # --external is enabled by default, but allow --no-external
- if ($opt->{external} //= 1) {
- my $cb = $lxs->can('prepare_external');
- $self->_externals_each($cb, $lxs);
+ if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
+ $lxs->prepare_external($lse);
+ } else {
+ my $tmp = PublicInbox::LeiXSearch->new;
+ $tmp->prepare_external($lse);
+ $self->ale->refresh_externals($tmp);
+ }
+ if (@only) {
+ for my $loc (@only) {
+ my @loc = $self->get_externals($loc) or return;
+ $lxs->prepare_external($_) for @loc;
+ }
+ } else {
+ my (@ilocals, @iremotes);
+ for my $loc (@{$opt->{include} // []}) {
+ my @loc = $self->get_externals($loc) or return;
+ $lxs->prepare_external($_) for @loc;
+ @ilocals = @{$lxs->{locals} // []};
+ @iremotes = @{$lxs->{remotes} // []};
+ }
+ # --external is enabled by default, but allow --no-external
+ if ($opt->{external} //= 1) {
+ my %x;
+ for my $loc (@{$opt->{exclude} // []}) {
+ my @l = $self->get_externals($loc, 1) or return;
+ $x{$_} = 1 for @l;
+ }
+ my $ne = $self->externals_each(\&prep_ext, $lxs, \%x);
+ $opt->{remote} //= !($lxs->locals - $opt->{'local'});
+ if ($opt->{'local'}) {
+ $lxs->{remotes} = \@iremotes if !$opt->{remote};
+ } else {
+ $lxs->{locals} = \@ilocals;
+ }
+ }