From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id b0082e40 for ; Mon, 4 Nov 2019 21:25:27 +0000 (UTC) Received: (qmail 18725 invoked by alias); 4 Nov 2019 21:25:21 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24398 Received: (qmail 9027 invoked by uid 1010); 4 Nov 2019 21:25:20 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f178.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25622. spamassassin: 3.4.2. Clear:RC:0(209.85.208.178):SA:0(-1.9/5.0):. Processed in 2.10292 secs); 04 Nov 2019 21:25:20 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.178 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Coqt1BsX+DlBRzoHpcCfV9uh+UrQq3GK8zF38+ygLlw=; b=rN7CwrLgGmeNT5RHJzg/AAfGVx/N2OvrpHLlLs+0PxnNEcUajuN4cNTj1kiI141xpL Vlx06Yn7fmcR2k1dBDctICzGFLzjuKLEXny4l0IgCywtT3nP0YADKDjGrPeLjdIRK2Cu cQYWZmulZKw1KB2Euz7pdLpHpN8WTJbKSDa4Y1uoNvcNoP9NBAlyLTF8AJpZUSL61F+M G3KU5XjIjZo8s8BCkOfPRYWF2MaqOcTldNFOFWTPPcsl7hCU4Xv8YssOTkdzHYaWSREM fIigLnNqfIKH5exr/X9U9gWAQSmuMdCXTKxAl8dYV3hlYbNByZ21cZMFGVOlEiinmP2m 8gbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Coqt1BsX+DlBRzoHpcCfV9uh+UrQq3GK8zF38+ygLlw=; b=EusuFZaqwwXWIPny05U/YnfHf1EZ4oWc5ThaCG1qic2RQsVKZFfzVNhpT/J+8WYJ83 IAFmzlMQC2y15CZGpznN90xh1gC+eSJuTjQ3y8LApEtwj+B+FybMGmjsipfIsPAcZa8d IhlexHQkPdvOFnyueYjqH4IOsTn/qHCVHp2KSmI6PjX4ZvmkCFo+QUzE+yl4pa7eexWg 5CUS5nHo+AlVkky1E3Q0G2JbeWKybs7vjdhgRDqSl6wQQ/QzodBtI/+9QQntOxsfXrEp RR+X7T1LOOUhPH8E/dgiKkKqbxXZM9ErXFjBTflMJV+HRqnGDPwdTZ+IAqlIy4gGy4up VpAA== X-Gm-Message-State: APjAAAUrkbreHGxYvZiCtfQc+D5+DSuvlzzdkEqCOEzBdJCuEqPvGApL uD4qegY+Y7xU5bTe3+MgdPI7J3bmuh6EIb4a7EC9aQ== X-Google-Smtp-Source: APXvYqycgLxmYxIuEkMqtpb1x8tAesBxpfA0hfH6LpUQBoMF9qfKcz4evm+Zy2ivwC6MNQvXNwmVQfdbSc7oK1UaZfM= X-Received: by 2002:a05:651c:1b0:: with SMTP id c16mr19736721ljn.192.1572902683952; Mon, 04 Nov 2019 13:24:43 -0800 (PST) MIME-Version: 1.0 References: <206B06E5-8D28-4132-A0CC-BE070F9A5F7C@mac.com> <8F91689D-3069-4A1F-A4B2-3BF6F009B878@dana.is> <23662F36-B0E7-43FE-81AF-86C2C9D03044@mac.com> In-Reply-To: <23662F36-B0E7-43FE-81AF-86C2C9D03044@mac.com> From: Bart Schaefer Date: Mon, 4 Nov 2019 15:24:32 -0600 Message-ID: Subject: Re: Use of (e:...:) glob qualifier with _files -g? To: Chris Nebel Cc: zsh-users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Nov 4, 2019 at 2:42 PM Chris Nebel wrote: > > My problem then becomes how to let people configure the completion so the= y can use any extensions I didn=E2=80=99t cover. I=E2=80=99m guessing that= the answer has something to do with zstyle and the =E2=80=9Cfile-patterns= =E2=80=9D style, but I=E2=80=99m having trouble turning the examples in zsh= compsys(1) into something that works. To make this a bit more concrete, sa= y my completion code looks something like this: > > files -g '*.(cpio|tar|xar)' > > =E2=80=A6and someone wants to also match =E2=80=9C*.cpgz=E2=80=9D files, = what would they do? Typically you would assign the pattern to a variable, and then use a style to allow the user to substitute his own value for that variable. You can name the style anything you like, but a usual approach would be to choose a name that is already in use for similar purposes. If you call the existing _files completer it will handle the zstyle lookup. You need to determine a context name for your completion and assign that to a local variable named curcontext to inform other functions that look for styles of the context in which they are being invoked. To put this together, you'd simply do something like: local curcontext=3D"${curcontext%:*:*}:darwinup" _files -g '*.(cpio|tar|xar)' Then a user can write zstyle ':completion:*:darwinup' file-patterns "%p *.cpgz=E2=80=9D where %p will be replaced by your defaults and *.cpgz will also be tried (see previous remarks about why spaces are complicated).