From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7374 invoked by alias); 27 Apr 2013 10:18:08 -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: 31341 Received: (qmail 189 invoked from network); 27 Apr 2013 10:17:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 74.125.82.54 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to:cc :content-type; bh=4075y7rdaIXQ1SIILUmoka32vtENfT7/vxtDdhvA1QA=; b=HXVaL9/KW3TH0wZDPHHbU+eubTe15hB96yTBWfd4D4/NXOBkkPk7PKNNwHpnKloo8F LhGUN3IsvcaDR90yReJ+osQcLzM7a3+xYNeesZyjzaDA8qn/meJQbzJVgTp29bMjN6C4 BX2Pmpszj0nrlRtCXnwqCjnoJAZdqG3XnPLvaicwq08g5sD1VRdjpjxsyrBYGnL/LoN3 fH4CbtURlyBmh5ffZYtcRAiKNYN93kuaCRj2O3viLV3yGuN/DK8CZT7MN15YKLeSodlQ /Ef3J/yotm0bksvPHMSG6N5K+kidzY9TV+CTuV6rqmkiuHX7D5tTq/Nmbs5MNbVFXP1B 0GBw== MIME-Version: 1.0 X-Received: by 10.194.158.42 with SMTP id wr10mr86504353wjb.23.1367057547877; Sat, 27 Apr 2013 03:12:27 -0700 (PDT) Date: Sat, 27 Apr 2013 05:12:27 -0500 Message-ID: Subject: No way to properly complete specific set of files From: Felipe Contreras To: zsh-workers@zsh.org Cc: Felipe Contreras Garza Content-Type: text/plain; charset=UTF-8 Hi, I have an array, let's say: files=('Documents' 'Downloads' 'Downloads/test' 'Videos') And I want to complete those files, with all the niceties that _file has. I could do the same as _git and others do: _multi_parts -f -- / files But that doesn't work; the files are not detected. And it doesn't complete the same way. Or I could use _path_files, as somebody suggested on the list, but that doesn't limit the list of files. It would have been very easy to tell _path_files which files to complete, but no, I have to manually implement the completion myself: --- #compdef foobar _foobar_1 () { _multi_parts -f -- / $1 } _foobar_2 () { _path_files } _foobar_3 () { local -a list local pfx="" cur="${words[CURRENT]}" file case "$cur" in ?*/*) pfx="${cur%/*}" cur="${cur##*/}" pfx="${pfx}/" ;; esac for file in ${(P)1}; do case "$file" in ${pfx}*) file="${file##$pfx}" ;; *) continue ;; esac case "$file" in ?*/*) list+="${file%%/*}" ;; *) list+="${file}" ;; esac done compadd -Q -p "${pfx-}" -f -a list } _foobar () { local -a files files=('Documents' 'Downloads' 'Downloads/test' 'Videos') _foobar_3 files return 0 } _foobar --- Am I missing something? -- Felipe Contreras