diff --git a/plugin/AtomicSave.vim b/plugin/AtomicSave.vim index 5e5482c..d9675db 100644 --- a/plugin/AtomicSave.vim +++ b/plugin/AtomicSave.vim @@ -1,5 +1,10 @@ function! AtomicSave() if (writefile(getline(1, '$'), expand('').'.tmp') == 0)| + call system('if [ -f ' . shellescape(expand('')) . ' ]; then chmod --reference=' . shellescape(expand('')) . ' ' . shellescape(expand('').'.tmp') . '; fi')| + if v:shell_error| + echo "error chmod file: chmod returned " v:shell_error| + endif| + " NOTE: vim's "rename" erroneously calls "unlink" on its target! " THIS DOES NOT WORK: if (rename(expand('').'.tmp', expand('')) == 0) | set nomodified | echo "error" | endif call system('mv ' . shellescape(expand('').'.tmp') . ' ' . shellescape(expand('')))|