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

Completion issues



Thanks to some notes from Sven, I was able to update chapter six of the
user guide, during which these matters arose.  When I understand them, I'll
upload the new version.  If that passes muster, I'll transfer it to the
main zsh web site.  I know Sven has actually asked about some of these,
including the first one.

First, I hate the new behaviour of _complete_help.  I use it to find out
what context I'm in.  Unfortunately I don't get to see that, because a huge
list of style has scrolled by.  This is useful information, but should be
decanted to another function --- perhaps _complete_long_help, with the
default binding ^X^H (? ^H has other uses, so maybe there's something
better).  I don't think a style to turn off styles in ^Xh is good enough,
there's too much mucking around, and you may want the style information
anyway.  A workable alternative is that a numeric argument activates the
style list --- this feature could be configurable by a style.

Second, if I understood correctly, the default behaviour for completion is
to ignore ignored completions completely.  Thus the behaviour of $fignore
has changed.  If this is right, _ignored should definitely be added to the
default completers.  Certainly people may prefer it without, but it should
be up to them to change the old behaviour.

Next, I'm in a mess with the tag label stuff.  First of all,
I tried this:
 zstyle ':completion:*:*:-command-:*' tag-order \
   'functions:-non-comp:non-completion\ functions *' functions
 zstyle ':completion:*:functions-non-comp' ignored-patterns '_*'
pretty much what's in the manual, except with a name.  Now listing
completions for zfl gives me
  Completing non-completion functions
  zfls 
  Completing shell function
  zfls 
  Completing alias
  zfls 
Forget the last one; arguably you should only get the alias in this case,
since that's what will actually run, but I can see that's a
sophistication.  It's a bit annoying that I get the same function, for the
same tag, both with filtering and without.  With a long list it's going to
be worse.  Have I missed something?

Also, if I remember right the tag label stuff was partly inspired by the
example in the guide about ignoring functions matching `_*'.  That can
still be done using _ignored; Sven's sent me how to do that for the guide.
It can also be done by:
  zstyle ':completion:*' tag-order functions:-non-comp
  zstyle ':completion:*:functions-non-comp' ignored-patterns '_*'
(for some reason didn't seem to work before, but does now, so I presume I
fouled up).  The only problem there is I don't really want to upset the
global tag-order for what is really a local problem for one tag.  So I
replaced the first line with:
  zstyle ':completion:*:functions' tag-order functions:-non-comp
This doesn't work, and I can understand why it wouldn't --- looking up a
tag using a tag is distinctly odd.  But the manual implies this works with
options:
  zstyle ':completion:*:options' tag-order 'options:-long:long options
        options:-short:short options
        options:-single-letter:single letter options'
(formatted here with a ghastly offset of some thirty characters but I
suppose that's my problem).  As a subsidiary question, what happened to the
backslashes the manual claims are needed for the spaces in the names? More
importantly, what the heck's going on? Apparently looking up the tag
`options' will, after all, force a re-lookup with options split into three.
As far as I can see, this example is the only thing in the manual which
tells you one way or the other whether you can explicitly split up tags
into sub-tags like this. I'm now distinctly confused.  Explanation?

I came across the same problem when trying to explain _next_label using the
code in _mh.  Looking at the code, which is this:
  if _wanted sequences; then
    while _next_label sequences expl sequence; do
      compadd "$expl[@]" $(mark $foldnam 2>/dev/null | 
			   awk -F: '{ print $1 }') &&
        ret=0
      compadd "$expl[@]" reply next cur prev first last all unseen && ret=0
      _files "$expl[@]" -W folddir -g '<->' && ret=0
      (( ret )) || return 0
    done
I would expect the following to work:
  zstyle ':completion:*:sequences' tag-order sequences:-name sequences:-num
  zstlye ':completion:*:sequences-name' ignored-patterns '<->'
  zstyle ':completion:*:sequences-num' ignored-patterns '^<->'
prefering named sequences to messages which are just numbers.  But it
doesn't.  I noted that despite being inside the _wanted, _files is used
instead of _path_files, so I thought maybe it was using the files tag, but
assuming a split into `sequences' and `files' doesn't seem to work either.
What's the right way of doing this?

By the way, the example given in the manual of ignored-patterns and tag
labels,
  zstyle ':completion:*:*:-command-:*' tag-order 'functions:-non-comp'
  zstyle ':completion:*:functions-non-comp' ignored-patterns '_*'
(= in command position, prefer the `functions' tag but use it with the name
functions-non-comp; anywhere you see that tag, exclude patterns matching
`_*) isn't particularly good, since the issue only really arises in command
position after you've typed a character, hence you really need
correction/approximation to test this, and it's hard to think of an
example.  I've borrowed this from the manual until I or someone else can
think of another clean, simple example.

Another thing:  I couldn't get matcher-list to work for a labelled
completer, e.g. _complete:-extended.  When I switched to matcher instead,
it worked fine.  This fit my preconception, when I eventually decided what
that would have been, because I though matcher-list was decided once right
at the start.  However, the manual explicitly says that you can use
matcher-list with labelled completers.

Tail-ender:  this is a real bug:
  % zsh -f
  % autoload -U compinit; compinit -D
  % zstyle ':completion:*' completer _expand _complete
  % zstyle ':<TAB>
           ^this gets replaced by an character from the upper end of
            ISO-8859-1 which I didn't particularly want to see.

The style subst-globs-only is several times referred to without the
plural, which is particularly annoying in _zstyle, but also occurs in the
doc.  (No patch, since it's almost half past midnight and I like to eat
this evening.)

This is probably known, but _next_tags doesn't work well with menu
completion.  Ideally, it should probably remove the current choice if the
last command was a menu completion and replace it with the first choice
from the list generated with the next tag.  Also, the message at the top
doesn't change; you still see `Completing TeX or LaTeX file' if you cycle
through to completing directories.  Maybe this is a feature.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxxxxxxxxxxxxxxxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



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