(patch) Lua interface

49 views
Skip to first unread message

Luis Carvalho

unread,
Sep 1, 2008, 1:13:02 AM9/1/08
to vim...@vim.org
Hi,

I'm attaching a patch that provides a complete Lua [1] interface to Vim in
case anyone finds it useful. The patch is against vim-7.2. Any feedback is
welcome, of course. Disclaimer: this is my first post to the list and this is
my first patch to Vim! :)

Cheers,
Luis.

[1] http://www.lua.org

--
Computers are useless. They can only give you answers.
-- Pablo Picasso

--
Luis Carvalho (Kozure)
lua -e 'print((("lexca...@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'

vim72-lua.patch.gz
signature.asc

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 3:57:08 AM9/1/08
to vim...@googlegroups.com, vim...@vim.org

On Mon, Sep 01, at 01:13 Luis Carvalho wrote:
> Hi,
>
> I'm attaching a patch that provides a complete Lua [1] interface to Vim in
> case anyone finds it useful. The patch is against vim-7.2. Any feedback is
> welcome, of course. Disclaimer: this is my first post to the list and this is
> my first patch to Vim! :)
>

Hi Luis and thanks for the patch. As I am currently evaluating Lua, so I
can invest some more time to learn the language, Lua interface seems a great
addition to vim for me. I am hoping others (Bram) feels the same too.


Below is a minor diff to your patch.


--- vim72-lua.patch 2008-09-01 10:43:13.865134252 +0300
+++ vim72-lua.patch.orig 2008-09-01 10:42:52.905306090 +0300
@@ -338,7 +338,7 @@
+ LUA_INC=
+ if test "X$vi_cv_path_lua_pfx" != "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
-+ if test -f $vi_cv_path_lua_pfx/include/lua.h; then
++ if test -f $vi_cv_path_lua_pfx/include/scheme.h; then
+ AC_MSG_RESULT("yes")
+ else
+ AC_MSG_RESULT("no")


Hoping to see Lua integrated into vim, again thanks.

> Cheers,
> Luis.
>
> [1] http://www.lua.org
>
> --
> Computers are useless. They can only give you answers.
> -- Pablo Picasso
>
> --
> Luis Carvalho (Kozure)
> lua -e 'print((("lexca...@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'

Regards,
Ag.

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 3:57:08 AM9/1/08
to vim...@googlegroups.com, vim...@vim.org

On Mon, Sep 01, at 01:13 Luis Carvalho wrote:
> Hi,
>
> I'm attaching a patch that provides a complete Lua [1] interface to Vim in
> case anyone finds it useful. The patch is against vim-7.2. Any feedback is
> welcome, of course. Disclaimer: this is my first post to the list and this is
> my first patch to Vim! :)
>

Hi Luis and thanks for the patch. As I am currently evaluating Lua, so I


can invest some more time to learn the language, Lua interface seems a great
addition to vim for me. I am hoping others (Bram) feels the same too.


Below is a minor diff to your patch.


--- vim72-lua.patch 2008-09-01 10:43:13.865134252 +0300
+++ vim72-lua.patch.orig 2008-09-01 10:42:52.905306090 +0300
@@ -338,7 +338,7 @@
+ LUA_INC=
+ if test "X$vi_cv_path_lua_pfx" != "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
-+ if test -f $vi_cv_path_lua_pfx/include/lua.h; then
++ if test -f $vi_cv_path_lua_pfx/include/scheme.h; then
+ AC_MSG_RESULT("yes")
+ else
+ AC_MSG_RESULT("no")


Hoping to see Lua integrated into vim, again thanks.

> Cheers,


> Luis.
>
> [1] http://www.lua.org
>
> --
> Computers are useless. They can only give you answers.
> -- Pablo Picasso
>
> --
> Luis Carvalho (Kozure)
> lua -e 'print((("lexca...@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'

Regards,
Ag.

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 4:31:09 AM9/1/08
to vim...@googlegroups.com, vim...@vim.org
On Mon, Sep 01, at 10:57 Ag. D. Hatzimanikas wrote:
>
> Below is a minor diff to your patch.
>

