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