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

Re: Completing strings from history?



John Cooper (john.cooper@xxxxxxxxxxxxx) wrote:
> Peter Stephenson <pws@xxxxxxx> writes:
>  > > Typing `foo<ESC-/>' (bound to _history-complete-older) finds the most recent
>  > > word in the history beginning "foo".  Typing <ESC-/> again appears to do
>  > > nothing.
>  > > 
>  > > Is it possible to set things up so that repeatedly typing <ESC-/> cycles back
>  > > through all matches in the history?  (ala Emacs' dabbrev-expand)
>  > 
>  > You can do this by setting the `stop' style, which is so called because it
>  > stops when it has reached as far back into the history as it can (unlike
>  > normal menu completion which would continue cycling).
>  > 
>  >   zstyle ':completion:history-words:*' stop 1

Actually the intention was that repeatedly typing <ESC-/> always
cycled back, and that the stop style would stop cycling when it hit
the end-stops.  In other words, the default behaviour I intended when
I wrote it was the behaviour you want, but unfortunately it seems to
be broken.

> With the above zstyle, I find that hitting <ESC-/> after having reached the
> oldest history item prohibits <ESC-,> from taking my forwards again, and
> similarly, hitting <ESC-,> after cycling forwards to the most recent item
> prohibits <ESC-/> from taking me backwards again.

This is also a bug, I think.

> Two more questions:
> 
> 1. Is it possible to turn off the beep that's emitted every time I
>    type <ESC-/>?

This is maybe also a bug.  Argh!  It doesn't happen for me, presumably
because of one of the other zstyles I have set.  Not sure which
though.

> 2. Can all matching words be displayed as per normal completions
>    (then I'd see whether it's worth continuing to bang on <ESC-/> a
>    few more times)?

The `list' style controls that.

I think the reason this is all such a mess is because there's no
internal mechanism for controlling the behaviour of automenu when it
reaches the start or end of the match list, so it had to be
reimplemented in the shell function.  Ideally the `stop' style would
be implemented in the core of the completion code to control this, and
which would greatly simplify the current nastiness that is
_history_complete_word.  It would also leave the core engine in charge
of deciding when to generate the match list, rather than the current
_history_complete_word_gen_matches.

We could also then move the verbosity control from the `stop' style
(which can currently be `true' or `verbose') into the `verbosity'
style, which would make much more sense.

Sven? ;-)

Incidentally, the `Completion System Configuration' section in the
info pages is enormous; how about splitting it up into smaller chunks?
That way the xrefs from the `Style and Tag Index' would be much more
helpful, as they would land you directly on (or at least, a lot closer
to) the text concerning the style or tag you are looking up.  Or can
the info format do something equivalent to <a name="..."> ?

Sorry, this is getting a bit -worker-ish again...



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