Note to me:
Don't send again patches, when there is an angry wife near your shoulders.

--- vim72-lua.patch.orig 2008-09-01 10:42:52.905306090 +0300
+++ vim72-lua.patch 2008-09-01 10:43:13.865134252 +0300


@@ -338,7 +338,7 @@
+ LUA_INC=
+ if test "X$vi_cv_path_lua_pfx" != "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)

-+ if test -f $vi_cv_path_lua_pfx/include/scheme.h; then
++ if test -f $vi_cv_path_lua_pfx/include/lua.h; then

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 4:31:09 AM9/1/08
to vim...@googlegroups.com, vim...@vim.org
On Mon, Sep 01, at 10:57 Ag. D. Hatzimanikas wrote:
>
> Below is a minor diff to your patch.
>

Note to me:


Don't send again patches, when there is an angry wife near your shoulders.

--- vim72-lua.patch.orig 2008-09-01 10:42:52.905306090 +0300
+++ vim72-lua.patch 2008-09-01 10:43:13.865134252 +0300


@@ -338,7 +338,7 @@
+ LUA_INC=
+ if test "X$vi_cv_path_lua_pfx" != "X"; then
+ AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)

-+ if test -f $vi_cv_path_lua_pfx/include/scheme.h; then
++ if test -f $vi_cv_path_lua_pfx/include/lua.h; then

Bram Moolenaar

unread,
Sep 1, 2008, 4:57:56 AM9/1/08
to Luis Carvalho, vim...@vim.org

Luis Carvalho wrote:

> I'm attaching a patch that provides a complete Lua [1] interface to
> Vim in case anyone finds it useful. The patch is against vim-7.2. Any
> feedback is welcome, of course. Disclaimer: this is my first post to
> the list and this is my first patch to Vim! :)

It looks fairly complete. I hope a few people try it out and provide
feedback.

There was a patch for Lua a couple of years ago by Wolfgang Oertl, but
it appears the download link no longer works. He never finished it
anyway.

--
hundred-and-one symptoms of being an internet addict:
25. You believe nothing looks sexier than a man in boxer shorts illuminated
only by a 17" inch svga monitor.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Luis Carvalho

unread,
Sep 1, 2008, 1:19:02 PM9/1/08
to vim...@googlegroups.com, vim...@vim.org
> > Below is a minor diff to your patch.

Thank you. I'm attaching an updated version of the patch with a few more
changes. I should probably find a place to put the latest version of the patch...

Cheers,
Luis.

vim72-lua.patch.gz
signature.asc

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 3:41:06 PM9/1/08
to vim...@googlegroups.com, vim...@vim.org
On Mon, Sep 01, at 01:19 Luis Carvalho wrote:
> > > Below is a minor diff to your patch.
>
> Thank you. I'm attaching an updated version of the patch with a few more
> changes. I should probably find a place to put the latest version of the patch...
>

Thanks.

I think I've tried all the available commands and they work as they
were documented.

My only question is (from :help lua-vim):

vim.open({fname}) Opens a new buffer for file {fname} and
returns it. Note that the buffer
is not set as current.

And then few lines below:

:lua vim.open"myfile"() -- open buffer and set it as current


They both work as advertised, but why this idiom? Is there any other way
to have the same result, but to be a little bit less confusing?
If there is a reason to stay like this, at least (for me), it looks more
natural exactly the opposite, so:

lua vim.open('somefile')

it should open the file and set is as current.


> Cheers,
> Luis.

Regards,
Ag.

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 4:34:42 PM9/1/08
to vim...@googlegroups.com, vim...@vim.org
On Mon, Sep 01, at 01:19 Luis Carvalho wrote:
> > > Below is a minor diff to your patch.
>
> Thank you. I'm attaching an updated version of the patch with a few more
> changes. I should probably find a place to put the latest version of the patch...
>

By the way,

I added your patch to the vim's wiki page at linuxfromscratch.org

http://wiki.linuxfromscratch.org/blfs/wiki/vim

You can create anytime an account and add the updated patch (if any), until
it will be integrated into mainline (hopefully soon).

