emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make-subprocess


From: Nic Ferrier
Subject: Re: make-subprocess
Date: Fri, 26 Sep 2014 10:38:15 +0100

address@hidden writes:

> Hello,
>
> An Elisp program communicating with a subprocess is typically written
> as:
>
>   (let* ((process-connection-type nil)
>          (process (start-process "cat" nil "cat" "/etc/motd")))
>     (set-process-filter process #'my-filter)
>     (set-process-sentinel process #'my-sentinel)
>     ...)
>
> It is a bit tricky and error prone.  On the other hand, Python and GLib
> provide a simple way to spawn and communicate with subprocess:
>
> http://legacy.python.org/dev/peps/pep-0324/
> https://developer.gnome.org/gio/unstable/GSubprocess.html
>
> So I would like to propose something similar:
>
> * Provide a function 'make-subprocess' similar to 'make-network-process'
>   or 'make-serial-process', which can be used as:
>
>   (make-subprocess :name "cat" :program "cat" :args '("/etc/motd")
>                    :filter #'my-filter :sentinel #'my-sentinel
>                    :coding '(utf-8 . utf-8))
>
> * Rewrite 'start-process' as an Elisp wrapper around 'make-subprocess'.
>
> This also has the following benefits:
>
> * We could collect stderr output naturally.  'make-subprocess' could
>   have a keyword, say :error, to prepare a pipe for stderr when spawning
>   a process.
>
> * Maybe it could share the same code to handle the standard keywords
>   (:coding, :filter, :sentinel, etc.) with 'make-network-process' and
>   'make-serial-process'.
>
> What do people think?  I'm attaching a patch as POC.


I like the idea. I've written several wrappers that do this myself.

What about make-network-process? that could be extended to take the same
sentinel and filter arguments.

I think your function should be called:

  make-sub-process

to fit in with make-network-process.


I'd also like to have a:

  set-default-sentintel

function which would make a particular sentinel the default if one was
not specified. Maybe make-sub-process and make-network-process could
have a default-sentinel variable that they consulted if a sentinel was
not specified?


Nic



reply via email to

[Prev in Thread] Current Thread [Next in Thread]