summaryrefslogtreecommitdiff
path: root/.vim/ftplugin/svn.vim
blob: 7b2e5c10ee63aa3f987d1f5e48c3191af6b7fec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
" made by Michael Scherer ( misc@mandrake.org )
" $Id: svn.vim 282 2005-01-31 21:24:55Z misc $
"
" 2004-09-13 : Lukas Ruf ( lukas.ruf@lpr.ch )
"   - re-ordered windows
"   - set focus on svn-commit.tmp (that's where one has to write)
"   - set buffer type of new window to 'nofile' to fix 'TODO'
"
" 2005-01-31 :
"   - autoclose on exit, thanks to Gintautas Miliauskas ( gintas@akl.lt )
"     and tips from Marius Gedminas ( mgedmin@b4net.lt )
"
" 2005-02-08 :
"   - rewrite in pure vim function, from Kyosuke Takayama ( support@mc.neweb.ne.jp )
"   - simplified installation instruction, from Marius Gedminas ( mgedmin@b4net.lt )
"
" 2005-02-11 :
"   - reindent with space, asked by Marius Gedminas ( mgedmin@b4net.lt )
"   - do not preview if no file are diffed, patch from Marius Gedminas.
"
" to use it, place it in ~/.vim/ftplugins ( create the directory if it doesn't exist )

function! Svn_diff_windows()
    let i = 0
    let list_of_files = ''

    while i <= line('$')
        let line = getline(i)
        if line =~ '^M'
            let file = substitute(line, '\v^MM?\s*(.*)\s*$', '\1', '')
            let list_of_files = list_of_files . ' '.file
	elseif line =~ '^A'
            let file = substitute(line, '\v^AM?\s*[+]*\s*(.*)\s*$', '\1', '')
            let list_of_files = list_of_files . ' '.file
	elseif line =~ '^D'
            let file = substitute(line, '\v^D\s*(.*)\s*$', '\1', '')
            let list_of_files = list_of_files . ' '.file
	endif

        let i = i + 1
    endwhile

    if list_of_files == ""
        return
    endif

    vnew
    silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
    exe 'normal :r!LANG=C svn diff ' . list_of_files . "\n"
    setlocal nomodifiable
    goto 1
    redraw!
    wincmd R
    wincmd p
    goto 1
    redraw!
endfunction

set nowarn

call Svn_diff_windows()
set nowb