zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Leonardo Barbosa <barbosa.leonardo@gmail.com>, zsh-users@zsh.org
Subject: Re: custom completion for listing *.tex is not working
Date: Tue, 03 Sep 2013 07:32:16 -0700	[thread overview]
Message-ID: <130903073216.ZM27351@torch.brasslantern.com> (raw)
In-Reply-To: <CAMXWGTwZB9wP4YbuW703sBErWZhRYrb6YpWZ2mGKqtGo08KOVg@mail.gmail.com>

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 <ctrl+x h>
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 <ctrl+x h>
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.


  reply	other threads:[~2013-09-03 14:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03 11:11 Leonardo Barbosa
2013-09-03 14:32 ` Bart Schaefer [this message]
2013-09-09 11:49   ` Leonardo Barbosa
2013-09-10 15:08     ` Bart Schaefer
2013-09-10 16:31       ` Peter Stephenson
2013-09-10 16:45         ` Bart Schaefer
2013-09-06 13:24 ` zzapper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130903073216.ZM27351@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=barbosa.leonardo@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).