zsh-workers
 help / color / mirror / code / Atom feed
* When you know completion will be slow ...
@ 2014-02-06 16:04 Bart Schaefer
  2014-02-07 12:21 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2014-02-06 16:04 UTC (permalink / raw)
  To: zsh-workers

Completion functions that are going to perform potentially slow operations
(e.g., "git ls-files" is unpredictable on large repos, or the example from
recently on zsh-users of "system_profiler -listDataTypes") could warn the
user that there will be a delay.

The "zle -M" command works from inside a completion widget, and will erase
the completion listing (which is then redrawn), so it could be used to
display a message just before the long operation begins.  Unfortunately it
is not "safe to call" in the way that "zle -R" is, so may need to test that
zle is active with "zle && zle -M ..." ("zle -R" also works, but covers up
the first line of the completion listing which is then never redrawn).

This seems to interoperate safely with menu-selection as well.  If this is
deemed a good idea, we might want to document a standard zstyle name for it
so it can be turned on/off for properly written completion functions.


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

* Re: When you know completion will be slow ...
  2014-02-06 16:04 When you know completion will be slow Bart Schaefer
@ 2014-02-07 12:21 ` Peter Stephenson
  2014-02-07 16:14   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2014-02-07 12:21 UTC (permalink / raw)
  To: zsh-workers

On Thu, 06 Feb 2014 08:04:43 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Completion functions that are going to perform potentially slow operations
> (e.g., "git ls-files" is unpredictable on large repos, or the example from
> recently on zsh-users of "system_profiler -listDataTypes") could warn the
> user that there will be a delay.
> 
> The "zle -M" command works from inside a completion widget, and will erase
> the completion listing (which is then redrawn), so it could be used to
> display a message just before the long operation begins.

Do you know about the show-completer style?  It's not quite the same
thing but by the same token that means you get information even if you
don't know in advance completion's going to be slow.  I added this ages
ago and have been using it without any problem ever since (I don't even
notice the message unless somethings taking a long time and had to
confirm by trial that it was really appearing).

pws


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

* Re: When you know completion will be slow ...
  2014-02-07 12:21 ` Peter Stephenson
@ 2014-02-07 16:14   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2014-02-07 16:14 UTC (permalink / raw)
  To: zsh-workers

On Feb 7, 12:21pm, Peter Stephenson wrote:
} Subject: Re: When you know completion will be slow ...
}
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > The "zle -M" command works from inside a completion widget, and will erase
} > the completion listing (which is then redrawn), so it could be used to
} > display a message just before the long operation begins.
} 
} Do you know about the show-completer style?  It's not quite the same
} thing but by the same token that means you get information even if you
} don't know in advance completion's going to be slow.

I had forgotten about it, having played with it for a while way back when
you first added it and then left it alone.

I just tried it again and I find the context it displays is not specific
enough, but you're right that it does at least tell you that something is
happening.

However, using "zle -R" gives me bad behavior.  Starting from Src/zsh -f:

------------
torch% autoload -U compinit; compinit -D
torch% _deliberately_slow() { sleep 5; return 1; }
torch% zstyle ':completion:*' completer _deliberately_slow _complete
torch% zstyle ':completion:*' show-completer yes
torch% ls 
Trying completion for :completion::deliberately-slow::
------------

Becomes

------------
torch% ls
Config/               config.modules.sh     Makefile
config.h              config.status*        Src/
config.log            Doc/                  stamp-h
config.modules        Etc/                  Test/
config.modules.local  foo/
------------

and if I then press TAB again I get

------------
torch% ls
Trying completion for :completion::deliberately-slow::
config.h              config.status*        Src/
config.log            Doc/                  stamp-h
config.modules        Etc/                  Test/
config.modules.local  foo/
------------

which then becomes

------------
torch% ls Config/

config.h              config.status*        Src/                
config.log            Doc/                  stamp-h             
config.modules        Etc/                  Test/               
config.modules.local  foo/
------------

Oops, the first line of the completion listing is not redrawn.  This
does not happen with "zle -M".


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

end of thread, other threads:[~2014-02-07 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06 16:04 When you know completion will be slow Bart Schaefer
2014-02-07 12:21 ` Peter Stephenson
2014-02-07 16:14   ` Bart Schaefer

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