From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Callbacks from modules Date: Thu, 26 Nov 2015 17:43:54 +0200 Message-ID: <83si3svk91.fsf@gnu.org> References: Reply-To: Eli Zaretskii 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 1448552720 11960 80.91.229.3 (26 Nov 2015 15:45:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Nov 2015 15:45:20 +0000 (UTC) Cc: emacs-devel@gnu.org To: Ivan Andrus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 26 16:45:07 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 1a1yjI-0002uP-TS for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 16:45:05 +0100 Original-Received: from localhost ([::1]:51838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1yjK-0002TQ-Mz for ged-emacs-devel@m.gmane.org; Thu, 26 Nov 2015 10:45:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1yj4-0002TG-20 for emacs-devel@gnu.org; Thu, 26 Nov 2015 10:44:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1yj0-0007t6-Rb for emacs-devel@gnu.org; Thu, 26 Nov 2015 10:44:49 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:55420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1yj0-0007sP-Jb for emacs-devel@gnu.org; Thu, 26 Nov 2015 10:44:46 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NYF00500I302E00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Thu, 26 Nov 2015 17:44:10 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NYF004IBIDLO380@a-mtaout22.012.net.il>; Thu, 26 Nov 2015 17:44:10 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 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:195290 Archived-At: > From: Ivan Andrus > Date: Wed, 25 Nov 2015 23:08:48 -0700 >=20 > I=E2=80=99ve started writing an Emacs module to access NSSpeechSynt= hesizer on OS X (and=20 > maybe GNUStep though I haven=E2=80=99t tested it there). I=E2=80= =99ve been using the mod-test=20 > module as an example and I have it working reasonably well except t= hat 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 messa= ge=20 > speechSynthesizer:didFinishSpeaking. From there I would like to ru= n 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 s= toring 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 star= t 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?