Login  Register

Spawning autonomous shell commands

classic Classic list List threaded Threaded

Spawning autonomous shell commands

Hilary-17
6 posts
This may be partly a windoze question. I use this on a windoze box:

(defun espeak-region ()
   "Send the region to espeak"
   (interactive)
   (shell-command-on-region (region-beginning) (region-end) "espeak -v
mb-en1 -p 50 -s 150 --stdin ")
   )

It works, but it locks up emacs until espeak has finished reading the
text. Is there a way of spawning espeak as an autonomous process which
can finish in its own time?

--
Hilary S

Re: Spawning autonomous shell commands

Eli Zaretskii
43636 posts
> From: Hilary <[hidden email]>
> Date: Thu, 27 Sep 2012 22:00:59 +0100
>
> This may be partly a windoze question. I use this on a windoze box:
>
> (defun espeak-region ()
>    "Send the region to espeak"
>    (interactive)
>    (shell-command-on-region (region-beginning) (region-end) "espeak -v
> mb-en1 -p 50 -s 150 --stdin ")
>    )
>
> It works, but it locks up emacs until espeak has finished reading the
> text. Is there a way of spawning espeak as an autonomous process which
> can finish in its own time?

See 'start-process' and 'process-send-region'.

Re: Spawning autonomous shell commands

Hilary-17
6 posts
In reply to this post by Hilary-17
On 2012-09-28 08:06, Eli Zaretskii wrote:

>> From: Hilary <[hidden email]>
>> Date: Thu, 27 Sep 2012 22:00:59 +0100
>>
>> This may be partly a windoze question. I use this on a windoze box:
>>
>> (defun espeak-region ()
>>     "Send the region to espeak"
>>     (interactive)
>>     (shell-command-on-region (region-beginning) (region-end) "espeak -v
>> mb-en1 -p 50 -s 150 --stdin ")
>>     )
>>
>> It works, but it locks up emacs until espeak has finished reading the
>> text. Is there a way of spawning espeak as an autonomous process which
>> can finish in its own time?
>
> See 'start-process' and 'process-send-region'.

Thanks for the suggestion. It looks as though those aren't implemented
in the windoze port, but async-shell-command is. Presumably it's
possible to make up an async-shell-command-on-region function from the
relevent parts of simple.el.

--
Hilary S

Re: Spawning autonomous shell commands

Eli Zaretskii
43636 posts
> From: Hilary <[hidden email]>
> Date: Fri, 28 Sep 2012 18:49:19 +0100
>
> > See 'start-process' and 'process-send-region'.
>
> Thanks for the suggestion. It looks as though those aren't implemented
> in the windoze port

Of course, they are.  What made you think they aren't?

> but async-shell-command is. Presumably it's possible to make up an
> async-shell-command-on-region function from the relevent parts of
> simple.el.

Yes, that's another way to go.