Mercurial > vim-p44vim
comparison autoload/p44vim.vim @ 3:14a272d72b0a
Only open file for edit if it's readonly just before writing to it.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 24 Sep 2020 22:50:09 -0700 |
parents | 74b2ef146e82 |
children | 52e1502091e0 |
comparison
equal
deleted
inserted
replaced
2:74b2ef146e82 | 3:14a272d72b0a |
---|---|
46 | 46 |
47 " Auto-commands {{{ | 47 " Auto-commands {{{ |
48 | 48 |
49 let s:ignore_next_w12 = 0 | 49 let s:ignore_next_w12 = 0 |
50 | 50 |
51 function! s:auto_edit_buffer() abort | 51 function! s:maybe_auto_edit_buffer() abort |
52 call p44vim#p4edit() | 52 if &readonly |
53 call p44vim#p4edit() | |
54 endif | |
53 endfunction | 55 endfunction |
54 | 56 |
55 function! s:maybe_ignore_w12() abort | 57 function! s:maybe_ignore_w12() abort |
56 if s:ignore_next_w12 | 58 if s:ignore_next_w12 |
57 let v:fcs_choice = '' " Ignore the warning, keep the file. | 59 let v:fcs_choice = '' " Ignore the warning, keep the file. |
70 let b:p44v_repo_root = l:repo_root | 72 let b:p44v_repo_root = l:repo_root |
71 call s:trace("Setting up P4 auto-commands for: ".bufname('%')) | 73 call s:trace("Setting up P4 auto-commands for: ".bufname('%')) |
72 | 74 |
73 augroup p44v_auto | 75 augroup p44v_auto |
74 autocmd! | 76 autocmd! |
75 autocmd FileChangedRO * call <SID>auto_edit_buffer() | 77 autocmd BufWritePre * call <SID>maybe_auto_edit_buffer() |
76 autocmd FileChangedShell * call <SID>maybe_ignore_w12() | 78 autocmd FileChangedShell * call <SID>maybe_ignore_w12() |
77 augroup END | 79 augroup END |
78 endfunction | 80 endfunction |
79 | 81 |
80 " }}} | 82 " }}} |