On Nov 9, 8:51 pm, "Charles E. Campbell, Jr."
<[EMAIL PROTECTED]> wrote:
> > 2.  I tried this to make read-only buffers unmodifiable:
> >
> >         function MakeUnmodifiableIfReadonly()  
> >         if &readonly
> >             set nomodifiable
> >         endif
> >         endfunction
> >         autocmd BufReadPost * call MakeUnmodifiableIfReadonly()
> >
> >     but it doesn't seem to work with :q or :bd, it takes a full
> >     :bw, which seems not recomended.  And I probably missed some
> >     totally easy way to do this (might be a good one for the FAQ)?
>
> First, you don't really need to call a function with the autocmd.  Just
>
>   au BufReadPost * set nomodifiable
>
> would've done what you had did via the function.  However, that setting
> doesn't affect the editing of the buffer, nor does it lock the window.  
> Windows aren't lock-able.
>

I don't think the autocmd Dr. Chip gives will do the job the OP wants.

Looking carefully, it looks like the desire is to only set
nomodifiable if readonly is also set.

I'm not actually sure why the autocmd used by the OP doesn't work, but
perhaps try using the BufWinEnter instead of BufReadPost autocmd.
>From :help BufReadPost we get a hint to "See BufWinEnter for when you
need to do something after processing the modelines." Perhaps the
readonly option also gets set after executing modelines.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to