From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10001 invoked by alias); 20 Sep 2014 18:21:14 -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: 19119 Received: (qmail 6880 invoked from network); 20 Sep 2014 18:21:03 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140920112024.ZM29459@torch.brasslantern.com> Date: Sat, 20 Sep 2014 11:20:24 -0700 In-reply-to: Comments: In reply to "Yuri D'Elia" "Re: rsync --progress stops completion" (Sep 20, 3:20pm) References: <2002755.9ryFYYVtTN@note> <5418786F.8030001@thregr.org> <140916175124.ZM5742@torch.brasslantern.com> <54194198.2010607@thregr.org> <140917085133.ZM6725@torch.brasslantern.com> <541AA918.8060503@thregr.org> <140918093602.ZM7963@torch.brasslantern.com> <140918190130.ZM8366@torch.brasslantern.com> In-reply-to: Comments: In reply to "Yuri D'Elia" "Re: rsync --progress stops completion" (Sep 20, 3:25pm) X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: rsync --progress stops completion MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 20, 3:20pm, Yuri D'Elia wrote: } } I'll take rsync as an example here. } } $ rsync --unknown } } will stop the completion entirely. Surely, with _files you can go on, } but I would like /--?.*/ to be simply treated as an unknown argument, so } that a further flag would properly complete as expected as if --unknown } was never there in the first place. OK. so you'd like that. That doesn't mean everyone would like that, so you still haven't answered the question "how would you like to tell the completion system about it, if not in the completer zstyle?" On Sep 20, 3:25pm, Yuri D'Elia wrote: } } Also, to follow my previous discussion, I would somehow prefer a system } where the completion *allows* unknown flags as a general rule for all } completers. } } I don't have enough knowledge of the existing completers to know though } if this is feasible or not. It's not particularly feasible because every completion function is just that -- a shell function -- and there's no requirement that they be implemented by passing through any single control point, except for "compadd" by which time it is too late to affect the parse. It might be possible to add something to _arguments + comparguments to tell it to ignore things it can't parse, but that still won't cover *every* completion, and it would lead to false positives in cases where the failure of one parse is followed by attempting a different one -- so it would still have to be up to the individual completion functions to "decide" whether to tell _arguments to do this. However, perhaps the following is close enough to what you want? This is similar to doing "compset -n $CURRENT" except that it retains the first word (presumably the command name). _try_again() { [[ $compstate[context] = command && CURRENT -gt 2 ]] || return 1 words=("$words[1]" "${(@)words[CURRENT,-1]}") CURRENT=2 _compskip=default _normal -s } zstyle ':completion:*' completer _oldlist _expand _complete _try_again Obviously this defeats any attempt at making option suggestions mutually exclusive, and might (depending again upon the implementation of the completion function) end up suggesting options where only a non-option argument is valid.