On Sep 19, 11:12 am, Luis Carvalho <[email protected]> wrote:
> Hi Rob,
>
> > 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((("[email protected]"):gsub("(%u+%.)","")))'

Hi Luis,

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.

diff -r 15b934a16641 src/if_lua.c
--- a/src/if_lua.c      Wed Sep 14 19:04:40 2011 +0200
+++ b/src/if_lua.c      Tue Sep 20 13:58:15 2011 -0500
@@ -1069,6 +1069,31 @@
     {NULL, NULL}
 };

+  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); /* return string */
+        msg_putchar('\n');
+        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 */
+    }
+}
+
     static int
 luaopen_vim(lua_State *L)
 {
@@ -1082,6 +1107,11 @@
     /* print */
     lua_pushcfunction(L, luaV_print);
     lua_setglobal(L, "print");
+    /* debug.debug */
+    lua_getglobal(L, "debug");
+    lua_pushcfunction(L, luaV_debug);
+    lua_setfield(L, -2, "debug");
+    lua_pop(L, 1);
     /* free */
     lua_pushlightuserdata(L, (void *) LUAVIM_FREE);
     lua_pushcfunction(L, luaV_free);

Thanks,
Rob

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui