On Jan 2, 3:45 am, ashres <ash...@gmail.com> wrote: > Hey all, > I'm working on my first vimscript plugin. One of the things I want to > do in the plugin is to customize the statusline, but then, at a later > time, be able to restore it. > > I've a function called Startup that saves the current statusline: > > function! MyPlugin#Startup() > let s:saved_statusline = &statusline > " modify the statusline for plugin purposes here > " .... > endfunction > > And, I've got a function called Shutdown, that reverts the statusline > back: > > function! MyPlugin#Shutdown() > set statusline=%{s:saved_statusline} > endfunction > > I call Startup first, then Shutdown next. I get these errors: > > E121: Undefined variable: s:saved_statusline > E15: Invalid expression: s:saved_statusline > > Any help would be greatly appreciated!
When restoring, use let &statusline = s:saved_statusline instead. If the restoring function is defined in the same script as the saving function, they will both have access to the script-local variables of that script; but the 'statusline' and its %{} expression are evaluated outside of any script context, and, when *evaluating* the statusline in order to display it for a particular window, s:saved_statusline is indeed not defined. -- You received this message from the "vim_mac" 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