I've had a quick hack (and not sure how to get a proper patch set
up... but), the trampoline should be able to happen as the first thing
vim does.

It seems to work (although I've not tried any "windowing" commands yet)


proto/if_mzscheme.pro:

int mzscheme_main __ARGS((int, char**));

if_mzsch.c:

l.801:
--------------------------------
int
mzscheme_main(argc, argv)
    int         argc;
    char        **argv;
{
#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) && defined(USE_THREAD_LOCAL)
    scheme_register_tls_space(&tls_space, 0);
#endif
#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
    /* use trampoline for precise GC in MzScheme >= 4.x */
    scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
#else
    mzscheme_env_main(NULL, argc, argv);
#endif
}

    static int
mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
{
--------------------------------
l.849:

    main(argc, argv);
--------------------------------



main.c:
l.175 (at very top of main):
#ifdef FEAT_MZSCHEME
        {
        static int mzscheme_trampolined_p = 0;
        printf("in FEAT_MZSCHEME bit %d\n", mzscheme_trampolined_p);
        if(!mzscheme_trampolined_p)
            {
            mzscheme_trampolined_p++;
            return mzscheme_main(argc, argv);
            }
        }
#endif

Then at very bottom: l.946:

    /* Call the main command loop.  This never returns.
     * For embedded MzScheme the main_loop will be called by Scheme
     * for proper stack tracking
     */
    main_loop(FALSE, FALSE);

(removing references to FEAT_SCHEME)

Tim



On 4 October 2011 14:56, Sergey Khorev <[email protected]> wrote:
> I see your point.
>
> Basically, if you application embeds MzScheme v.4+ you need to use
> trampolined startup: all the Scheme activity should run inside a function
> called from scheme_main_setup. Speaking of Vim it looks like:
> 1) At the end of VimMain in main.c we do mzscheme_main()
> 2) mzscheme_main in if_mzsch.c invokes scheme_main_setup(TRUE,
> mzscheme_env_main, 0, NULL)
> 3) mzscheme_env_main does some basic initialisations and passes control back
> to Vim calling its main_loop().
>
> I think we can call mzscheme_main earlier, before Vim starts processing
> command line or scripts. We can wrap the remaining part of VimMain into a
> function and call it from mzscheme_env_main (reminds me continuation-passing
> style :)
> I cannot recall why I did not implement it like that.
>
> On Oct 4, 2011 12:44 PM, "Tim Brown" <[email protected]> wrote:
>>
>> Sergey,
>>
>> Thanks for your help so far.
>>
>> On 3 October 2011 17:39, Sergey Khorev <[email protected]> wrote:
>> >> could you confirm to me that:
>> >>
>> >> vim +':mz #f'
>> >>
>> >> works with racket-5.1.3
>> >>
>> >> It still cores on me. As does racket-5.0.1
>> >
>> > Ah, got you!
>> > :mz from command line does not and will not work with any versions
>> > newer than 3.x. Once Vim has initialised everything should work as
>> > expected.
>>
>> Unfortunately, this is just a test case, and the +":mz #f" on the
>> command line isn't actually what I want to do. I'm trying to put
>> together a "syntax" which adds all of the racket keywords (which IMO,
>> only racket would know) as :syntax... keywords.
>>
>> (In fact: http://www.vim.org/scripts/script.php?script_id=3757)
>>
>> Unfortunately, it is not the case that "Vim has initialised
>> everything" as I am loading my first racket file which then tries to
>> :source/:runtime the vim script via an :autocmd
>>
>> In fact, I have to wait until the file is loaded and displayed to me.
>> *Then* (and this is the bit I deeply resent) I have to souce the file
>> myself! (OK, so it's mapped to a key, but there's a principle here).
>>
>> So I have two questions for you:
>>  * What is wrong with the way vim starts up that it is not ready to
>> invoke :mzscheme on a command line, vim -u, syntax load or :autocmd?
>>  * When, technically has "Vim ... initialised everything"?
>>
>> > In principle someone adventurous might refactor Vim startup code to fix
>> > this...
>>
>> How adventurous?
>> How much of this is at the vim end?
>> How much of this is at the if_mzscheme/racket end?
>>
>> Tim
>>
>> --
>> | Tim Brown <[email protected]> | M:+44(0)7771714159 | H:01372747875 |
>>
>> --
>> You received this message from the "vim_dev" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visit http://www.vim.org/maillist.php
>
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>



-- 
| Tim Brown <[email protected]> | M:+44(0)7771714159 | H:01372747875 |
|----------------------------------------------------------------|
| vim: syntax=mail textwidth=65 ai nocindent

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

Raspunde prin e-mail lui