IMHO you could use autocmd instead of &modified. Please check :h autocmd-events-abc for what you need.
On Fri, Mar 16, 2012 at 4:23 PM, Black <[email protected]> wrote: > Hi all, > > I try to customise my SL to have a style depending section on the > state of the buffer which it is attached. > set statusline=%1*\ %f\ %2*%=\ %3*\ %{&modified?'✖':'✔'}\ %4*\ <% > {&encoding}:%{&fileformat}>\ %5*\ %r%y\ %6*\ %cc,%lL/%LL\ %3p%% > > I tried the following code, the return of the unfortunate condition is > not interpreted. > set statusline=%1*\ %f\ %2*%=\ %{&modified?'%7*\ ✖':'%8*\ ✔'}\ %4*\ <% > {&encoding}:%{&fileformat}>\ %5*\ %r%y\ %6*\ %cc,%lL/%LL\ %3p%% > > I then tried this code. It works well when I have a buffer, beyond all > my SL are identical to the SL of my current buffer. > function! StatusLine(e) > if (a:e) > return '%1* %f %2*%= %7* ✖ %4* <%{&encoding}:%{&fileformat}> > %5* %r%y %6* %cc,%lL/%LL %3p%%' > else > return '%1* %f %2*%= %8* ✔ %4* <%{&encoding}:%{&fileformat}> > %5* %r%y %6* %cc,%lL/%LL %3p%%' > endif > endfunction > > set statusline=%!StatusLine(&modified) > > I wonder if you can force interpretation of the return of a condition > or why my second try does not work, is this a bug? > > For your help, > In advance, > Thank you. > > PS : I use the version 7.3.315 > > -- > 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 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
