I noticed that Vim currently uses the stock implementation of Lua's
debug.debug() function in if_lua.c, which will cause Vim to seemingly
hang if called. I've written and attached a new implementation for
debug.debug() that will make it more usable in Vim if Lua scripters
want to make use of it.
Thanks,
Rob Hoelz
Hi Rob
Thanks for the patch. I just checked ":help todo.txt" in Vim-7.3.315
and it includes a comment about your patch:
==== [ :help todo.txt ] ====
Patch for Lua debug(). (Rob Hoelz, 2011 Sep 12).
====
It's also near the top of the TODO list so chances are it will
be included soon.
Regards
-- Dominique
> It's been a week since I posted this patch, and I haven't seen any
> response. If you guys don't want to incorporate my patch into Vim,
> that's ok; I'd just like to know if I need to fix anything up, or if
> it needs to get vetted or something.
Sorry for the delay in checking your patch. Can you please check if this
luaV_debug works instead of your luaV_debug_debug? It's simpler and more in
line with Lua's original debug.debug:
static int
luaV_debug (lua_State *L)
{
lua_settop(L, 0);
lua_getglobal(L, "vim");
lua_getfield(L, -1, "eval");
lua_remove(L, -2); /* vim.eval at position 1 */
for (;;)
{
const char *input;
size_t l;
lua_pushvalue(L, 1); /* vim.eval */
lua_pushliteral(L, "input('lua_debug> ')");
lua_call(L, 1, 1, 0); /* return string */
input = lua_tolstring(L, -1, &l);
if (l == 0 || strcmp(input, "cont") == 0)
return 0;
if (luaL_loadbuffer(L, input, l, "=(debug command)") ||
lua_pcall(L, 0, 0, 0))
luaV_emsg(L);
lua_settop(L, 1); /* remove eventual returns, but keep vim.eval */
}
}
If it works, can you please also product a patch?
Cheers,
Luis
--
Computers are useless. They can only give you answers.
-- Pablo Picasso
--
Luis Carvalho (Kozure)
lua -e 'print((("lexca...@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'
> Thanks for your improvement to my patch; it works fine, except the
> output from each command appears on the same line as the input. The
> following patch is based on yours,
> but includes a fix for the same line behavior.
Ok, great. We still need to define lua_remove for the dynamic version of the
interpreter, so I'm updating the patch. I've also added a comment to
msg_putchar and moved the function definition closer to luaV_print.
Thanks,
Luis
--
Computers are useless. They can only give you answers.
-- Pablo Picasso
--
Luis Carvalho (Kozure)
lua -e 'print((("lexca...@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'