From: Iain Patterson Date: Thu, 6 Feb 2014 13:27:42 +0000 (+0000) Subject: Use help buffers in commit and merge scripts. X-Git-Url: http://git.iain.cx/?p=profile.git;a=commitdiff_plain;h=f91d0548dbdf839818a7645e855ff3e9f5e9252c Use help buffers in commit and merge scripts. The previous attempt to override Vim 7.4's window closing paranoia didn't work that well. Closing the scratch buffer would result in the commit message window being lost without saving changes. The latest scheme is to mark the scratch buffer as a help buffer, despite the documentation saying we aren't supposed to do that. The result is that it will automatically be closed when it's the last buffer standing, which is very close to what we want. --- diff --git a/.vim/script/merge b/.vim/script/merge index a00fea3..992108a 100644 --- a/.vim/script/merge +++ b/.vim/script/merge @@ -22,8 +22,7 @@ fun! P4merge() set ro set nomodifiable set nobuflisted - set buftype=nowrite - set bufhidden=hide + set buftype=help setlocal noswapfile exe "file \[ORIG:" . l:filename . "\]" diffthis @@ -34,8 +33,7 @@ fun! P4merge() set ro set nomodifiable set nobuflisted - set buftype=nowrite - set bufhidden=hide + set buftype=help setlocal noswapfile exe "file \[YOURS:" . l:filename . "\]" diffthis @@ -47,7 +45,7 @@ fun! P4merge() set ro set nomodifiable set nobuflisted - set buftype=nowrite + set buftype=help set bufhidden=hide setlocal noswapfile exe "file \[THEIRS:" . l:filename . "\]" diff --git a/.vim/script/p4 b/.vim/script/p4 index 4badc84..3595ed4 100644 --- a/.vim/script/p4 +++ b/.vim/script/p4 @@ -18,7 +18,7 @@ fun! P4submit() delete " Allow closing an unmodified spec. - set nomod + set nomodified try /everything below this line is just the diff/ @@ -44,20 +44,16 @@ fun! P4submit() " Delete the blank line left above the diff. 1 delete + set ro + set nomodified + set nomodifiable set nobuflisted - set buftype=nowrite - set bufhidden=hide + set buftype=help setlocal noswapfile file [p4 diff\] " Map q to quit easily. nnoremap q q - " Vim 7.4 really doesn't want us to quit windows from a script. - try - au QuitPre * qa! - catch - endtry - " Switch back to the top window and put the cursor by the description. wincmd k resize 10 diff --git a/.vim/script/svn b/.vim/script/svn index 223d0f0..f648862 100644 --- a/.vim/script/svn +++ b/.vim/script/svn @@ -2,7 +2,7 @@ " trying to run a sequence of normal mode commands. fun! SVNcommit() " Allow closing an unmodified spec. - set nomod + set nomodified " Get the modified files. Discount new files. let l:files = system("sed -n '1,/^$/d;/^[MR]..../{s//\"/;s/$/\"/p;}' " . bufname("")) @@ -19,20 +19,16 @@ fun! SVNcommit() " Delete the blank line left above the diff. 1 delete - se nobuflisted - set buftype=nowrite - set bufhidden=hide + set ro + set nomodifiable + set nomodified + set nobuflisted + set buftype=help setlocal noswapfile file [svn diff\] " Map q to quit easily. nnoremap q q - " Vim 7.4 really doesn't want us to quit windows from a script. - try - au QuitPre * qa! - catch - endtry - " Switch back to the top window. wincmd k endfun