From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20498 invoked by alias); 4 Aug 2016 15:54:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38994 Received: (qmail 14024 invoked from network); 4 Aug 2016 15:54:35 -0000 X-Qmail-Scanner-Diagnostics: from hermes.apache.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(140.211.11.3):SA:0(-1.3/5.0):. Processed in 0.126248 secs); 04 Aug 2016 15:54:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at apache.org does not designate permitted sender hosts) From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 2/3] _man: Fix two bugs when completing manpage filenames in separate-sections mode. Date: Thu, 4 Aug 2016 15:54:24 +0000 Message-Id: <1470326066-3241-3-git-send-email-danielsh@tarsus.local2> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1470326066-3241-1-git-send-email-danielsh@tarsus.local2> References: <1470326066-3241-1-git-send-email-danielsh@tarsus.local2> - No longer glob all files (the (-g)-less _path_files was virtually always called, by at least one of the multiple calls to _man_pages). - Actually separate sections (by propagating $expl). --- Completion/Unix/Command/_man | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index ef17ad8..ffe53be 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -87,6 +87,13 @@ _man() { done (( ret )) || return 0 done + ## To fall back to other sections' manpages when completing filenames, like + ## the 'else' codepath does: + # + # if (( ret )) && [[ $PREFIX$SUFFIX == */* ]]; then + # sect_dirname= + # _wanted manuals expl 'manual page' _man_pages && return + # fi return 1 else @@ -105,9 +112,13 @@ _man_pages() { # Easy way to test for versions of man that allow file names. # This can't be a normal man page reference. # Try to complete by glob first. - _path_files -g "*$suf" && return - _path_files - return + if [[ -n $sect_dirname ]]; then + _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.Z|.lzma)" "$expl[@]" + else + _path_files -g "*$suf" "$expl[@]" && return + _path_files "$expl[@]" + fi + return $? fi zparseopts -E M+:=matcher