zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Completion introspection
Date: Sun, 31 May 2020 10:44:05 +0200	[thread overview]
Message-ID: <CAN=4vMoBiGtmVNYEuv6=cQnLegFBhVtksOGsr+DC4AMXPcok2Q@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]

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.

             reply	other threads:[~2020-05-31  8:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31  8:44 Roman Perepelitsa [this message]
2020-06-01  8:07 ` Daniel Shahaf
2020-06-01  8:22   ` Roman Perepelitsa
2020-06-02 13:43     ` Oliver Kiddle
2020-07-01 17:46       ` Roman Perepelitsa

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='CAN=4vMoBiGtmVNYEuv6=cQnLegFBhVtksOGsr+DC4AMXPcok2Q@mail.gmail.com' \
    --to=roman.perepelitsa@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).