zsh-workers
 help / color / mirror / code / Atom feed
* Trial patch for showing completion in progress
@ 2004-09-09 11:13 Peter Stephenson
  2004-09-09 12:40 ` Oliver Kiddle
  2004-09-09 15:30 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-09-09 11:13 UTC (permalink / raw)
  To: Zsh hackers list

I often want to find out what completion is doing when it goes away for
a while.  Here's a simple patch that helps, though I think there's more
that can be done.  No documentation yet.

As defined, you set the show-completer style to true in any context
where you want to show the status.  It is examined when each element of
the completer list is tried.  The message is overwritten by any list
output.

Is there a better place for this?  On the whole I think this point is OK.

Is there a way of doing this only if completion takes a certain time?
E.g. store SECONDS as floating point and examine it at certain key
points?

Is there a way of removing the zle -M output if the completion produced
no output?

Index: Completion/Base/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_main_complete,v
retrieving revision 1.9
diff -u -r1.9 _main_complete
--- Completion/Base/Core/_main_complete	2 Mar 2004 12:52:06 -0000	1.9
+++ Completion/Base/Core/_main_complete	9 Sep 2004 11:10:50 -0000
@@ -135,7 +135,10 @@
   else
     _completer="${tmp[2,-1]//_/-}"
   fi
+
   curcontext="${curcontext/:[^:]#:/:${_completer}:}"
+  zstyle -t ":completion:${curcontext}:" show-completer &&
+    zle -M "Trying completion for :completion:${curcontext}"
 
   zstyle -a ":completion:${curcontext}:" matcher-list _matchers ||
       _matchers=( '' )

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Trial patch for showing completion in progress
  2004-09-09 11:13 Trial patch for showing completion in progress Peter Stephenson
@ 2004-09-09 12:40 ` Oliver Kiddle
  2004-09-09 12:51   ` Peter Stephenson
  2004-09-09 15:30 ` Bart Schaefer
  1 sibling, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2004-09-09 12:40 UTC (permalink / raw)
  To: Zsh hackers list

Peter wrote:
> I often want to find out what completion is doing when it goes away for
> a while.  Here's a simple patch that helps, though I think there's more
> that can be done.  No documentation yet.

In most cases, if it takes a while it is filename completion trying to
look for files in the full path: the stuff which allows /u/l/b to
complete to /usr/local/bin.

> As defined, you set the show-completer style to true in any context
> where you want to show the status.  It is examined when each element of
> the completer list is tried.  The message is overwritten by any list
> output.
> 
> Is there a better place for this?  On the whole I think this point is OK.

It depends what you are trying to do. Are you trying to show the
completers or the zstyle context? _main_complete is not the only place
the context is changed so for showing the context, _description or
_setup would be a better place.

> Is there a way of doing this only if completion takes a certain time?
> E.g. store SECONDS as floating point and examine it at certain key
> points?

Why not just stick $SECONDS (as floating point) in PS4 and use
_complete_debug.

I'm not convinced we should be sticking debug stuff like this into
completion unless it really is proven to be useful. I normally prefer to
use a second tty for completion debug output instead of zle. And it
isn't hard to make temporary changes to _main_complete (or whatever) for
debugging.

> Is there a way of removing the zle -M output if the completion produced
> no output?

Either you have to replace compadd with a function or, depending on
where you produce the debug, you might be able to check
compstate[nmatches].

Oliver


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

* Re: Trial patch for showing completion in progress
  2004-09-09 12:40 ` Oliver Kiddle
@ 2004-09-09 12:51   ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-09-09 12:51 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> > Is there a better place for this?  On the whole I think this point is OK.
> 
> It depends what you are trying to do. Are you trying to show the
> completers or the zstyle context? _main_complete is not the only place
> the context is changed so for showing the context, _description or
> _setup would be a better place.

No, it's just a gross indication of what process is happening.

> Why not just stick $SECONDS (as floating point) in PS4 and use
> _complete_debug.

That's a completely different thing requiring hours of sifting
information.  With this you can find out what you want to know as you're
actually using it.

> I'm not convinced we should be sticking debug stuff like this into
> completion unless it really is proven to be useful.

I don't want to debug it, I want to see what it's doing without lots of
extra work.  Progress information is a perfectly normal thing to have in
a system.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Trial patch for showing completion in progress
  2004-09-09 11:13 Trial patch for showing completion in progress Peter Stephenson
  2004-09-09 12:40 ` Oliver Kiddle
@ 2004-09-09 15:30 ` Bart Schaefer
  2004-09-09 15:40   ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2004-09-09 15:30 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 9 Sep 2004, Peter Stephenson wrote:

> Is there a better place for this?  On the whole I think this point is OK.

How about this?

    zstyle () {
        [[ $3 = matcher-list ]] && {
            zle -R "Trying completion for $2"
            sleep 1
        }
        builtin zstyle "$@"
    }

> Is there a way of doing this only if completion takes a certain time?

I don't think there's a sifficiently low-level loop that's common to all
completions.  You could try hooking into _wanted or _tags, I suppose.

> Is there a way of removing the zle -M output if the completion produced
> no output?

Using zle -R instead of -M takes care of that.  Is there some other bad
side-effect of -R?


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

* Re: Trial patch for showing completion in progress
  2004-09-09 15:30 ` Bart Schaefer
@ 2004-09-09 15:40   ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-09-09 15:40 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:
> How about this?
> 
>     zstyle () {
>         [[ $3 = matcher-list ]] && {
>             zle -R "Trying completion for $2"
>             sleep 1
>         }
>         builtin zstyle "$@"
>     }

Nasty but interesting.  The `sleep 1' misses the point, however, which
is that you see what it's doing in real time.  If it's fast enough that
the message doesn't appear, you don't care.

> > Is there a way of removing the zle -M output if the completion produced
> > no output?
> 
> Using zle -R instead of -M takes care of that.  Is there some other bad
> side-effect of -R?

That would be fine.  I was thinking it shouldn't be connected with a
redisplay, but of course it has to be in any case.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

end of thread, other threads:[~2004-09-09 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-09 11:13 Trial patch for showing completion in progress Peter Stephenson
2004-09-09 12:40 ` Oliver Kiddle
2004-09-09 12:51   ` Peter Stephenson
2004-09-09 15:30 ` Bart Schaefer
2004-09-09 15:40   ` Peter Stephenson

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