annotate runtime/indent/postscr.vim @ 32365:da534deace14 v9.0.1514

patch 9.0.1514: test waits unnecessarily long before checking screendump Commit: https://github.com/vim/vim/commit/45fcb7928af8ac9bc5685ce7c804b8250866a874 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 6 13:01:27 2023 +0100 patch 9.0.1514: test waits unnecessarily long before checking screendump Problem: Test waits unnecessarily long before checking screendump. Solution: Remove TermWait() call.
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 May 2023 14:15:02 +0200
parents 57c9377b9c62
children
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
28933
57c9377b9c62 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
3 " Maintainer: Mike Williams <mrw@eandem.co.uk>
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
4 " Last Change: 2022 Apr 06
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
5
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 setlocal indentexpr=PostscrIndentGet(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentkeys+=0],0=>>,0=%%,0=end,0=restore,0=grestore indentkeys-=:,0#,e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
15 let b:undo_indent = "setl inde< indk<"
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
16
7
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