Loading ...
Sorry, an error occurred while loading the content.

(patch) Lua interface

Expand Messages
  • Luis Carvalho
    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
    Message 1 of 28 , Aug 31, 2008
    • 0 Attachment
      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((("lexcarvalho@..."):gsub("(%u+%.)","")))'
    • Ag. D. Hatzimanikas
      ... 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
      Message 2 of 28 , Sep 1, 2008
      • 0 Attachment
        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((("lexcarvalho@..."):gsub("(%u+%.)","")))'

        Regards,
        Ag.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Ag. D. Hatzimanikas
        ... Note to me: Don t send again patches, when there is an angry wife near your shoulders. ... +++ vim72-lua.patch 2008-09-01 10:43:13.865134252 +0300 @@
        Message 3 of 28 , Sep 1, 2008
        • 0 Attachment
          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
          + AC_MSG_RESULT("yes")
          + else
          + AC_MSG_RESULT("no")

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Bram Moolenaar
          ... 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
          Message 4 of 28 , Sep 1, 2008
          • 0 Attachment
            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 -- Bram@... -- 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 ///

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Luis Carvalho
            ... 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...
            Message 5 of 28 , Sep 1, 2008
            • 0 Attachment
              > > 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.

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

              --
              Luis Carvalho (Kozure)
              lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
            • Ag. D. Hatzimanikas
              ... 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})
              Message 6 of 28 , Sep 1, 2008
              • 0 Attachment
                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.

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Ag. D. Hatzimanikas
                ... 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
                Message 7 of 28 , Sep 1, 2008
                • 0 Attachment
                  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.

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Paul Moore
                  ... 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
                  Message 8 of 28 , Sep 1, 2008
                  • 0 Attachment
                    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.



                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Luis Carvalho
                    Hi Ag., ... I guess I ve overused the syntactic sugar. The line ... is equivalent to ... that is, b is the new buffer for myfile and b() sets it as the current
                    Message 9 of 28 , Sep 1, 2008
                    • 0 Attachment
                      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!

                      Cheers,
                      Luis.

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

                      --
                      Luis Carvalho (Kozure)
                      lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                    • Paul Moore
                      ... 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
                      Message 10 of 28 , Sep 2, 2008
                      • 0 Attachment
                        On 1 Sep, 18:19, Luis Carvalho <lexcarva...@...> 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.
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_dev" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Luis Carvalho
                        ... Thanks for catching this. A new patch, that also provides a simple configure.in, is available at
                        Message 11 of 28 , Sep 3, 2008
                        • 0 Attachment
                          > > 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?

                          Cheers,
                          Luis.

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

                          --
                          Luis Carvalho (Kozure)
                          lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                        • Andy Kittner
                          ... 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
                          Message 12 of 28 , Sep 3, 2008
                          • 0 Attachment
                            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
                            Hi Andy, ... That makes sense. I ve updated configure.in to link a shared lib. ... Thanks for the report. The latest patch, available at
                            Message 13 of 28 , Sep 3, 2008
                            • 0 Attachment
                              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.

                              Cheers,
                              Luis.

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

                              --
                              Luis Carvalho (Kozure)
                              lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                            • Paul Moore
                              ... 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
                              Message 14 of 28 , Sep 4, 2008
                              • 0 Attachment
                                On Sep 4, 2:44 am, Luis Carvalho <lexcarva...@...> 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.
                                --~--~---------~--~----~------------~-------~--~----~
                                You received this message from the "vim_dev" maillist.
                                For more information, visit http://www.vim.org/maillist.php
                                -~----------~----~----~----~------~----~------~--~---
                              • Tony Mechelynck
                                ... 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).
                                Message 15 of 28 , Sep 4, 2008
                                • 0 Attachment
                                  On 04/09/08 16:37, Paul Moore wrote:
                                  > On Sep 4, 2:44 am, Luis Carvalho<lexcarva...@...> 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.

                                  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"

                                  --~--~---------~--~----~------------~-------~--~----~
                                  You received this message from the "vim_dev" maillist.
                                  For more information, visit http://www.vim.org/maillist.php
                                  -~----------~----~----~----~------~----~------~--~---
                                • Paul Moore
                                  On Sep 4, 8:55 pm, Tony Mechelynck ... That s my view. ... The only issue here is that Lua allows loading of extension modules
                                  Message 16 of 28 , Sep 4, 2008
                                  • 0 Attachment
                                    On Sep 4, 8:55 pm, Tony Mechelynck <antoine.mechely...@...>
                                    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.
                                    --~--~---------~--~----~------------~-------~--~----~
                                    You received this message from the "vim_dev" maillist.
                                    For more information, visit http://www.vim.org/maillist.php
                                    -~----------~----~----~----~------~----~------~--~---
                                  • Luis Carvalho
                                    ... Here is the latest patch; it includes dynamic dll loading in Windows and a few minor tweaks:
                                    Message 17 of 28 , Sep 5, 2008
                                    • 0 Attachment
                                      > 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!

                                      Cheers,
                                      Luis.

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

                                      --
                                      Luis Carvalho (Kozure)
                                      lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                                    • Patrick Texier
                                      ... In this patch, for Make_bc5.mak, I have found two errors: ... LUA_VER ... lua.lib I have a warning, using Vim 7.2.13: if_lua.c: Warning W8065 if_lua.c 998:
                                      Message 18 of 28 , Sep 9, 2008
                                      • 0 Attachment
                                        On Fri, 5 Sep 2008 13:49:12 -0400, Luis Carvalho wrote:

                                        > I've also patched the Windows makefiles:
                                        >
                                        > http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-mak-0.4.patch.gz

                                        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

                                        --~--~---------~--~----~------------~-------~--~----~
                                        You received this message from the "vim_dev" maillist.
                                        For more information, visit http://www.vim.org/maillist.php
                                        -~----------~----~----~----~------~----~------~--~---
                                      • Mondal, Shishir
                                        I have tried earlier, but could not do that: any one knows definite steps how to unsubscribe from the list? Regards Shishir ... From: Patrick Texier
                                        Message 19 of 28 , Sep 9, 2008
                                        • 0 Attachment
                                          I have tried earlier, but could not do that: any one knows definite
                                          steps how to unsubscribe from the list?
                                          Regards
                                          Shishir


                                          -----Original Message-----
                                          From: Patrick Texier [mailto:p.texier@...]
                                          Sent: Tuesday, September 09, 2008 7:31 AM
                                          To: vim_dev@...
                                          Subject: Re: (patch) Lua interface : Borland C++ 5.5.1 test


                                          On Fri, 5 Sep 2008 13:49:12 -0400, Luis Carvalho wrote:

                                          > I've also patched the Windows makefiles:
                                          >
                                          > http://wiki.linuxfromscratch.org/blfs/attachment/wiki/vim/vim72-lua-ma
                                          > k-0.4.patch.gz

                                          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



                                          --~--~---------~--~----~------------~-------~--~----~
                                          You received this message from the "vim_dev" maillist.
                                          For more information, visit http://www.vim.org/maillist.php
                                          -~----------~----~----~----~------~----~------~--~---
                                        • Tony Mechelynck
                                          ... Method I: Send an email (which may be empty) from the email address with which you are subscribed to vim-dev-unsubscribe@vim.org then wait for a reply and
                                          Message 20 of 28 , Sep 9, 2008
                                          • 0 Attachment
                                            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-unsubscribe@... 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.

                                            --~--~---------~--~----~------------~-------~--~----~
                                            You received this message from the "vim_dev" maillist.
                                            For more information, visit http://www.vim.org/maillist.php
                                            -~----------~----~----~----~------~----~------~--~---
                                          • John Beckett
                                            ... Please report any problem you have when you try the following (report = reply to this mail): ... In the vim-dev section of that page, email the To
                                            Message 21 of 28 , Sep 9, 2008
                                            • 0 Attachment
                                              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



                                              --~--~---------~--~----~------------~-------~--~----~
                                              You received this message from the "vim_dev" maillist.
                                              For more information, visit http://www.vim.org/maillist.php
                                              -~----------~----~----~----~------~----~------~--~---
                                            • Luis Carvalho
                                              ... Thanks for the report. ... That s weird. I haven t seen such a warning in any other compiler... ... I couldn t reproduce this behavior, but I don t have
                                              Message 22 of 28 , Sep 10, 2008
                                              • 0 Attachment
                                                > 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

                                                Cheers,
                                                Luis.

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

                                                --
                                                Luis Carvalho (Kozure)
                                                lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                                              • Paul Moore
                                                ... 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
                                                Message 23 of 28 , Sep 12, 2008
                                                • 0 Attachment
                                                  On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@...> 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.
                                                  --~--~---------~--~----~------------~-------~--~----~
                                                  You received this message from the "vim_dev" maillist.
                                                  For more information, visit http://www.vim.org/maillist.php
                                                  -~----------~----~----~----~------~----~------~--~---
                                                • Paul Moore
                                                  ... 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
                                                  Message 24 of 28 , Sep 15, 2008
                                                  • 0 Attachment
                                                    On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@...> 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.
                                                    --~--~---------~--~----~------------~-------~--~----~
                                                    You received this message from the "vim_dev" maillist.
                                                    For more information, visit http://www.vim.org/maillist.php
                                                    -~----------~----~----~----~------~----~------~--~---
                                                  • Bram Moolenaar
                                                    ... 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
                                                    Message 25 of 28 , Sep 16, 2008
                                                    • 0 Attachment
                                                      Paul Moore wrote:

                                                      > On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@...> 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).

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

                                                      /// Bram Moolenaar -- Bram@... -- 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 ///

                                                      --~--~---------~--~----~------------~-------~--~----~
                                                      You received this message from the "vim_dev" maillist.
                                                      For more information, visit http://www.vim.org/maillist.php
                                                      -~----------~----~----~----~------~----~------~--~---
                                                    • Paul Moore
                                                      ... 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
                                                      Message 26 of 28 , Sep 16, 2008
                                                      • 0 Attachment
                                                        2008/9/16 Bram Moolenaar <Bram@...>:
                                                        >
                                                        > Paul Moore wrote:
                                                        >
                                                        >> On Sep 11, 3:06 am, Luis Carvalho <lexcarva...@...> 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.

                                                        --~--~---------~--~----~------------~-------~--~----~
                                                        You received this message from the "vim_dev" maillist.
                                                        For more information, visit http://www.vim.org/maillist.php
                                                        -~----------~----~----~----~------~----~------~--~---
                                                      • char101
                                                        ... 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) ...
                                                        Message 27 of 28 , Sep 16, 2008
                                                        • 0 Attachment
                                                          On Sep 1, 12:13 pm, Luis Carvalho <lexcarva...@...> 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
                                                          --~--~---------~--~----~------------~-------~--~----~
                                                          You received this message from the "vim_dev" maillist.
                                                          For more information, visit http://www.vim.org/maillist.php
                                                          -~----------~----~----~----~------~----~------~--~---
                                                        • Luis Carvalho
                                                          ... 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 Cheers,
                                                          Message 28 of 28 , Sep 17, 2008
                                                          • 0 Attachment
                                                            > 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

                                                            Cheers,
                                                            Luis.

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

                                                            --
                                                            Luis Carvalho (Kozure)
                                                            lua -e 'print((("lexcarvalho@..."):gsub("(%u+%.)","")))'
                                                          Your message has been successfully submitted and would be delivered to recipients shortly.