1 " $Id$ vim: set 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.
5 " There's no point doing this if the spec is readonly. That probably means
6 " it's a submitted change.
8 " Clear the unnamed register.
11 " Delete the spec blurb if it exists.
12 /^# A Perforce Change Spec/,/^$/d
13 " If the blurb was deleted the text will be in the unnamed register.
15 " Allow closing an unmodified spec.
18 " Create a new window, move it below the spec and read in a diff.
23 " Delete the blank line left above the diff.
31 " Switch back to the top window and put the cursor by the description.
35 ?<enter description here>
39 " We get here if no blurb was deleted. This is the case if we aren't
45 " Expand the command line window so we don't have to press RETURN later.
46 let s:cmdheight = &cmdheight
49 " Call and then discard our function.
52 " Don't expand tabs in the spec.
55 " Restore the command window.
56 exe "set cmdheight=" . s:cmdheight
58 " Close the scratch buffer.
60 " Vim 7 lets us close the buffer by number. The changelist is always in #1.
61 au BufWinLeave <buffer=1> qa!
63 " Prior versions can only do it by name. Fall back to a temporary file.
64 au BufWinLeave /tmp/tmp.*.* qa!