From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18989 invoked by alias); 20 Sep 2016 08:55:46 -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: X-Seq: 21950 Received: (qmail 25986 invoked from network); 20 Sep 2016 08:55:46 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com 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(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.634415 secs); 20 Sep 2016 08:55:46 -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=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=/91x0jvsBt2xwdEP ODM6voxqWO8=; b=fz0iWQbnJKXoC7A19E7Shz2Kxc5H35dKB1qlG1TD03KitXVh jKIFuxpZjWd13azz5JVqyh2+iyIFQbWJ1zMTTI1M8EY9EeItdT46KzubNTEQSEiH GHa7PS5pwTEQxzi76/2WYZPVKZDI3GPQS2S4nQgqodM1I+vthTNRAl3yl8w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=/91x0jvsBt2xwdE PODM6voxqWO8=; b=Xjc19MyaxhVzSWJ2e1d0TGzIYnoA7JQl8OlKOwYOdIJG6DJ 0cbGYJ0mOGH86UPBsln+Ck38Q67vQSLBtGrLEyzafJgYAMtxEMh5barr41fHX7Xf r9AJXjpqoWiTSavlYPcHbNWr+0s5QPBv0oCr8y+t+d44ppBcsv7Rf9Ub7PbA= X-Sasl-enc: xXG7xxM3sKg1SO9M0ZykltZ1ZUJI6PNbA5qugqh0V7Ds 1474361733 Date: Tue, 20 Sep 2016 08:54:31 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: Setting the 'completer' style - _match and ** Message-ID: <20160920085431.GA3720@fujitsu.shahaf.local2> References: <20160912233028.GA17257@fujitsu.shahaf.local2> <160919074515.ZM28018__10595.0927398682$1474296416$gmane$org@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <160919074515.ZM28018__10595.0927398682$1474296416$gmane$org@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) [ Your MUA seems to have changed the subject: your email has a hyphen where the email you reply to had an em dash. ] Bart Schaefer wrote on Mon, Sep 19, 2016 at 07:45:15 -0700: > On Sep 12, 11:30pm, Daniel Shahaf wrote: > } > } I've come up with the following: > } . > } bindkey $'\t' complete-word > } zstyle ':completion:*' completer _all_matches _match-ds _expand _complete _ignored > } _match-ds() { > } [[ $PREFIX$SUFFIX != *[*][*]* ]] && _match "$@" > } } > } . > } The idea is that if a pattern contains "**" then _match('s wrapper) will > } leave it for _expand to process. > } > } Is there another way to implement this? > > You could probably come up with a "zstyle -e" formulation that would only > include_match in the completer value in the right circurmstances. How would I do that? I think the "right circumstances" are [[ $curtag == *(file|dir)* ]], but the 'completer' style is looked up under the context :completion:::::, before tags are known. I tried to workaround that by defining a compadd() wrapper function that checks $curtag before calling the builtin compadd, but that caused «: **/generic*» to complete nothing. > I'll note in passing that _match is supposed to be used after _complete, The documentation says so too, but gives no rationale, and empirically it works before _complete too. Why should _match be later than _complete? > not before _expand. Might it be better to suppress the _expand completer > in the cases where you want _match rather than the other way around? Perhaps I could do something like this: . _match-ds2() { _match "$@" if that added no matches; then curcontext=${curcontext/:match-ds2:/expand} _expand "$@" fi } . where the condition is implemented using $? or $compstate[nmatches], and remove _expand from the 'completer' style entirely. I'll give this a shot later. I want _match basically everywhere; when I want _expand I can invoke it directly with ^X* . I even use _match as . rsync -[ap] . to get the description of the -p option without getting a screenful of other options. Thanks for the answer, Daniel