Thursday, February 27, 2014

Re: Dumb question: variables in the statusline

"Ben Klein" <ben@silver-chalice.com>
>
> (Maybe this will be like last time, where I just had to send the
> question to the list before I could realize how idiotically wrong I
> was...)
>
>
> I have a function which takes ... arguments, and when I try to call
> it from another function to set the statusline, I basically get:
>
>
>
> E121: Undefined variable: a:1
> E116: Invalid arguments for function
> FunctionFromWhichIAmTryingToGetAStatusline(a:1)
>
>
> So the function getting the error is more or less:
>
>
> function! SetUpTheStatusline(...)
> setlocal statusline=%!FunctionFromWhichIAmTryingToGetAStatusline(a:1)
> endfunction
>
>
> And that is just getting those two errors.
>
>
> To be clear, I have verified that there is indeed a:1 in the
> SetUpTheStatusline() function. I can do (it seems) anything with it
> -- even use it in the call to
> FunctionFromWhichIAmTryingToGetAStatusline() -- except for using it
> in a function called in the statusline.
>
>
> What am I doing wrong?

"statusline" is a string, so I guess the correct form is:

exe "setlocal statusline=%!FunctionFromWhichIAmTryingToGetAStatusline('" . a:1 . "')"

Of course, a:1 should be of the proper type.

Best,
Paul

--
--
You received this message from the "vim_use" 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 because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment