annotate runtime/indent/postscr.vim @ 26404:1bbb884c8561 v8.2.3733

patch 8.2.3733: Vim9: using "legacy" before range does not work Commit: https://github.com/vim/vim/commit/b579f6ebbfa826d228abec1e1b24c05894517c27 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 4 11:57:00 2021 +0000 patch 8.2.3733: Vim9: using "legacy" before range does not work Problem: Vim9: using "legacy" before range does not work. Solution: Skip over range before parsing command. (closes https://github.com/vim/vim/issues/9270)
author Bram Moolenaar <Bram@vim.org>
date Sat, 04 Dec 2021 13:00:05 +0100
parents 9c221ad9634a
children 6dd88e45d47d
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
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
2 " Language: PostScript
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
3 " Maintainer: Mike Williams <mrw@netcomuk.co.uk> (Invalid email address)
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
5 " Last Change: 2nd July 2001
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentexpr=PostscrIndentGet(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentkeys+=0],0=>>,0=%%,0=end,0=restore,0=grestore indentkeys-=:,0#,e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " Catch multiple instantiations
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*PostscrIndentGet")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 function! PostscrIndentGet(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " Find a non-empty non-comment line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " Note: ignores DSC comments as well!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let lnum = a:lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 while lnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let lnum = prevnonblank(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if getline(lnum) !~ '^\s*%.*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " Hit the start of the file, use user indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " Start with the indent of the previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let pline = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Indent for dicts, arrays, and saves with possible trailing comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 if pline =~ '\(begin\|<<\|g\=save\|{\|[\)\s*\(%.*\)\=$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
45 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Remove indent for popped dicts, and restores.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 if pline =~ '\(end\|g\=restore\)\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
50 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " Else handle immediate dedents of dicts, restores, and arrays.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 elseif getline(a:lnum) =~ '\(end\|>>\|g\=restore\|}\|]\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
54 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " Else handle DSC comments - always start of line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 elseif getline(a:lnum) =~ '^\s*%%'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " For now catch excessive left indents if they occur.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 if ind < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 let ind = -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " vim:sw=2