You can click on the "attach file" and check then the "Replace existing
attachment of the same name" in the next page. Or if you want to add a
patch with a different name (preferable), click on the existing attachment
to delete it and then add the new one.

Ag. D. Hatzimanikas

unread,
Sep 1, 2008, 4:34:42 PM9/1/08
to vim...@googlegroups.com, vim...@vim.org
On Mon, Sep 01, at 01:19 Luis Carvalho wrote:
> > > Below is a minor diff to your patch.
>
> Thank you. I'm attaching an updated version of the patch with a few more
> changes. I should probably find a place to put the latest version of the patch...
>

By the way,

Paul Moore

unread,
Sep 1, 2008, 6:22:45 PM9/1/08
to vim...@vim.org
Luis Carvalho wrote:
>>> Below is a minor diff to your patch.
>
> Thank you. I'm attaching an updated version of the patch with a few more
> changes. I should probably find a place to put the latest version of the patch...

I gave this a try on Windows. With the following patch to Make_ming.mak,
it compiles fine. I've done a couple of tests and it looks OK so far.
The only possible issue is with C runtime compatibility and loading DLLs
(compiled Lua extensions). Getting CRT versions that match is a fiddly
issue. That's nothing new for Windows Lua, though, so that's not an
issue with the patch.

Paul.


w32make.patch

Luis Carvalho

unread,
Sep 1, 2008, 6:34:18 PM9/1/08
to vim...@googlegroups.com
Hi Ag.,

> My only question is (from :help lua-vim):
>
> vim.open({fname}) Opens a new buffer for file {fname} and
> returns it. Note that the buffer
> is not set as current.
>
> And then few lines below:
>
> :lua vim.open"myfile"() -- open buffer and set it as current
>
>
> They both work as advertised, but why this idiom? Is there any other way
> to have the same result, but to be a little bit less confusing?
> If there is a reason to stay like this, at least (for me), it looks more
> natural exactly the opposite, so:
>
> lua vim.open('somefile')
>
> it should open the file and set is as current.

I guess I've overused the syntactic sugar. The line

:lua vim.open"myfile"()

is equivalent to

:lua local b = vim.open("myfile"); b()

that is, b is the new buffer for myfile and b() sets it as the current buffer.
I didn't want to force vim.open to set the buffer to be current as that might
not be what the user wants.

Thanks for taking the time and testing if_lua!

signature.asc

Paul Moore

unread,
Sep 2, 2008, 10:41:01 AM9/2/08
to vim_dev
On 1 Sep, 18:19, Luis Carvalho <lexcarva...@gmail.com> wrote:
> Thank you. I'm attaching an updated version of the patch with a few more
> changes. I should probably find a place to put the latest version of the patch...

A fairly small point:

:lua print("a\nb\nc")

prints

a^@b^@c

(i.e, newlines are printed as ^@, rather than as proper newlines).

Vim converts nulls to newlines and vice versa in internal strings. You
may want to look at LineToString, StringToLine, and writer, in
if_python.c. Your MSG call in luaV_print needs to split the line at
each \n character and call MSG on each line in turn. Same for the
various EMSG calls

Paul.

Luis Carvalho

unread,
Sep 3, 2008, 9:03:21 AM9/3/08
to vim...@googlegroups.com
> > Thank you. I'm attaching an updated version of the patch with a few more
> > changes. I should probably find a place to put the latest version of the patch...
>
> A fairly small point:
>
> :lua print("a\nb\nc")
>
> prints
>
> a^@b^@c
>
> (i.e, newlines are printed as ^@, rather than as proper newlines).
>
> Vim converts nulls to newlines and vice versa in internal strings. You
> may want to look at LineToString, StringToLine, and writer, in
> if_python.c. Your MSG call in luaV_print needs to split the line at
> each \n character and call MSG on each line in turn. Same for the
> various EMSG calls

Thanks for catching this. A new patch, that also provides a simple
configure.in, is available at

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.2.patch.gz

I have a question. The standalone Lua interpreter is usually linked to a
static library, but the linker gets a -E option to export all symbols and so
dynamic modules get supported. Should I add a check for gcc and add -Wl,-E?
That would export all symbols in Vim, and so it doesn't sound like a good
idea... I could also link to a shared Lua library as default. What do you guys
think?

