From: Oleg Broytman Date: Mon, 26 Mar 2018 04:03:51 +0000 (+0300) Subject: .vimrc: Fix checktime/FileChangedShell X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=fefb347090ff343f13ad354b9472e68d6a36e4a8;p=dotfiles.git .vimrc: Fix checktime/FileChangedShell When `checktime` is called in an autocommand it doesn't trigger FileChangedShell immediately. Instead it waits until the end of the autocommand. So we have to remove FileChangedShell autocommand when it's triggered, not inside SetExecutableBit function called from an autocommand. --- diff --git a/.vimrc b/.vimrc index 1620a5d..ab3609e 100644 --- a/.vimrc +++ b/.vimrc @@ -591,7 +591,7 @@ if executable('chmod') checktime let fname = expand("%:p") let fx = executable(fname) - execute "au FileChangedShell " . fname . " :echo" + execute "au FileChangedShell call _BufChangedCB()" if a:x && !fx !chmod a+x % elseif !a:x && fx @@ -601,7 +601,9 @@ if executable('chmod') echoerr 'Error running chmod: ' . v:shell_error endif checktime - execute "au! FileChangedShell " . fname + endfunction + function! _BufChangedCB() + execute "au! FileChangedShell " endfunction command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif endif