|
1 | 1 | " made by Michael Scherer ( misc@mandrake.org ) |
2 | 2 | " $Id: svn.vim 282 2005-01-31 21:24:55Z misc $ |
3 | | -" TODO - rewrite in pure vim functions |
4 | 3 | " |
5 | 4 | " 2004-09-13 : Lukas Ruf ( lukas.ruf@lpr.ch ) |
6 | 5 | " - re-ordered windows |
|
10 | 9 | " 2005-01-31 : |
11 | 10 | " - autoclose on exit, thanks to Gintautas Miliauskas ( gintas@akl.lt ) |
12 | 11 | " and tips from Marius Gedminas ( mgedmin@b4net.lt ) |
13 | | -" |
14 | | -" to use it, place it in ~/.vim and add |
15 | | -" au BufRead svn-commit.tmp source ~/.vim/svn.vim |
16 | | -" to your .vimrc |
17 | | - |
| 12 | +" |
| 13 | +" 2005-02-08 : |
| 14 | +" - rewrite in pure vim function, from Kyosuke Takayama ( support@mc.neweb.ne.jp ) |
| 15 | +" - simplified installation instruction, from Marius Gedminas ( mgedmin@b4net.lt ) |
| 16 | +" |
| 17 | +" to use it, place it in ~/.vim/plugins ( create the directory if it doesn't exist ) |
18 | 18 |
|
19 | 19 | function! Svn_diff_windows() |
20 | | -python <<EOF |
21 | | -import vim |
22 | | -import re |
23 | | -svn_re=re.compile('^--This line, and those below, will be ignored--$') |
24 | | -modif_re=re.compile('^MM?\s*(.*)\s*$') |
25 | | -win=vim.windows[0] |
26 | | -svn_found=0 |
27 | | -list_of_files='' |
| 20 | + let i = 0 |
| 21 | + let list_of_files = '' |
28 | 22 |
|
29 | | -for b in win.buffer: |
30 | | - if svn_re.search(b): |
31 | | - svn_found=1 |
32 | | - if not svn_found: |
33 | | - continue |
34 | | - |
35 | | - if modif_re.search(b): |
36 | | - list_of_files=list_of_files+' '+modif_re.match(b).group(1) |
| 23 | + while i <= line('$') |
| 24 | + let line = getline(i) |
| 25 | + if line =~ '^M' |
37 | 26 |
|
38 | | -vim.command("new") |
39 | | -win.height=len(win.buffer)+2 |
40 | | -# use normal to remove annoying 'hit enter messages' |
41 | | -vim.command("normal :r!svn diff " + list_of_files + "\n") |
42 | | -vim.command("set previewwindow ft=diff") |
43 | | -vim.command("set buftype=nofile") |
44 | | -vim.command("wincmd p") |
45 | | -vim.command("wincmd R") |
46 | | -vim.command('goto 1') |
| 27 | + let file = substitute(line, '\v^MM?\s*(.*)\s*$', '\1', '') |
| 28 | + let list_of_files = list_of_files . ' '.file |
| 29 | + endif |
47 | 30 |
|
48 | | -EOF |
| 31 | + let i = i + 1 |
| 32 | + endwhile |
| 33 | + |
| 34 | + new |
| 35 | + silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile |
| 36 | + exe 'normal :r!LANG=C svn diff ' . list_of_files . "\n" |
| 37 | + setlocal nomodifiable |
| 38 | + goto 1 |
| 39 | + redraw! |
| 40 | + wincmd R |
| 41 | + wincmd p |
| 42 | + goto 1 |
| 43 | + redraw! |
49 | 44 | endfunction |
| 45 | + |
50 | 46 | set nowarn |
51 | 47 |
|
52 | 48 | call Svn_diff_windows() |
|
0 commit comments