From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DB0BE2007D for ; Wed, 3 Feb 2021 08:11:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 07/11] lei: complete basenames for include|exclude|only Date: Tue, 2 Feb 2021 22:11:39 -1000 Message-Id: <20210203081143.24424-8-e@80x24.org> In-Reply-To: <20210203081143.24424-1-e@80x24.org> References: <20210203081143.24424-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will make it even easier for RSI-afflicted users to use, since many externals may share a common prefix. --- lib/PublicInbox/LeiQuery.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 10b8d6fa..8015ecec 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -112,11 +112,22 @@ sub lei_q { sub _complete_q { my ($self, @argv) = @_; my $ext = qr/\A(?:-I|(?:--(?:include|exclude|only)))\z/; - # $argv[-1] =~ $ext and return $self->_complete_forget_external; my @cur; while (@argv) { if ($argv[-1] =~ $ext) { my @c = $self->_complete_forget_external(@cur); + # try basename match: + if (scalar(@cur) == 1 && index($cur[0], '/') < 0) { + my $all = $self->externals_each; + my %bn; + for my $loc (keys %$all) { + my $bn = (split(m!/!, $loc))[-1]; + ++$bn{$bn}; + } + push @c, grep { + $bn{$_} == 1 && /\A\Q$cur[0]/ + } keys %bn; + } return @c if @c; } unshift(@cur, pop @argv);