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

Re: Proposed _history completer



Felix Rosencrantz wrote:

> Here is a first attempt at proposing a completer that completes words in
> history.  This is the start of a replacement for the example in the compctl
> manual that searches history if filenames don't match in the default
> completion (compctl -D -f + -H 0 '').
> 
> This is a pruned down version of the _history_complete_word widget so
> that it would behave as a completer function and not as a stand alone
> widget.  Some of the behavior provided by the _history_complete_word
> widget is lost, but the ability to include it as a completer should be
> useful.  It might be useful to use with the predict widgets.

I think (or at least hope) I suggested this when Adam added _h_c_w.

> One benefit is that it is now possible to use the default styles that all the
> completers use.  For example, matcher-list can be used with _history.
> 
> Future changes to this widget might include the ability to limit how much
> of history is used for completion, like the old compctl -H flag. 

_first contains a bit of code for something like this...

> I think there is a lot of potential to be found in limiting history words to
> similar contexts;  only history lines where the current command is used,
> or previous values for the current option. 

Sounds good.

>  To do this might require
> some changes to the zsh/parameter module to make this efficient.

Hm, I can't see how this could be done, yet. Have you tried how
slow/fast it is?

> It might be useful to use history as a way to filter completions from other
> completers.  To first use completions that are already found in history.
> Or the opposite, to eliminate choices that are found in the history.

Hm, the latter sounds more useful. That could probably be done with
some trickery with _comp_ignore, which is set in _description, but the
history stuff probably shouldn't go there. Maybe another completer
that sets some array and a change to _description to include
that. Might make things pretty slow, but there may be potential for
optimisation... probably an option to compadd like -F but that gives
strings (not patterns) to exclude. Or maybe just make -F use strings
without wildcards directly in a strcmp().


Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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