From 9edda15d7856fb83cbd23143d5a3f9ab86b92cb8 Mon Sep 17 00:00:00 2001 From: Ken Allan Date: Thu, 24 Nov 2011 12:18:48 +1000 Subject: [PATCH] Add code to chmod the temporary file based off the mode of the reference file --- plugin/AtomicSave.vim | 5 +++++ 1 file changed, 5 insertions(+) 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('')))|