[Geany] coroutines under geanylua

Timothy Boronczyk tboronczyk at xxxxx
Thu Feb 11 17:21:14 UTC 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/users/attachments/20100211/4b42ab8b/attachment.html>


More information about the Users mailing list