From 8b91bd5f929bf166ee3a79dec43fba0e68b1dc8e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Sep 2021 07:41:55 +0000 Subject: lei: various completion improvements "lei export-kw" no longer completes for anonymous sources. More commands use "lei refresh-mail-sync" as a basis for their completion work, as well. ";AUTH=ANONYMOUS@" is stripped from completions since it was preventing bash completion from working on AUTH=ANONYMOUS IMAP URLs. I'm not sure if there's a better way, but all of our code works fine without specifying AUTH=ANONYMOUS as a command-line arg. Finally, we fallback to using more candidates if none can be found, allowing multiple URLs to be completed. --- lib/PublicInbox/LeiExportKw.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LeiExportKw.pm') diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm index d5533a2a..cea9beeb 100644 --- a/lib/PublicInbox/LeiExportKw.pm +++ b/lib/PublicInbox/LeiExportKw.pm @@ -127,9 +127,13 @@ EOM sub _complete_export_kw { my ($lei, @argv) = @_; - my $lms = $lei->lms or return; + my $lms = $lei->lms or return (); my $match_cb = $lei->complete_url_prepare(\@argv); - map { $match_cb->($_) } $lms->folders; + # filter-out read-only sources: + my @k = grep(!m!(?://;AUTH=ANONYMOUS\@|\A(?:nntps?|s?news)://)!, + $lms->folders($argv[-1], 1)); + my @m = map { $match_cb->($_) } @k; + @m ? @m : @k; } no warnings 'once'; -- cgit v1.2.3-24-ge0c7