zsh-users
 help / color / mirror / code / Atom feed
* autoexecuting command after a pause
@ 2002-12-05 21:40 Eric Smith
  2002-12-06 10:26 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2002-12-05 21:40 UTC (permalink / raw)
  To: zsh-users

What is a way to have certain|all commands
automatically execute on the command line after a
pause of n milliseconds?


-- 
Eric Smith


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

* Re: autoexecuting command after a pause
  2002-12-05 21:40 autoexecuting command after a pause Eric Smith
@ 2002-12-06 10:26 ` Bart Schaefer
  2002-12-06 15:50   ` Eric Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2002-12-06 10:26 UTC (permalink / raw)
  To: zsh-users

On Dec 5, 10:40pm, Eric Smith wrote:
}
} What is a way to have certain|all commands
} automatically execute on the command line after a
} pause of n milliseconds?

A "pause" following what other event?

It would be helpful if you gave an example of what you want to accomplish.


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

* Re: autoexecuting command after a pause
  2002-12-06 10:26 ` Bart Schaefer
@ 2002-12-06 15:50   ` Eric Smith
  2002-12-07 10:49     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2002-12-06 15:50 UTC (permalink / raw)
  To: zsh-users

> A "pause" following what other event?
> 
> It would be helpful if you gave an example of what you want to accomplish.

Thanks Bart.

Ok, let me give the simplest case ...
Like why press <enter> all the time? Maybe I set up some
(say) preexec() function for a certain shell to automatically
accept any types string on the command line if there has been
a pause of n milliseconds.
This is not for normal use but ad hoc.

Make sense?

-- 
Eric Smith


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

* Re: autoexecuting command after a pause
  2002-12-06 15:50   ` Eric Smith
@ 2002-12-07 10:49     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2002-12-07 10:49 UTC (permalink / raw)
  To: zsh-users

On Dec 6,  4:50pm, Eric Smith wrote:
} 
} Like why press <enter> all the time? Maybe I set up some
} (say) preexec() function for a certain shell to automatically
} accept any types string on the command line if there has been
} a pause of n milliseconds.
} This is not for normal use but ad hoc.
} 
} Make sense?

Partly.

By "there has been a pause of ..." you mean "something was typed at the
prompt, but then the typing stopped and it was left unchanged for ...".

What doesn't make sense to me is "not for normal use but ad hoc."  If it
isn't for normal use, what turns it on and off?  And if you have to turn
it on and off, how is that different from pressing enter?

Putting that aside --

The way one would normally do this sort of thing is by setting the TMOUT
parameter and installing a trap for the ALARM signal.  However, that has
only full second granularity, and you can't execute zle widgets from the
trap unless it triggers while you're already in a zle widget, which by
definition can't happen for TMOUT.  (The trap must use `zle accept-line'
to execute the contents of the editor buffer.)

So I think you'd need to get zsh 4.1.0-dev-6 and use `zle -F' to install
an alternate input handler, and then arrange (possibly by some external
process) to write a byte on the handled descriptor.  That wakes up zle
and executes the handler in the appropriate context for calling widgets.

I'm not interested enough to attempt to code it for you, but if you want
to take a stab at it I'll be happy to critique it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2002-12-07 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-05 21:40 autoexecuting command after a pause Eric Smith
2002-12-06 10:26 ` Bart Schaefer
2002-12-06 15:50   ` Eric Smith
2002-12-07 10:49     ` 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).