]> git.phdru.name Git - dotfiles.git/blobdiff - .vim/ftplugin/python.vim
.mc/mc.ext: Add a regex for zip archives
[dotfiles.git] / .vim / ftplugin / python.vim
index 44ec35e0775cc24159e0afe9c385039ccf38b8bd..2aa92b056598bd9d44867b268ee8e7cd3cf762e0 100644 (file)
@@ -17,13 +17,13 @@ if has("iconv") && !exists('b:encoding_set')
    endif
 endif
 
-setlocal fo-=t fo+=croql
+setlocal formatoptions-=t formatoptions+=croql
 setlocal keywordprg=pydoc
 setlocal shiftwidth=4 softtabstop=4
 compiler python
 
 if has("unix")
-   execute "autocmd BufWritePost " . expand("%") . " call SavePython()"
+   autocmd BufWritePost <buffer> call SavePython()
 endif
 
 " Compile and remove *.cgi[co] files after compilation; do not remove *.py[co] files;
@@ -39,8 +39,14 @@ function! SavePython()
       if ext != "py"
          !rm -f %[co]
       endif
+      if executable(expand('%:p')) || !executable('chmod')
+        return
+      endif
       if getline(1) =~ "^#!"
          !chmod +x %
+         if v:shell_error
+            echoerr 'Cannot make file executable: ' . v:shell_error
+         endif
       endif
    endif
 endfunction