fritzophrenic wrote:
>
> 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
>   
The autocmd I gave was intended to be a shorter way to do what the OP 
was doing, although I didn't get it right.  Here's the modified version:

au BufReadPost * if &readonly|set noma|endif

> 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.
>   
I think the OP wanted the window to stay in place.  Both his function 
and the shorter version I gave above do work to make readonly buffers 
not modifiable.  However, "not modifiable" doesn't mean that the buffer 
can't be quit, deleted from Vim's memory (or wiped).  I think that 
there's a confusion between windows and buffers.  There is no built-in 
way to "lock" a window, which I interpret to mean that a :q or :bd or 
:bw or... will quit etc and do an enew.  A set of cnoremaps perhaps 
could be made to emulate such behavior.

Regards,
Chip Campbell


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

Reply via email to