From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: Callbacks from modules Date: Thu, 26 Nov 2015 17:17:40 +0100 Message-ID: References: <83si3svk91.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1448554712 12968 80.91.229.3 (26 Nov 2015 16:18:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Nov 2015 16:18:32 +0000 (UTC) Cc: Ivan Andrus , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 26 17:18:19 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 1a1zFQ-0006FK-6Y for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 17:18:16 +0100 Original-Received: from localhost ([::1]:52048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1zFS-0004mn-BV for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 11:18:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1zFE-0004k9-Gg for emacs-devel@gnu.org; Thu, 26 Nov 2015 11:18:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1zFD-0008RQ-H1 for emacs-devel@gnu.org; Thu, 26 Nov 2015 11:18:04 -0500 Original-Received: from mx1.bahnhof.se ([213.80.101.11]:60079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1zF8-0008QX-T1; Thu, 26 Nov 2015 11:17:59 -0500 Original-Received: from localhost (mf.bahnhof.se [213.80.101.20]) by mx1-reinject (Postfix) with ESMTP id BD14645B1F; Thu, 26 Nov 2015 17:17:56 +0100 (CET) X-Virus-Scanned: by amavisd-new using ClamAV at bahnhof.se (MF1) Original-Received: from mf1.bahnhof.se ([127.0.0.1]) by localhost (mf1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cchymha1z+dD; Thu, 26 Nov 2015 17:17:51 +0100 (CET) Original-Received: from mta.verona.se (h-235-62.a149.priv.bahnhof.se [85.24.235.62]) by mf1.bahnhof.se (Postfix) with ESMTP id 26310330B03; Thu, 26 Nov 2015 17:17:50 +0100 (CET) Original-Received: from localhost (unknown [127.0.0.1]) by mta.verona.se (Postfix) with ESMTP id BD39D4E4BB8; Thu, 26 Nov 2015 16:17:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at verona.se Original-Received: from mta.verona.se ([127.0.0.1]) by localhost (exodia.verona.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id osh1Vo3_cg8f; Thu, 26 Nov 2015 17:17:40 +0100 (CET) Original-Received: from exodia.verona.se (www.verona.se [192.168.200.15]) by mta.verona.se (Postfix) with ESMTP id BF3A84E4232; Thu, 26 Nov 2015 17:17:40 +0100 (CET) In-Reply-To: <83si3svk91.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 26 Nov 2015 17:43:54 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.11 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:195294 Archived-At: Eli Zaretskii writes: >> From: Ivan Andrus >> Date: Wed, 25 Nov 2015 23:08:48 -0700 >>=20 >> I=E2=80=99ve started writing an Emacs module to access NSSpeechSynthesiz= er on OS X (and=20 >> maybe GNUStep though I haven=E2=80=99t tested it there). I=E2=80=99ve b= een using the mod-test=20 >> module as an example and I have it working reasonably well except that I= don=E2=80=99t=20 >> have any idea how to run a callback. >>=20 >> When the synthesizer is done speaking it sends an Objective-C message=20 >> speechSynthesizer:didFinishSpeaking. From there I would like to run an = elisp=20 >> hook, say `ns-speech-finished-speaking-hook`. How can I do this? Do I = have to=20 >> squirrel away a pointer to an emacs_env somehow? I tried naively storin= g env=20 >> from a previous call but, not surprisingly, the pointer is invalid when = I try=20 >> to use it. > > How would you do that in Emacs's core code? A module is just a > (limited) extension of the Emacs core, so when you ask such questions, > you should first think how Emacs core does that. > > Anyway, I assume you have a C callback in your module that is > triggered by the speechSynthesizer:didFinishSpeaking message, is that > right? Then one way would be to have that callback set a flag, > provide a Lisp-callable function that returns the flag, and then start > a timer that will test the flag and call your Lisp callback when the > flag is set. > > Another, perhaps simpler, possibility would be to have the module > provide a Lisp-callable function that will register a Lisp callback. > Then your C callback will simply call that Lisp function. > > Would any of these do the job? > > For the xwidget code I used events. Wouldn't that work here as well? --=20 Joakim Verona