emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Callbacks from modules


From: joakim
Subject: Re: Callbacks from modules
Date: Thu, 26 Nov 2015 17:17:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Ivan Andrus <address@hidden>
>> Date: Wed, 25 Nov 2015 23:08:48 -0700
>> 
>> I’ve started writing an Emacs module to access NSSpeechSynthesizer on OS X 
>> (and 
>> maybe GNUStep though I haven’t tested it there).  I’ve been using the 
>> mod-test 
>> module as an example and I have it working reasonably well except that I 
>> don’t 
>> 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 naively storing 
>> env 
>> from a previous call but, not surprisingly, the pointer is invalid when I 
>> try 
>> 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?

-- 
Joakim Verona



reply via email to

[Prev in Thread] Current Thread [Next in Thread]