From 06d0d0563b6cee6b5291563c080daac155b83cb2 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 27 Jan 2014 16:55:23 +0000 Subject: [PATCH] Vim 7.4 won't let us quit windows from a script. The Perforce and Subversion commit and merge scripts want to quit when the commit message window has been closed, since the only other window shown really should be the diff. Vim 7.4's paranoia about scripts closing windows make quitting tricky... --- .vim/script/merge | 5 +++++ .vim/script/p4 | 6 ++++++ .vim/script/svn | 14 +++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.vim/script/merge b/.vim/script/merge index ad7c083..a00fea3 100644 --- a/.vim/script/merge +++ b/.vim/script/merge @@ -59,6 +59,11 @@ fun! P4merge() wincmd L se modifiable 1 + + try + au QuitPre * qa! + endtry + catch endfun " Expand the command line window so we don't have to press RETURN later. diff --git a/.vim/script/p4 b/.vim/script/p4 index 75dace6..7aa16ba 100644 --- a/.vim/script/p4 +++ b/.vim/script/p4 @@ -52,6 +52,12 @@ fun! P4submit() " Map q to quit easily. noremap 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 152d2c9..7b4da64 100644 --- a/.vim/script/svn +++ b/.vim/script/svn @@ -27,6 +27,12 @@ fun! SVNcommit() " Map q to quit easily. noremap 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 @@ -43,4 +49,10 @@ delfunction SVNcommit exe "se cmdheight=" . s:cmdheight " Close the scratch buffer. -au BufWinLeave qa! +if version >= 700 + " Vim 7 lets us close the buffer by number. The changelist is always in #1. + au BufWinLeave qa! +else + " Prior versions can only do it by name. Fall back to a temporary file. + au BufWinLeave /tmp/tmp.*.* qa! +endif -- 2.7.4