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

Re: disable substring match on command name



On Mar 3,  3:13pm, Amm wrote:
}
} Thanks a lot for putting a lot of effort here. I appreciate it.

You're welcome!

} > On Mar 3, Bart Schaefer wrote:
} > Finally we tweak the style that compsys is actually going to look up,
} > zstyle -e ':completion:*' matcher-list \
} >   'zstyle -a "word-${CURRENT}:completion:$curcontext" matcher-list reply'
} 
} But your solution possible would not work if command is entered
} after pipe symbol.
} 
} echo 1 2 | sort
} 
} In that example sort would NOT be the first word but 4th or 5th.

Just to clear this up:  It would still be the 1st word.  By the time
the $words array has been populated, the completion internals have
figured out that "|" separates two commands and you are presumably
finished completing the one that does not encompass $CURSOR, so it
removes the "|" and everything before it.  In fact, if you had

 echo 2 1 | sort | tr 12 34

and were completing after "sort", it would also remove "| tr ..."
so that $words contains only the relevant command.  None of compsys
would work if every completer had to figure out for itself what to
use for $CURRENT in a pipeline or complex command.

} I have not tried your solution though. And I also find it little
} bit hackish.

Admittedly it is, and in fact I had forgotten that individual "matcher"
zstyles were looked up by tag.  The key bit to your solution is ...

} I removed matcher-list line.

... because matcher-list is applied ALONG WITH the "matcher" style if
both are specified.  There have often been questions in the past about
how to limit the application of matcher-list given how little context
is used, and I found the chaining idea interesting.

} zstyle ':completion:*' tag-order '*' '*:-afrr' '*:-aflr'
} zstyle ':completion:*:all-files-afrr' matcher 'r:|[._-]=** r:|=**'
} zstyle ':completion:*:all-files-aflr' matcher 'l:|=* r:|=*'

It might be worthwhile to note in the docs that matcher-list is in
effect a shorthand for something like this, but I can't find a good
place that doesn't confuse the flow of the existing examples ...

Here, though, is some related clarification of the docs.


diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index c304461..7dacbcf 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1995,11 +1995,11 @@ only be performed with the `tt(*)' inserted.
 kindex(matcher, completion style)
 item(tt(matcher))(
 This style is tested separately for each tag valid in the current
-context.  Its value is added to any match specifications given by the 
+context.  Its value is tried before any match specifications given by the 
 tt(matcher-list) style.  It should be in the form described in
 ifzman(the section `Completion Matching Control' in zmanref(zshcompwid))\
 ifnzman(noderef(Completion Matching Control))\
-.
+.  For examples of this, see the description of the tt(tag-order) style.
 )
 kindex(matcher-list, completion style)
 item(tt(matcher-list))(
@@ -2022,9 +2022,11 @@ without repetition:
 example(zstyle ':completion:*' matcher-list '' '+m:{a-z}={A-Z}' '+m:{A-Z}={a-z}')
 
 It is possible to create match specifications valid for particular
-completers by using the third field of the context.  For example, to
-use the completers tt(_complete) and tt(_prefix) but only allow
-case-insensitive completion with tt(_complete):
+completers by using the third field of the context.  This applies only
+to completers that override the global matcher-list, which as of this
+writing includes only tt(_prefix) and tt(_ignored).  For example, to
+use the completers tt(_complete) and tt(_prefix) but allow
+case-insensitive completion only with tt(_complete):
 
 example(zstyle ':completion:*' completer _complete _prefix
 zstyle ':completion:*:complete:*' matcher-list \ 



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