Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zstyle problems



On Oct 2, 10:50am, Jonas Juselius wrote:
} Subject: Re: zstyle problems
}
} I still think this is a bit confusing. Typing 'cd' and then pressing
} ^Xh says 'tags in context :completion::complete:cd::', which made me
} think that this was the actual context...

It is the context for the tags (hence "tags in context ..."), but not the
context for any old style that has nothing to do with tags.

I agree that it's confusing at first, but this is the way the system is
structured; because it isn't just based on simply completing after a
known command name any more, there has to be a way to bootstrap it.  The
completers are what figure out the full context by examining the command
line in detail (among other things that they do).

} What would be the correct way of defining different (individual)
} completions for 'cd' and other commands?

There's a difference between defining completions (which is done with
compdef and a function) and defining completion behaviors (which is done
with zstyles for completers and tags).  Some completers implement other
special styles (like max-errors for _correct) to adjust their behavior,
but there isn't direct support for changing the entire set of completers
based on the command name, because of the bootstrapping issue.

However, there's an example in the documentation under the _approximate
completer that shows how to change the entire list of completers based on
a condition of your own invention.  (Hmm, I just noticed that example is
missing a "-e" flag in the "zstyle" command.  Doc typo.)  You'd want
something like

    zstyle -e ':completion::*' completer '\
      case $words[1] in
      (cd|chdir) reply=(_complete);;
      (*) reply=(_complete _correct _approximate);;
      esac'

} Ok, I tried this but I didn't see any difference from the standard
} completion...

I presume you mean you tried *this*:

} >     zstyle ':completion::complete:-tilde-:*' tag-order \
} > 	    named-directories users directory-stack

} Could this have something to do with menu completion and sorting?

You want to look at the group-order style, and its partner group-name,
as well as tag-order.  If you haven't already, add to you .zshrc:

    zstyle ':completion:*' group-name ''

and see if that doesn't change something.  Then start experimenting
with group-order.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author