signature.asc

Andy Kittner

unread,
Sep 3, 2008, 5:59:36 PM9/3/08
to vim...@googlegroups.com
On Wed, Sep 03, 2008 at 09:03:21AM -0400, Luis Carvalho wrote:
>
>Thanks for catching this. A new patch, that also provides a simple
>configure.in, is available at
>
>http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.2.patch.gz
>
>I have a question. The standalone Lua interpreter is usually linked to a
>static library, but the linker gets a -E option to export all symbols and so
>dynamic modules get supported. Should I add a check for gcc and add -Wl,-E?
>That would export all symbols in Vim, and so it doesn't sound like a good
>idea... I could also link to a shared Lua library as default. What do you guys
>think?
>
>Cheers,
>Luis.

Hi,

First of all thanks for the patch, I've also been toying around with
Lua support in vim, but up to now it's only a sandbox for playing around
with various things both on the Lua and the vim side.

Anyway, as for your question I'd say just default to using a shared lib.
Most other interfaces seem to do so, and I'd say the costs should be
neglectable in this case. On Windows looking up the required symbols at
runtime seems to be the most popular choice, though I personally don't
care to much about it either way.

One last thing, I noticed that your patch seems to have problems with
nested compounds:

function! s:foo()
let l:things = [[1, "foo"], [2, "bar"], [3, "baz"]]
" for extra evilness:
" call add(l:things, l:things)
lua vim.eval("l:things")
endfunction
call s:foo()

Saving this as test.vim and doing vim -c 'so test.vim' causes a
segmentation fault. Same happens if I stick in a dictionary.
Flat lists seem to work flawlessly though.

Let me know if you can't reproduce this, then I'l do a debug-build
tomorrow and get you a meaningful backtrace.

Best regards
Andy
--
BOFH Excuse #239:

CPU needs bearings repacked

Luis Carvalho

unread,
Sep 3, 2008, 9:44:11 PM9/3/08
to vim...@googlegroups.com
Hi Andy,

> Anyway, as for your question I'd say just default to using a shared lib.
> Most other interfaces seem to do so, and I'd say the costs should be
> neglectable in this case. On Windows looking up the required symbols at
> runtime seems to be the most popular choice, though I personally don't
> care to much about it either way.

That makes sense. I've updated configure.in to link a shared lib.

> One last thing, I noticed that your patch seems to have problems with
> nested compounds:
>
> function! s:foo()
> let l:things = [[1, "foo"], [2, "bar"], [3, "baz"]]
> " for extra evilness:
> " call add(l:things, l:things)
> lua vim.eval("l:things")
> endfunction
> call s:foo()
>
> Saving this as test.vim and doing vim -c 'so test.vim' causes a
> segmentation fault. Same happens if I stick in a dictionary.
> Flat lists seem to work flawlessly though.

Thanks for the report. The latest patch, available at

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.3.patch.gz

should fix these issues.

signature.asc

Paul Moore

unread,
Sep 4, 2008, 10:37:26 AM9/4/08
to vim_dev
On Sep 4, 2:44 am, Luis Carvalho <lexcarva...@gmail.com> wrote:
> > Anyway, as for your question I'd say just default to using a shared lib.
> > Most other interfaces seem to do so, and I'd say the costs should be  
> > neglectable in this case. On Windows looking up the required symbols at  
> > runtime seems to be the most popular choice, though I personally don't  
> > care to much about it either way.
>
> That makes sense. I've updated configure.in to link a shared lib.

On Windows, things get a little odd, as linking Lua as a DLL has 2
negative effects:

1. If lua51.dll isn't present, Vim won't start. This is fixable, but
needs code changes to load the DLL at runtime. The other language
bindings do this - I think I can do something similar for Lua with
less code changes, based on a recipe from the Lua wiki. Let me know if
you'd like me to try.

2. Vim needs to be linked with the same C runtime as the Lua DLL. In
practice, this means that most existing Lua binary DLLs won't work, as
they use the msvcrt8 runtime, which isn't normal for Vim. You can
build your own Lua binary DLLs, but if you're doing that, you can
probably also recompile Vim reasonably easily.

