Hello!
I'm writing a plug-in for Geany using geanylua which wraps a handful of calls to some of our internal utilities with varying arguments. For example, if one option is selected on the dialog prompt then I might invoke "foo --abc", though another option would invoke "foo --xyz". I'd like to wrap the invocation in a coroutine since foo may take several minutes to complete and I don't want Geany to appear as if it's hung. Unfortunately, may code isn't working as I would expect.
My Lua code that performs the actual invocation is:
-- execute cmd with dir as it's working directory function myExec (cmd, dir) local old = geany.wkdir() local c = coroutine.create( function () geany.wkdir(dir) os.execute(cmd) geany.wkdir(old) geany.message("Action completed.") end ) coroutine.resume(c) end
I'm not a Lua guru by any stretch of the imagination... so there may be something wrong with my understanding of coroutines in Lua. Or, is this an implementation issue in geanylua?
Any suggestions that can get me pointed in the right direction are welcome... I'd prefer not to have write the plug-in in C++ if I can avoid it! :)
-Tim
On Thu, 11 Feb 2010 12:21:14 -0500 Timothy Boronczyk tboronczyk@gmail.com wrote:
I'm not a Lua guru by any stretch of the imagination... so there may be something wrong with my understanding of coroutines in Lua. Or, is this an implementation issue in geanylua?
So what happens when you run the code?
I think any failure is probably a limitation of geanylua. I haven't checked for sure, but maybe geanylua terminates your script when it thinks it is finished, even though there is work being done in a spawned thread.
Regards, Nick
On Thu, Feb 11, 2010 at 11:21 AM, Timothy Boronczyk wrote:
"foo --abc", though another option would invoke "foo --xyz".
foo may take several minutes to complete and I don't want Geany to appear as if it's hung.
You might try one of these:
1. os.execute("start foo --abc") -- Windows 2. os.execute("foo --abc &") -- Linux etc. 3. geany.launch( "foo" , "--abc") -- cross-platform (see docs)
Notifying the user about process completion/success/failure would be the responsibility of the the external program itself.
- Jeff