From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: replacing process sentinels and filters with hooks Date: Mon, 01 Oct 2012 11:34:11 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1349105685 3270 80.91.229.3 (1 Oct 2012 15:34:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2012 15:34:45 +0000 (UTC) Cc: emacs-devel@gnu.org To: Christopher Monsanto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 01 17:34:49 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TIi0z-00062z-2C for ged-emacs-devel@m.gmane.org; Mon, 01 Oct 2012 17:34:37 +0200 Original-Received: from localhost ([::1]:43651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIi0t-0005A5-II for ged-emacs-devel@m.gmane.org; Mon, 01 Oct 2012 11:34:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIi0m-0004z2-5K for emacs-devel@gnu.org; Mon, 01 Oct 2012 11:34:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIi0a-0004Ah-Rp for emacs-devel@gnu.org; Mon, 01 Oct 2012 11:34:24 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:47622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIi0a-00049m-Nk for emacs-devel@gnu.org; Mon, 01 Oct 2012 11:34:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu09FxLT4/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLDiYSFBgNJIgcBboJkEQDozOBWIMF X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="200385117" Original-Received: from 69-196-180-248.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.196.180.248]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 01 Oct 2012 11:34:11 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 6E910AE1FB; Mon, 1 Oct 2012 11:34:11 -0400 (EDT) In-Reply-To: (Christopher Monsanto's message of "Mon, 1 Oct 2012 09:14:12 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153846 Archived-At: > 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 > ), 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 ) Just 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 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