From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26776 invoked by alias); 22 Jul 2016 07:20:40 -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: 38913 Received: (qmail 23157 invoked from network); 22 Jul 2016 07:20:40 -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.127755 secs); 22 Jul 2016 07:20:39 -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 1/2] _pkg-config: Complete variables for --variable. Date: Fri, 22 Jul 2016 07:20:32 +0000 Message-Id: <1469172033-7560-1-git-send-email-danielsh@tarsus.local2> X-Mailer: git-send-email 2.1.4 --- Completion/Unix/Command/_pkg-config | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Completion/Unix/Command/_pkg-config b/Completion/Unix/Command/_pkg-config index e44b368..54955eb 100644 --- a/Completion/Unix/Command/_pkg-config +++ b/Completion/Unix/Command/_pkg-config @@ -20,7 +20,7 @@ arguments=( "--libs-only-l[print the -l part of \"--libs\"]" "--libs-only-other[output other libs]" "--list-all[list all known packages]" - "--variable=[return the value of the specified variable]:variable" + "--variable=[return the value of the specified variable]:variable:->variable" "--define-variable=[set the global value for a variable]:name value pair" "--uninstalled[return success if any \"-uninstalled\" packages are being used]" "--exists[test whether the package exists or not]" @@ -33,11 +33,23 @@ arguments=( "*: :->packages" ) -_arguments -C $arguments && ret=0 +_arguments -C -S : $arguments && ret=0 -if [[ -n $state ]] ; then - packages=( ${${(f)"$(_call_program packages pkg-config --list-all)"}%% *} ) - _wanted packages expl 'package' compadd -a - packages && ret=0 -fi +case $state in + (packages) + packages=( ${${(f)"$(_call_program packages pkg-config --list-all)"}%% *} ) + _wanted packages expl 'package' compadd -a - packages && ret=0 + ;; + + (variable) + if [[ $line[1] != '-' ]]; then + local -a variables=( ${${(f)"$(_call_program variables "pkg-config --print-variables -- ${(q)line[1]}")"}} ) + _wanted variables expl 'variable' compadd -a - variables && ret=0 + else + _message "variable" + fi + ;; + +esac return ret