g:actual_curwin undefined

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

g:actual_curwin undefined

Lifepillar-2
I want to use g:statusline_winid and g:actual_curwin to detect
whether the currently drawn status line is the active one.
 
With Vim 8.1.1517, I have tried the following code:

    fun! BuildStatusLine()
      return g:statusline_winid ==# g:actual_curwin
      \ ? 'Active' : 'Inactive'
    endf

    set statusline=%!BuildStatusLine()

but I get E121: Undefined variable: g:actual_curwin.

My understanding is that the global variables should be defined
when a %! expression is evaluated. Is that correct? If so, what
am I doing wrong?

Thanks,
Life.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/50001D96-65C8-492F-BE80-9D8AC41B385C%40icloud.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: g:actual_curwin undefined

Lifepillar-2
On 19 Jun 2019, at 20:13, 'Lifepillar' via vim_use <[hidden email]> wrote:

>
> I want to use g:statusline_winid and g:actual_curwin to detect
> whether the currently drawn status line is the active one.
>
> With Vim 8.1.1517, I have tried the following code:
>
>    fun! BuildStatusLine()
>      return g:statusline_winid ==# g:actual_curwin
>      \ ? 'Active' : 'Inactive'
>    endf
>
>    set statusline=%!BuildStatusLine()
>
> but I get E121: Undefined variable: g:actual_curwin.

Never mind, I've got it: g:statusline_winid is evaluated in %! expressions, but
g:actual_curwin is evaluated in %{} context. It makes sense now.

Life.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/2E20EC58-B8B6-470D-955A-E7B478E99CEC%40icloud.com.
For more options, visit https://groups.google.com/d/optout.