From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Callbacks from modules Date: Thu, 26 Nov 2015 18:16:13 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bb04dc481a2e905257592fd X-Trace: ger.gmane.org 1448561809 30114 80.91.229.3 (26 Nov 2015 18:16:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Nov 2015 18:16:49 +0000 (UTC) Cc: Eli Zaretskii , Daniel Colascione To: Ivan Andrus , Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 26 19:16:32 2015 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 1a215p-0002jP-2E for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 19:16:29 +0100 Original-Received: from localhost ([::1]:52699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a215r-0005pJ-7q for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 13:16:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a215n-0005nK-6F for emacs-devel@gnu.org; Thu, 26 Nov 2015 13:16:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a215m-0005DE-1t for emacs-devel@gnu.org; Thu, 26 Nov 2015 13:16:27 -0500 Original-Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:33107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a215k-0005D1-4I; Thu, 26 Nov 2015 13:16:24 -0500 Original-Received: by wmec201 with SMTP id c201so41720659wme.0; Thu, 26 Nov 2015 10:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=Avx7YcaJvQV+r1gTabipCjmrl4pWM7WQDi7KOrnubSA=; b=giMgZNYB5bC5c++CRDlTKAjZbqApBuJArFSaVUFFwxvOilm76BXP49A/wD1lpSKQdS zm8VFw4f/Ky9Hl54y1qtDK9IoBlmVxNpXHJRxIRPncmkCJ7F4TkHh0tsK1OF9BmRyNdt 7cEXGspkdM89FtakrX4qQf4LF4AoZMm01YvPyc6sY1I3omnw24gnjiOHv2pN70qSpboz Z+cqGqLHUlbKbo1UmaNYXp3QVLrESGdq3VWicp45F5KBGK9IijpIzZ7Ql22mUBQGZHfd EPQtp3JSYGp3YnToFJ8ZEYxYwOHiNipM6DHvAmN4L3Y4BOTK0n44PROXJ+p56jY4WUrY zfSw== X-Received: by 10.195.13.135 with SMTP id ey7mr49848478wjd.25.1448561782922; Thu, 26 Nov 2015 10:16:22 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::229 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:195306 Archived-At: --047d7bb04dc481a2e905257592fd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ivan Andrus schrieb am Do., 26. Nov. 2015 um 07:09 Uhr: > I=E2=80=99ve started writing an Emacs module to access NSSpeechSynthesize= r on OS X > (and maybe GNUStep though I haven=E2=80=99t tested it there). I=E2=80=99= ve been using the > mod-test module as an example and I have it working reasonably well excep= t > that I don=E2=80=99t have any idea how to run a callback. > > When the synthesizer is done speaking it sends an Objective-C message > speechSynthesizer:didFinishSpeaking. From there I would like to run an > elisp hook, say `ns-speech-finished-speaking-hook`. How can I do this? = Do > I have to squirrel away a pointer to an emacs_env somehow? I tried naive= ly > storing env from a previous call but, not surprisingly, the pointer is > invalid when I try to use it. > > Yes, that is currently working as designed. Environments are alive only while Emacs calls some module functions. There are two major issues with allowing callbacks at arbitrary times, which need to be discussed and resolved first. The first is that such a facility would change the execution model of Emacs in a quite fundamental way. Right now all user-defined code inside the Emacs process gets run through a path under the control of Emacs, either as a response to an input event, or a timer, or a process filter etc. Adding a facility to run module code from arbitrary callbacks would remove this invariant, which can have global effects on Emacs. With the current design modules are a pretty localized feature: almost no other part of Emacs has to know about their existence. If we allow callbacks at arbitrary times all parts of Emacs would suddenly have to be prepared for this, and after decades of development there might well be hidden assumptions that such things cannot happen. Therefore I'd be very cautious before introducing such a facility. The second issue is how such a facility should be made available. Currently all communication between modules and Emacs happens through modules, and there is no facility how modules can request creation of an environment. However, it makes little sense to discuss this issue until the first one is resolved. --047d7bb04dc481a2e905257592fd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


I=E2=80=99ve started writing an Emacs module to access = NSSpeechSynthesizer on OS X (and maybe GNUStep though I haven=E2=80=99t tes= ted it there).=C2=A0 I=E2=80=99ve been using the mod-test module as an exam= ple and I have it working reasonably well except that I don=E2=80=99t have = any idea how to run a callback.

When the synthesizer is done speaking it sends an Objective-C message speec= hSynthesizer:didFinishSpeaking.=C2=A0 From there I would like to run an eli= sp hook, say `ns-speech-finished-speaking-hook`.=C2=A0 How can I do this?= =C2=A0 Do I have to squirrel away a pointer to an emacs_env somehow?=C2=A0 = I tried naively storing env from a previous call but, not surprisingly, the= pointer is invalid when I try to use it.


Yes, that is currently working as desi= gned. Environments are alive only while Emacs calls some module functions.<= /div>

There are two major issues with allowing callbacks= at arbitrary times, which need to be discussed and resolved first. The fir= st is that such a facility would change the execution model of Emacs in a q= uite fundamental way. Right now all user-defined code inside the Emacs proc= ess gets run through a path under the control of Emacs, either as a respons= e to an input event, or a timer, or a process filter etc. Adding a facility= to run module code from arbitrary callbacks would remove this invariant, w= hich can have global effects on Emacs. With the current design modules are = a pretty localized feature: almost no other part of Emacs has to know about= their existence. If we allow callbacks at arbitrary times all parts of Ema= cs would suddenly have to be prepared for this, and after decades of develo= pment there might well be hidden assumptions that such things cannot happen= . Therefore I'd be very cautious before introducing such a facility.

The second issue is how such a facility should be ma= de available. Currently all communication between modules and Emacs happens= through modules, and there is no facility how modules can request creation= of an environment. However, it makes little sense to discuss this issue un= til the first one is resolved.
--047d7bb04dc481a2e905257592fd--