From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7317 invoked by alias); 9 Sep 2013 11:51:00 -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: 17975 Received: (qmail 12703 invoked from network); 9 Sep 2013 11:50:46 -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 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.212.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=KmfHEaNqqgxHAE70+8QereSAqn6mliZhjYxQ6J6YDGE=; b=lpdrcZFPem/Sd74FXrtNpr3wuNkvO69V+ddXy0J2I0yO/weq9eQLjS+0+dRqWcPf/5 6z/ILPo3DnGTQp0piguq9bpvzBQH8Y5BlnoiaXmpwxJdUDUdp4gCmq5pjl4gSbke7LpT RGef9QuePDOKoX/C2yKjqjAocWgfKF0jADy+bBLhoHwKazoD5ZZMxOm4oFoWemckF0uw 09DX1yPGTa+sY/WJ73yb0G5JOOyJcVfV6W1qUfncUMkC0MTVAvvCU1FcJ8UO6Bd/Wg+P YRCjQqD4XVj+aMwriVFJTTK14vOT+8kGJGmiuJjvB+D8MpjaYT6MzA7o8pUNperMlqBL 0VHg== X-Received: by 10.58.215.15 with SMTP id oe15mr811872vec.25.1378727439864; Mon, 09 Sep 2013 04:50:39 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <130903073216.ZM27351@torch.brasslantern.com> References: <130903073216.ZM27351@torch.brasslantern.com> From: Leonardo Barbosa Date: Mon, 9 Sep 2013 08:49:59 -0300 Message-ID: Subject: Re: custom completion for listing *.tex is not working To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 Thanks for you prompt answer, Bart. I have tried your suggestion. zstyle ':completion:*:*:vi:*' file-patterns '*.tex:TeX-files' '%p:all-files' However, by doing so, it only through TeX files. So if multiples times it keeps suggesting the same TeX files, repeatedly, to me. I'd like TeX files to be priority, but, in case of more 's, it cycles through other files in the menu, too. I saw you example is similar to this example in the zsh manual: zstyle ':completion:*:*:rm:*' file-patterns \ '*.o:object-files' '%p:all-files' So in theory, it should have worked. Any idea? An just one more question, how can i make zsh to highlight the selected file in the menu while cycling through files? Best Leo On Tue, Sep 3, 2013 at 11:32 AM, Bart Schaefer wrote: > On Sep 3, 8:11am, Leonardo Barbosa wrote: > } > } I have tried this in order to make zsh suggests TeX files first to vi. > } > } vi() { command vi ${*:-*.tex(om[1])} } > > That doesn't do anything except cause "vi" with no arguments to attempt > to open the single most recent .tex file in the current directory; it > has no effect on tab completion. > > } zstyle ':completion:*:*:.tex:*' menu yes select > } zstyle ':completion:*:*:.tex:*' file-sort time > > The components of a completer style are (from the manual): > > :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:tag > > Mapping that onto the zstyles above, you've told the completion system > that a command named ".tex" should use menu selection sorted by time. > What you want is to have "vi" in that slot. > > } However, it doesn't work. Zsh is listing all types of files and not > } necessarily the TeX ones first. > > To do that, you adjust the set of possible tags (that last component of > the completion style). You can see what the current set of tags for "vi" > is by: > > zsh% vi > tags in context :completion::complete:vi:: > all-files (_files _default) > > That's not very useful, so you can use the file-patterns style to add > details (see the manual under file-patterns to explain %p): > > zstyle ':completion:*:*:vi:*' file-patterns \ > '*.tex:TeX-files' '%p:all-files' > > Note that because file-patterns is defining what the tags will become, the > tag part of the context pattern is always empty for this style. > > Now: > > torch% vi > tags in context :completion::complete:vi:: > TeX-files (_files _default) > all-files (_files _default) > > You can further refine this using the tag-order style. > > } Could any of you suggest me a hands on tutorial for zsh new completion > } system? > > The most comprehensive is probably the chapter on zsh completion published > in the "From Bash to Zsh" book. There is also > > http://zsh.sourceforge.net/Guide/zshguide06.html#l156 > > but it doesn't really work through a single increasingly complex example > the way you might want a tutorial to do.