I'd suggest defaulting to linking Lua statically on Windows, with a
DLL link as an optional alternative. That's what I did in my second
Make_ming.mak patch.

Let me know if you want me to do the dynamic DLL loading change. I'll
tidy up and update my Make_ming.mak patch in any case.

Regards,
Paul.

PS In case it's not obvious, you have my full permission to include
the changes I'm posting into your patch, should you wish.

Tony Mechelynck

unread,
Sep 4, 2008, 3:55:58 PM9/4/08
to vim...@googlegroups.com

1. If the interface uses a separate DLL, then the absence of that DLL
must not prevent Vim from running (as long as the interface isn't used,
of course).

2. If the DLL must be linked with the same C runtime as every program
with which it is used, there's little advantage in having a separate
DLL. It might even be outright dangerous to use it.

Therefore I believe that the way to go is to link the Lua interface (if
enabled) statically into Vim. Or else, maybe, as a DLL of a different
name, compiled and distributed together with Vim, and installed in
$VIMRUNTIME; but there might be licensing problems with the latter approach.


Best regards,
Tony.
--
Miss, n.:
A title with which we brand unmarried women to indicate that
they are in the market.
-- Ambrose Bierce, "The Devil's Dictionary"

Paul Moore

unread,
Sep 4, 2008, 6:49:30 PM9/4/08
to vim_dev
On Sep 4, 8:55 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> 1. If the interface uses a separate DLL, then the absence of that DLL
> must not prevent Vim from running (as long as the interface isn't used,
> of course).

That's my view.

> 2. If the DLL must be linked with the same C runtime as every program
> with which it is used, there's little advantage in having a separate
> DLL. It might even be outright dangerous to use it.
>
> Therefore I believe that the way to go is to link the Lua interface (if
> enabled) statically into Vim. Or else, maybe, as a DLL of a different
> name, compiled and distributed together with Vim, and installed in
> $VIMRUNTIME; but there might be licensing problems with the latter approach.

The only issue here is that Lua allows loading of extension modules
compiled as DLLs. These need either a Lua DLL to link to (so they use
the same Lua runtime as Vim) or a means to link to a statically linked
runtime within Vim. The latter is possible, but somewhat fiddly.
Disabling loading of DLL extensions is another option, but that's a
bit limiting, in my view.

Note that this is not actually any different from the situation with
Perl, Python, TCL or whatever. It's just that Lua doesn't have a
"default" binary distribution which can be assumed to be in use - the
nearest is the LuaBinaries distribution, which makes an unfortunate
(IMHO) choice of using the msvcr80 C runtime.

I propose the following (which I plan to implement):

1. Compile-time options to link Lua dynamically or statically. The
dynamic link version WILL fail to start if lua51.dll is not present.
But that's OK, as the static build will be the default (and given
point (2) below, should not need to be overridden in normal cases).

2. I will build, test and document a "forwarding DLL" which will allow
a statically linked Lua to load .dll extension modules. This probably
won't need to be distributed with Vim, as it's not in any way Vim-
specific. I'll probably put it on the Lua-users wiki, with a pointer
to the location in Vim's documentation. (The Lua-users wiki already
has a couple of descriptions of how to do this, but I'm hoping I can
provide some clarifications, plus a working binary).

This is all only for Windows (and only for the mingw compiler on
Windows). I don't have any experience of doing this type of thing for
Linux, so I'll leave that alone. Extending this to other Windows
compilers shouldn't be hard, but I don't have the means to build Vim
with anything other than mingw at the moment.

Comments?
Paul.

PS Please note - all I'm doing is some build configuration. All the
credit for the Lua interface remains with Luis, who certainly has my
gratitude for developing the patch.

Luis Carvalho

unread,
Sep 5, 2008, 1:49:12 PM9/5/08
to vim...@googlegroups.com
> 1. If the interface uses a separate DLL, then the absence of that DLL
> must not prevent Vim from running (as long as the interface isn't used,
> of course).

Here is the latest patch; it includes dynamic dll loading in Windows and a few
minor tweaks:

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.4.patch.gz

