annotate runtime/indent/postscr.vim @ 9169:0ea97a753a2d v7.4.1868

commit https://github.com/vim/vim/commit/b89a25f17e274dc308c584ea69a129ffbb26bc3d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 1 23:08:39 2016 +0200 patch 7.4.1868 Problem: Setting really_exiting causes memory leaks to be reported. Solution: Add the in_free_all_mem flag.
author Christian Brabandt <cb@256bit.org>
date Wed, 01 Jun 2016 23:15:06 +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