On Wed, Mar 11, 2009 at 8:17 PM, RPN <[email protected]> wrote:

> Chris, in hindsight the extra logic (although tempting) is a failure.
> The reason is that the logic of lines 2 and 3 is mutually incompatible
> in a subtle sense (assuming I understand vim correctly!).

I am using a similar trick in my .vimrc: instead of changing syntax on and off,
I change the color of the status line depending of modified state of the buffer.
I believe the same technique may be applied to the problem in question.
Quotation from my .vimrc:

" Bogus value, just not to leave it undefined
let was_modified = 2

autocmd BufEnter,BufReadPost,BufWritePost * call WhenModified(1)
autocmd CursorMoved,CursorMovedI * call WhenModified(0)

function! WhenModified(force)
  if a:force || &modified != g:was_modified
    execute 'setlocal statusline=%' . &modified . '*%t\ %L'
        \ . '\ %y%r[%{&tw}]%=\ %{Moon()}\ %{Lang()}\ %{Icon()}'
        \ . '\ %{&fenc}\ %m\ %-15(%{HexDec()}%)%-10(%l,%v%)%P'
    let g:was_modified = &modified
  endif
endfunction

Instead of my long "execute 'setlocal statusline...'" you can put any command
at your wish. A bit complex, but works for me.

-- 
http://slobin.pp.ru/ `When I use a word,' Humpty Dumpty said,
<[email protected]> `it means just what I choose it to mean'

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

Reply via email to