zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: autoexecuting command after a pause
Date: Sat, 7 Dec 2002 10:49:56 +0000	[thread overview]
Message-ID: <1021207104956.ZM11288@candle.brasslantern.com> (raw)
In-Reply-To: <20021206155016.GA30834@cherry.fruitcom.com>

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   


      reply	other threads:[~2002-12-07 10:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-05 21:40 Eric Smith
2002-12-06 10:26 ` Bart Schaefer
2002-12-06 15:50   ` Eric Smith
2002-12-07 10:49     ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1021207104956.ZM11288@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).