Re: Blocking of "save"

2007-05-09 Thread A.J.Mechelynck

A.J.Mechelynck wrote:

[EMAIL PROTECTED] wrote:

Hi,

 is there a way to disabling the saveing and writing of/to a file
 and leaving of vim until a certain condition of the contents of
 the file is not given (in this case certain characters are not
 allowed as contents of the file)?
 The whole thing should only be active for a C-/C++-Files.

 Thanks a lot for any help in advance!
 Keep editing!
 mcc




 ~/.vim/after/ftplugin/c.vim (Unix) 
 ~/vimfiles/after/ftplugin/c.vim (Windows) 
function s:CheckCFile()
" do something ...
" setting a variable (let's say l:FileOK) to true (1)
" or false (0)
return FileOK
endfunction
augroup cfilecheck
au BufWritePre *.c,*.h,*.cpp
\   setlocal modified
\ | let &l:readonly = ! s:CheckCFile()
augroup END



This should give you the familiar error if you attempt to save a "bad" 
file or exit Vim without an exclamation mark after the command name (see 
":help abandon").



Best regards,
Tony.


Oops! no, it should be global. Place it in your vimrc instead.


Best regards,
Tony.
--
Ask five economists and you'll get five different explanations (six if
one went to Harvard).
-- Edgar R. Fiedler


Re: Blocking of "save"

2007-05-09 Thread A.J.Mechelynck

[EMAIL PROTECTED] wrote:

Hi,

 is there a way to disabling the saveing and writing of/to a file
 and leaving of vim until a certain condition of the contents of
 the file is not given (in this case certain characters are not
 allowed as contents of the file)?
 The whole thing should only be active for a C-/C++-Files.

 Thanks a lot for any help in advance!
 Keep editing!
 mcc




 ~/.vim/after/ftplugin/c.vim (Unix) 
 ~/vimfiles/after/ftplugin/c.vim (Windows) 
function s:CheckCFile()
" do something ...
" setting a variable (let's say l:FileOK) to true (1)
" or false (0)
return FileOK
endfunction
augroup cfilecheck
au BufWritePre *.c,*.h,*.cpp
\   setlocal modified
\ | let &l:readonly = ! s:CheckCFile()
augroup END



This should give you the familiar error if you attempt to save a "bad" file or 
exit Vim without an exclamation mark after the command name (see ":help abandon").



Best regards,
Tony.
--
Excellent day for drinking heavily.  Spike office water cooler.



Blocking of "save"

2007-05-09 Thread meino . cramer
Hi,

 is there a way to disabling the saveing and writing of/to a file
 and leaving of vim until a certain condition of the contents of
 the file is not given (in this case certain characters are not
 allowed as contents of the file)?
 The whole thing should only be active for a C-/C++-Files.

 Thanks a lot for any help in advance!
 Keep editing!
 mcc


-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.