I've also patched the Windows makefiles:

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-mak-0.4.patch.gz

Thanks for the comments, suggestions, and ideas, especially to Paul Moore!

signature.asc

Patrick Texier

unread,
Sep 9, 2008, 10:30:38 AM9/9/08
to vim...@googlegroups.com
On Fri, 5 Sep 2008 13:49:12 -0400, Luis Carvalho wrote:

In this patch, for Make_bc5.mak, I have found two errors:

line 42:
> +INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua$(PERL_VER).dll\"
LUA_VER

line 90:
>+ $(LUA_LIB_FLAG)perl.lib+
lua.lib

I have a warning, using Vim 7.2.13:

if_lua.c:
Warning W8065 if_lua.c 998: Call to function 'luaV_newstate' with no
prototype in function lua_init

I had never used lua :-)

:lua print (12 * 36)
works, but
:lua print (0 / 0)
or
:lua print (99999999 * 99999999)
crashes Vim
--
Patrick Texier

Mondal, Shishir

unread,
Sep 9, 2008, 6:58:29 PM9/9/08
to vim...@googlegroups.com, Patrick Texier
I have tried earlier, but could not do that: any one knows definite
steps how to unsubscribe from the list?
Regards
Shishir

Tony Mechelynck

unread,
Sep 9, 2008, 7:25:56 PM9/9/08
to vim...@googlegroups.com, Shishir...@netapp.com
On 10/09/08 00:58, Mondal, Shishir wrote:
> I have tried earlier, but could not do that: any one knows definite
> steps how to unsubscribe from the list?
> Regards
> Shishir

Method I: Send an email (which may be empty) from the email address with
which you are subscribed to vim-dev-u...@vim.org then wait for a
reply and make sure to do what it says.

Method II: Browse to http://groups.google.com/groups/mysubs

(you may have to log in to your Google account before you get to that
page). You'll see the Google Groups to which you are subscribed. At the
right end of the line starting "vim_dev", you see a rolldown widget
which says "E-mail". Turn it to "Unsubscribe" then click "Save group
settings" at the bottom of the page.


Note: Depending on how you subscribed, one of the above methods (I don't
know which one) may work better for you than the other.


Best regards,
Tony.
--
Any father who thinks he's all important should remind himself that
this country honors fathers only one day a year while pickles get a
whole week.

John Beckett

unread,
Sep 9, 2008, 8:50:36 PM9/9/08
to vim...@googlegroups.com
Mondal, Shishir wrote:
> I have tried earlier, but could not do that: any one knows
> definite steps how to unsubscribe from the list?

Please report any problem you have when you try the following (report = reply to
this mail):

Click the link in the footer of the mail:
> You received this message from the "vim_dev" maillist.
> For more information, visit http://www.vim.org/maillist.php

In the vim-dev section of that page, email the "To Unsubscribe" address.

John


Luis Carvalho

unread,
Sep 10, 2008, 10:06:30 PM9/10/08
to vim...@googlegroups.com
> In this patch, for Make_bc5.mak, I have found two errors:
>
> line 42:
> > +INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua$(PERL_VER).dll\"
> LUA_VER
>
> line 90:
> >+ $(LUA_LIB_FLAG)perl.lib+
> lua.lib

Thanks for the report.



> I have a warning, using Vim 7.2.13:
>
> if_lua.c:
> Warning W8065 if_lua.c 998: Call to function 'luaV_newstate' with no
> prototype in function lua_init

That's weird. I haven't seen such a warning in any other compiler...



> I had never used lua :-)
>
> :lua print (12 * 36)
> works, but
> :lua print (0 / 0)
> or
> :lua print (99999999 * 99999999)
> crashes Vim

I couldn't reproduce this behavior, but I don't have Vim compiled with BCC.

In any case, the latest version of the patch that fixes Make_bc5.mak can be
found at:

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.5.patch.gz
http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-mak-0.5.patch.gz

signature.asc

Paul Moore

unread,
Sep 12, 2008, 4:21:41 PM9/12/08
to vim_dev
On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@gmail.com> wrote:
> > :lua print (12 * 36)
> > works, but
> > :lua print (0 / 0)
> > or
> > :lua print (99999999 * 99999999)
> > crashes Vim
>
> I couldn't reproduce this behavior, but I don't have Vim compiled with BCC.

