all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Christopher Monsanto <chris@monsan.to>
Cc: emacs-devel@gnu.org
Subject: Re: replacing process sentinels and filters with hooks
Date: Mon, 01 Oct 2012 11:34:11 -0400	[thread overview]
Message-ID: <jwvfw5y5ilp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAC5n7TEBD=MSjGhTByr+Xk9g-MCLmyzU2edwWa7REehJQEbPmw@mail.gmail.com> (Christopher Monsanto's message of "Mon, 1 Oct 2012 09:14:12 -0400")

> 1) Process filters and sentinels do not fit in with the rest of the
> Emacs API. In every other API that I can think of that involves a user
> callback, the hooks API is used.

Hooks are used normally for un-planned interaction between two
unrelated packages.  OTOH process sentinels and filters are typically
tightly linked to their process, the package that creates the process
being usually the same that provides the sentinels and filters.

> 2) A process sentinel must parse text to figure out how the process
> changed.

Yes, that's ugly (and it only affects sentinels).

> 3) It's hard for more than one interested party to interact with a process.

Indeed, tho it's rarely needed.  Concrete examples would be useful for
this discussion.

> My proposed change is to add a new function, (process-hook-list
> <proc>), which returns a list of hooks.  Each hook takes one argument,
> which has one of the following forms:

A hook is a symbol/variable which can hold a list of functions.
I'd rather call it `process-callbacks'.

> '(input <string>)

Just <string> would work as well.

So your proposal can be decomposed in 3 parts:
- merge sentinels and filters.
- provide a standard way to combine sentinels and filters, which is to
  run them in sequence (for sentinels, it might be a fine default, but
  for filters, it might be more useful for each filter to be able to
  affect the <string> passed to the next filter).
- change the particular representation of state passed to process sentinels.

I agree the third part is a good change (tho not terribly important).
I'm not sure the first is useful since in my experience sentinels and
filters do different things anyway.

As for the second, maybe a better path is to try and provide generic
`add-function' and `remove-function' that can operate on any
generalized-variable that holds a function.  So you could do

  (add-function (process-filter proc) #'toto)

which would set proc's filter to a new function that runs the old
function (if any) and runs toto as well.   And then `remove-function'
would reset the sentinel to its original value.

> signals through (run-hooks (process-hook-list ..))

run-hooks takes symbols as arguments.


        Stefan



  parent reply	other threads:[~2012-10-01 15:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-01 13:14 replacing process sentinels and filters with hooks Christopher Monsanto
2012-10-01 14:42 ` Paul Eggert
2012-10-01 15:20   ` Christopher Monsanto
2012-10-01 15:34 ` Stefan Monnier [this message]
     [not found]   ` <CAC5n7TGfMktPFOwpSqeqC6pF9rtpx14_fQaouEVnWmma2SfzdA@mail.gmail.com>
2012-10-01 16:53     ` Christopher Monsanto
     [not found]     ` <jwvboglmxm8.fsf-monnier+emacs@gnu.org>
2012-10-03 10:59       ` Christopher Monsanto
2012-10-03 13:37         ` Stefan Monnier
2012-11-13 17:58           ` Stefan Monnier
2012-10-03 14:39         ` Stephen J. Turnbull

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=jwvfw5y5ilp.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=chris@monsan.to \
    --cc=emacs-devel@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.