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

Completion introspection



What's the best way to retrieve the current completion word, tags and
contexts from a zle widget?

For example, suppose I type this:

  ls ~/foo/

If I now invoke _complete_help via its default ^X^H binding, I see this:

  tags in context :completion::complete:ls::
      argument-rest options  (_arguments _ls)
  tags in context :completion::complete:ls:argument-rest:
      globbed-files  (_files _arguments _ls)

I'd like to define a regular zle widget (not a completion widget) and am
looking for a way to retrieve:

  - the word that would be completed if I pressed tab: ~/foo/
  - the first context: :completion::complete:ls::
  - tags from the last context: globbed-files

Preferably this should be fast. If possible, I'd like to avoid the
generation of completion candidates (no globbing of ~/foo/* in this
example).

If some of these are easier to retrieve than others, I could do with a
subset. E.g., just the word would already be useful. Or just the first
context. Or just the tags from the last context.

Roman.


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