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

Re: make history-complete-older do nothing on empty string

On Wed, Apr 18, 2018 at 5:58 AM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> So when you interrupted it it was apparently reading in 66742 history
> words

Some people have really large shell history.  Manipulating that many
completion possibilities takes a long time.

Vincent, what version of zsh are you running?  There were some memory
management optimizations done in the past year or so that might speed
up large history accesses in general.

Although it would be nice to find out exactly what part of completion
is occupying time in this case (if only so that we might look into
making it interruptible), to answer the original question:

You'd want a wrapper around _history_complete_word to check the state
of the editor buffer, or you could copy that function to a location at
the front of your $fpath and modify it.  The test you want is probably
something like:

[[ ${LBUFFER:- } == ' ' && ${RBUFFER:- } == ' ' ]] && return 1

There's a space after :- in both of those references.  This means "if
either the buffer is empty or the cursor is sitting in the middle of a
run of spaces, then return" (i.e. don't complete anything).

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