annotate runtime/indent/postscr.vim @ 4289:52e946d654e0 v7.3.894

updated for version 7.3.894 Problem: Using wrong RUBY_VER causing Ruby build to break. Solution: Correct the RUBY_VER value. (Yongwei Wu)
author Bram Moolenaar <bram@vim.org>
date Mon, 15 Apr 2013 12:36:18 +0200
parents 3fc0f57ecb91
children 63b0b7b79b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " PostScript indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: PostScript
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Mike Williams <mrw@netcomuk.co.uk>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Last Change: 2nd July 2001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentexpr=PostscrIndentGet(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentkeys+=0],0=>>,0=%%,0=end,0=restore,0=grestore indentkeys-=:,0#,e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " Catch multiple instantiations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 if exists("*PostscrIndentGet")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 function! PostscrIndentGet(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " Find a non-empty non-comment line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " Note: ignores DSC comments as well!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let lnum = a:lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 while lnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let lnum = prevnonblank(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if getline(lnum) !~ '^\s*%.*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " Hit the start of the file, use user indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Start with the indent of the previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let pline = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " Indent for dicts, arrays, and saves with possible trailing comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if pline =~ '\(begin\|<<\|g\=save\|{\|[\)\s*\(%.*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " Remove indent for popped dicts, and restores.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if pline =~ '\(end\|g\=restore\)\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " Else handle immediate dedents of dicts, restores, and arrays.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 elseif getline(a:lnum) =~ '\(end\|>>\|g\=restore\|}\|]\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " Else handle DSC comments - always start of line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 elseif getline(a:lnum) =~ '^\s*%%'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " For now catch excessive left indents if they occur.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 if ind < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let ind = -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " vim:sw=2