When compiled with mingw/gcc 0/0 gives -1.#IND, which is a notation
for NaN. (the 99999 case works for me, I just get a large floating
point number). I suspect that bcc doesn't handle NaN and Inf properly,
and raises a floating point exception. Whether that is untrappable, or
could be trapped in the Lua interface code, I don't know, but it looks
like it's a bcc-specific fix that's needed, if anything.
(Alternatively, are there any bcc compiler flags that could be used to
avoid floating point exceptions?

Paul.

Paul Moore

unread,
Sep 15, 2008, 6:11:11 PM9/15/08
to vim_dev
On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@gmail.com> wrote:
> In any case, the latest version of the patch that fixes Make_bc5.mak can be
> found at:
>
> http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0...http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-m...

Is this likely to be included in standard Vim at any point? At the
moment, I'm manually patching it into my regular build process, and I
want to catch the point when the patch fails because it's been made
official :-)

Paul.

Bram Moolenaar

unread,
Sep 16, 2008, 2:49:11 PM9/16/08
to Paul Moore, vim_dev

Paul Moore wrote:

Do you mean the Lua interface or the updated Makefile?

The Lua interface is somewhere in the "new features" list. There are
too many bugs to fix at the moment, so I'm not eager to add more code
(with potential bugs).

--
Q: Should I clean my house or work on Vim?
A: Whatever contains more bugs.

Paul Moore

unread,
Sep 16, 2008, 3:20:52 PM9/16/08
to Bram Moolenaar, vim_dev
2008/9/16 Bram Moolenaar <Br...@moolenaar.net>:

>
> Paul Moore wrote:
>
>> On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@gmail.com> wrote:
>> > In any case, the latest version of the patch that fixes Make_bc5.mak can be
>> > found at:
>> >
>> > http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0...http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-m...
>>
>> Is this likely to be included in standard Vim at any point? At the
>> moment, I'm manually patching it into my regular build process, and I
>> want to catch the point when the patch fails because it's been made
>> official :-)
>
> Do you mean the Lua interface or the updated Makefile?
>
> The Lua interface is somewhere in the "new features" list. There are
> too many bugs to fix at the moment, so I'm not eager to add more code
> (with potential bugs).

Sorry, I meant the Lua interface.

"Not just yet" is fair enough. As I say, I'm manually applying the
patch myself at the moment. If I hit any issues, I'll carry on
reporting them here, and hopefully once things settle down a bit, the
patch will be reasonably well tested and suitable for inclusion then.

Paul.

char101

unread,
Sep 17, 2008, 2:32:18 AM9/17/08
to vim_dev
On Sep 1, 12:13 pm, Luis Carvalho <lexcarva...@gmail.com> wrote:
> Hi,
>
> I'm attaching a patch that provides a complete Lua [1] interface to Vim in
> case anyone finds it useful. The patch is against vim-7.2. Any feedback is
> welcome, of course. Disclaimer: this is my first post to the list and this is
> my first patch to Vim! :)

Hi,

vim72-lua-0.5.patch is missing a patch for globals.h

line 1397:
#if defined(DYNAMIC_PERL) || defined(DYNAMIC_PYTHON) ||
defined(DYNAMIC_RUBY) \
|| defined(DYNAMIC_TCL) || defined(DYNAMIC_ICONV) \
|| defined(DYNAMIC_GETTEXT) || defined(DYNAMIC_MZSCHEME)
EXTERN char_u e_loadlib[] INIT(= N_("E370: Could not load library
%s"));
EXTERN char_u e_loadfunc[] INIT(= N_("E448: Could not load library
function %s"));
#endif

---
Charles

Luis Carvalho

unread,
Sep 17, 2008, 12:06:10 PM9/17/08
to vim...@googlegroups.com
> vim72-lua-0.5.patch is missing a patch for globals.h

Nice catch. The updated patch can be found at the usual place:

http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-0.6.patch.gz

signature.asc
Reply all
Reply to author
Forward
0 new messages