zsh-users
 help / color / mirror / code / Atom feed
* How to capture a list of completions from a zle widget
@ 2013-10-27 18:16 Thiago Padilha
  2013-10-27 20:43 ` Bart Schaefer
  2013-10-27 20:44 ` Valodim Skywalker
  0 siblings, 2 replies; 5+ messages in thread
From: Thiago Padilha @ 2013-10-27 18:16 UTC (permalink / raw)
  To: zsh-users

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

Hi

How can I capture a list of possible completions for the current values of
$LBUFFER $RBUFFER and $CURSOR in a zle widget? I know invoking 'zle
list-choices' will display on terminal, but I would like to capture those
in an array.

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to capture a list of completions from a zle widget
  2013-10-27 18:16 How to capture a list of completions from a zle widget Thiago Padilha
@ 2013-10-27 20:43 ` Bart Schaefer
  2013-10-27 20:44 ` Valodim Skywalker
  1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2013-10-27 20:43 UTC (permalink / raw)
  To: Thiago Padilha, zsh-users

On Oct 27,  4:16pm, Thiago Padilha wrote:
}
} How can I capture a list of possible completions for the current values
} of $LBUFFER $RBUFFER and $CURSOR in a zle widget?

You need to override the "compadd" builtin.  Have a look at the example
_expand_word_and_keep function in Functions/Zle/keeper.


Which, I've just noticed, unnecessarily uses both the "function" keyword
and the "name()" syntax; only one or the other is necessary.  Also the
"always" block in _expand_word_and_keep really should cover the entire
definition of the compadd function.  So many nits to be picked ...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to capture a list of completions from a zle widget
  2013-10-27 18:16 How to capture a list of completions from a zle widget Thiago Padilha
  2013-10-27 20:43 ` Bart Schaefer
@ 2013-10-27 20:44 ` Valodim Skywalker
  2013-10-27 21:06   ` Bart Schaefer
  1 sibling, 1 reply; 5+ messages in thread
From: Valodim Skywalker @ 2013-10-27 20:44 UTC (permalink / raw)
  To: Thiago Padilha; +Cc: zsh-users

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

The only method known to me is by hooking compadd and some black magic:

https://github.com/Valodim/zsh-capture-completion

If it can be done in a less hacky way, I'd be all ears.

 - V


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to capture a list of completions from a zle widget
  2013-10-27 20:44 ` Valodim Skywalker
@ 2013-10-27 21:06   ` Bart Schaefer
  2013-10-28  8:09     ` Thiago Padilha
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2013-10-27 21:06 UTC (permalink / raw)
  To: zsh-users

On Oct 27,  9:44pm, Valodim Skywalker wrote:
} 
} https://github.com/Valodim/zsh-capture-completion
} 
} If it can be done in a less hacky way, I'd be all ears.

The zpty magic that Valodim is doing there is all so that you can run
the capture scripts as standalone programs.  If you're just writing a
widget to run inside ZLE, you don't need all that.

BTW here's a working link to the old Unix Review article that explains
how the "keeper" functions evolve:

http://web.archive.org/web/20050207041146/http://www.unixreview.com/documents/s=9513/ur0501a/ur0501a.htm


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to capture a list of completions from a zle widget
  2013-10-27 21:06   ` Bart Schaefer
@ 2013-10-28  8:09     ` Thiago Padilha
  0 siblings, 0 replies; 5+ messages in thread
From: Thiago Padilha @ 2013-10-28  8:09 UTC (permalink / raw)
  To: zsh-users

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

Ok

I already knew about Valodim's solution, I just wanted to be absolutely
sure there was no other way before going with it.

Thanks


On Sun, Oct 27, 2013 at 6:06 PM, Bart Schaefer <schaefer@brasslantern.com>wrote:

> On Oct 27,  9:44pm, Valodim Skywalker wrote:
> }
> } https://github.com/Valodim/zsh-capture-completion
> }
> } If it can be done in a less hacky way, I'd be all ears.
>
> The zpty magic that Valodim is doing there is all so that you can run
> the capture scripts as standalone programs.  If you're just writing a
> widget to run inside ZLE, you don't need all that.
>
> BTW here's a working link to the old Unix Review article that explains
> how the "keeper" functions evolve:
>
>
> http://web.archive.org/web/20050207041146/http://www.unixreview.com/documents/s=9513/ur0501a/ur0501a.htm
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-28  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-27 18:16 How to capture a list of completions from a zle widget Thiago Padilha
2013-10-27 20:43 ` Bart Schaefer
2013-10-27 20:44 ` Valodim Skywalker
2013-10-27 21:06   ` Bart Schaefer
2013-10-28  8:09     ` Thiago Padilha

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).