On 09/02/09 05:40, Garrett Whelan wrote:
> I would like to be able to access all the variables at a given time in
> Vim without necessarily knowing what they are. Basically everything you
> would see if you typed :let and :set. So in increasing order of difficulty
>
>    1. Is there a way to redirect the output from :let and :set? It would
>       be pretty simple to parse that up, but I can't figure it out.

        :help :redir

>    2. Is there a way to call functions in the Vim code from VimL?
>       Browsing through the source I see list_hashtable_vars seems to
>       have the info I need.

You cannot access arbitrary functions in the binary code from vimscript. 
The only things you can execute from vimscript are vimscript functions, 
ex-commands, and keybindings, see
        :help function-list
        :help ex-cmd-index
        :help index.txt
        :help :normal

You can view the C _source_ code if you've downloaded it, but of course 
this is done by loading the actual source files in the editor, not by 
disassembly.

>    3. Is there a way to access the actual C data structures from VimL?
>       If I could read the various hashtables myself I could do what I
>       needed.

AFAIK, there isn't -- nothing equivalent to the PEEK and POKE functions 
available in some versions of BASIC.

>
> I suspect there's no way to do any of this, but I thought I'd ask before
> I took a more...cumbersome route. Oh, also what is this declaration
> structure:
> 2038 static void
> 2039 list_func_vars(first)
> 2040 int *first;
> 2041 {
> 2042 if (current_funccal != NULL)
> 2043 list_hashtable_vars(&current_funccal->l_vars.dv_hashtab,
> 2044 (char_u *)"l:", FALSE, first);
> 2045 }
>
> I've never seen that in C before. Declaring variables after the
> arguments but before the body?
>
> --Whaledawg

It's not variables, it's the arguments: "int *first" here means that 
"first", the argument, is a pointer to int. I'm told doing it this way 
rather than "static void list_func_vars(int *first)" makes the source 
more portable among various C compilers.

IIUC, the Vim C source obeys the C89 standard, as shown by this line 
which I see in the logfile where I saved the stdout/stderr of configure:


checking for gcc option to accept ISO C89... none needed


See an explanation of Vim source coding style at ":help coding-style", 
and this particular case somewhat below ":help style-examples", in the 
section starting "Functions start with:".


Best regards,
Tony.
-- 
Pure drivel tends to drive ordinary drivel off of the TV screen.

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

Raspunde prin e-mail lui