c927fe41828efb3f5725cb304fa2f2bf77ceeb79
[profile.git] / .vim / script / svn
1 " $Id$ vim: se syntax=vim:
2 " Define the function we'll use.  It's easier to do this than to faff about 
3 " trying to run a sequence of normal mode commands.
4 fun! SVNcommit()
5   " Allow closing an unmodified spec.
6   set nomod
7
8   " Get the modified files.  Discount new files.
9   let l:files = system("sed -n '1,/^$/d;s/^[MR]....//p' " . bufname(""))
10
11   if l:files == ""
12     return
13   endif
14
15   " Create a new window, move it below the spec and read in a diff.
16   botright new
17   exe "r!svn diff " . substitute(l:files, "\n", " ", "g")
18   setf diff
19
20   " Delete the blank line left above the diff.
21   1
22   delete
23   se nobuflisted
24   set buftype=nowrite
25   set bufhidden=hide
26   setlocal noswapfile
27   file [svn diff]
28
29   " Switch back to the top window.
30   wincmd k
31 endfun
32
33 " Expand the command line window so we don't have to press RETURN later.
34 let s:cmdheight = &cmdheight
35 se cmdheight=3
36
37 " Call and then discard our function.
38 call SVNcommit()
39 delfunction SVNcommit
40
41 " Restore the command window.
42 exe "se cmdheight=" . s:cmdheight
43
44 " Close the scratch buffer.
45 au BufWinLeave <buffer=1> qa!