all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nic Ferrier <nferrier@ferrier.me.uk>
To: ueno@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: make-subprocess
Date: Fri, 26 Sep 2014 10:38:15 +0100	[thread overview]
Message-ID: <87a95md8mw.fsf@ferrier.me.uk> (raw)
In-Reply-To: <m3h9zupwg7.fsf-ueno@gnu.org> (ueno@gnu.org's message of "Fri, 26 Sep 2014 18:23:04 +0900")

ueno@gnu.org 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	other threads:[~2014-09-26  9:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26  9:23 make-subprocess Daiki Ueno
2014-09-26  9:38 ` Nic Ferrier [this message]
2014-09-26 12:42   ` make-subprocess Stefan Monnier

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=87a95md8mw.fsf@ferrier.me.uk \
    --to=nferrier@ferrier.me.uk \
    --cc=emacs-devel@gnu.org \
    --cc=ueno@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.