Guest User

Untitled

a guest
Mar 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. " C-c K to commit files with diff and status
  2. " C-c k to commit files with empty buffer (faster)
  3.  
  4. fun! SVK_FastCommit(size,diff,status)
  5. let file = tempname()
  6. exec a:size . 'split ' . file
  7. if a:diff
  8. call append(0, "==== DiffEND =====================================================")
  9. silent exec "0r !svk diff lib/"
  10. call append(0, "")
  11. call append(0, "==== Diff ========================================================")
  12. call append(0, "")
  13. endif
  14. if a:status
  15. silent exec "0r !svk status | grep -v '^?' "
  16. call append(0, "")
  17. call append(0, "==== Status ======================================================")
  18. endif
  19. call append(0,"")
  20. call cursor(1,1)
  21.  
  22. setlocal modifiable
  23. setlocal noswapfile
  24. setlocal bufhidden=hide
  25. setlocal nobuflisted
  26. setlocal nowrap
  27. setlocal cursorline
  28. setlocal number
  29. setlocal fdc=0
  30.  
  31. setfiletype svk-fast-commit
  32. setlocal syntax=svk-fast-commit
  33.  
  34. syn match hr +^====.*$+
  35. syn match add "^+.*$"
  36. syn match del "^-.*$"
  37. hi link hr Identifier
  38. hi add ctermfg=red
  39. hi del ctermfg=Magenta
  40.  
  41. exec 'autocmd BufWritePost <buffer> :call SVK_DoCommit("'. file .'")'
  42. autocmd BufWinLeave <buffer> :bw!
  43. " startinsert
  44. endf
  45.  
  46. fun! SVK_DoCommit(file)
  47. call s:FilterFile(a:file)
  48. call system("svk ci -F " . a:file . " &" )
  49. endf
  50.  
  51. fun! s:FilterFile(file)
  52. let lines = readfile(a:file)
  53. let newl = [ ]
  54. for l in lines
  55. if l =~ "^===="
  56. break
  57. endif
  58. call add(newl , l)
  59. endfor
  60. call writefile(newl,a:file)
  61. endf
  62. nmap <silent> <c-c>k :call SVK_FastCommit(8,0,0)<CR>
  63. nmap <silent> <c-c>K :call SVK_FastCommit(30,1,1)<CR>
Add Comment
Please, Sign In to add comment