]> git.phdru.name Git - dotfiles.git/commitdiff
.vimrc: Fix checktime/FileChangedShell
authorOleg Broytman <phd@phdru.name>
Mon, 26 Mar 2018 04:03:51 +0000 (07:03 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 26 Mar 2018 04:03:51 +0000 (07:03 +0300)
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.

.vimrc

diff --git a/.vimrc b/.vimrc
index 1620a5d40ad0b78cd52e498f9a6807d38dbfce5e..ab3609ebcf5a5d74a35ac9ebe0e1aa7ffcb21b3a 100644 (file)
--- 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 <buffer> 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 <buffer>"
    endfunction
    command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif
 endif