Hi,

I'm doing some work on MacVim and I've written a function (see below)
to programmatically evaluate an expression in vim and convert the
result to cocoa values.  I'd like to be able to return information
about why the evaluation failed if it does.  Can anyone give me tips
on how to get an error string or something?

Thanks,

Matt

----------------------------------------

// This function is modeled after eval_client_expr_to_string found in main.c
// Returns nil if there was an error evaluating the expression
static id evalExprCocoa(NSString * expr)
{

    char_u *s = (char_u*)[expr UTF8String];

#ifdef FEAT_MBYTE
    s = CONVERT_FROM_UTF8(s);
#endif

    int save_dbl = debug_break_level;
    int save_ro = redir_off;

    debug_break_level = -1;
    redir_off = 0;
    ++emsg_skip;

    typval_T * tvres = eval_expr(s, NULL);

    debug_break_level = save_dbl;
    redir_off = save_ro;
    --emsg_skip;

    setcursor();
    out_flush();

#ifdef FEAT_MBYTE
    CONVERT_FROM_UTF8_FREE(s);
#endif

#ifdef FEAT_GUI
    if (gui.in_use)
        gui_update_cursor(FALSE, FALSE);
#endif

    if (tvres == NULL)
        return nil;

    id res = vimToCocoa(tvres, 1);

    free_tv(tvres);

    return res;

}

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to