X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.vim%2Fscript%2Fp4;h=f599b3fa66d4262f688dced9505ab5d837d334d8;hb=cf5f78bd9314e698743b785236369e245473e3f0;hp=f7cabe5793dbb9d120db4f539faa039ad724a6e2;hpb=bc811c4ff356d27ed2d16eac2c8c16afd034510e;p=profile.git diff --git a/.vim/script/p4 b/.vim/script/p4 index f7cabe5..f599b3f 100644 --- a/.vim/script/p4 +++ b/.vim/script/p4 @@ -5,22 +5,30 @@ fun! P4submit() " There's no point doing this if the spec is readonly. That probably means " it's a submitted change. if ! &ro + setf perforce + " Clear the unnamed register. let @" = "" try " Delete the spec blurb if it exists. - /^# A Perforce Change Spec/,/^$/d + /^# A Perforce Change Spec/,/^# *(New changelists only\.)$/d " If the blurb was deleted the text will be in the unnamed register. - if @" != "" + if @" != "grgergregergeg" + " Delete the blank line left above the remaining fields. + 1 + delete + " Allow closing an unmodified spec. set nomod " Get the files in the changelist. - let l:files = system("sed -n 's/ #.*//p' " . bufname("")) - + let l:files = system("sed -n 's@^ \\(//.*\\) #.*@\\1@p' " . bufname("")) " Create a new window, move it below the spec and read in a diff. botright new - exe "r!env P4DIFF= p4 diff -du " . substitute(l:files, "\n", "", "g") + if l:files != "" + exe "r!env P4DIFF= p4 diff -du " . substitute(l:files, "\n", " ", "g") + endif + setf diff " Delete the blank line left above the diff.