annotate src/testdir/test_modeline.vim @ 35162:860a5fb8eaf2 default tip

Added tag v9.1.0407 for changeset 08f7c9428f8224d6b24c60f4da1fd12c6354e852
author Christian Brabandt <cb@256bit.org>
date Sat, 11 May 2024 11:45:04 +0200
parents 2bfde43727e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for parsing the modeline.
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
3 source check.vim
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
4
14383
8846b8344430 patch 8.1.0206: duplicate test function name
Christian Brabandt <cb@256bit.org>
parents: 14381
diff changeset
5 func Test_modeline_invalid()
14989
85467d180844 patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents: 14387
diff changeset
6 " This was reading allocated memory in the past.
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
7 call writefile(['vi:0', 'nothing'], 'Xmodeline', 'D')
14989
85467d180844 patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents: 14387
diff changeset
8 let modeline = &modeline
85467d180844 patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents: 14387
diff changeset
9 set modeline
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call assert_fails('split Xmodeline', 'E518:')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
11
18908
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
12 " Missing end colon (ignored).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
13 call writefile(['// vim: set ts=2'], 'Xmodeline')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
14 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
15 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
16 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
17
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
18 " Missing colon at beginning (ignored).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
19 call writefile(['// vim set ts=2:'], 'Xmodeline')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
20 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
21 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
22 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
23
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
24 " Missing space after vim (ignored).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
25 call writefile(['// vim:ts=2:'], 'Xmodeline')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
26 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
27 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
28 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
29
14989
85467d180844 patch 8.1.0506: modeline test fails when run by root
Bram Moolenaar <Bram@vim.org>
parents: 14387
diff changeset
30 let &modeline = modeline
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 bwipe!
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 endfunc
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
33
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
34 func Test_modeline_filetype()
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
35 call writefile(['vim: set ft=c :', 'nothing'], 'Xmodeline_filetype', 'D')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
36 let modeline = &modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
37 set modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
38 filetype plugin on
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
39 split Xmodeline_filetype
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
40 call assert_equal("c", &filetype)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
41 call assert_equal(1, b:did_ftplugin)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
42 call assert_equal("ccomplete#Complete", &ofu)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
43
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
44 bwipe!
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
45 let &modeline = modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
46 filetype plugin off
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
47 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
48
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
49 func Test_modeline_syntax()
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
50 call writefile(['vim: set syn=c :', 'nothing'], 'Xmodeline_syntax', 'D')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
51 let modeline = &modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
52 set modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
53 syntax enable
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
54 split Xmodeline_syntax
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
55 call assert_equal("c", &syntax)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
56 call assert_equal("c", b:current_syntax)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
57
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
58 bwipe!
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
59 let &modeline = modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
60 syntax off
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
61 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
62
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
63 func Test_modeline_keymap()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
64 CheckFeature keymap
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
65 call writefile(['vim: set keymap=greek :', 'nothing'], 'Xmodeline_keymap', 'D')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
66 let modeline = &modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
67 set modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
68 split Xmodeline_keymap
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
69 call assert_equal("greek", &keymap)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
70 call assert_match('greek\|grk', b:keymap_name)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
71
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
72 bwipe!
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
73 let &modeline = modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
74 set keymap= iminsert=0 imsearch=-1
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
75 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
76
18908
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
77 func Test_modeline_version()
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
78 let modeline = &modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
79 set modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
80
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
81 " Test with vim:{vers}: (version {vers} or later).
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
82 call writefile(['// vim' .. v:version .. ': ts=2:'], 'Xmodeline_version', 'D')
18908
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
83 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
84 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
85 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
86
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
87 call writefile(['// vim' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
88 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
89 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
90 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
91
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
92 call writefile(['// vim' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
93 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
94 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
95 bw!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
96
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
97 " Test with vim>{vers}: (version after {vers}).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
98 call writefile(['// vim>' .. v:version .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
99 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
100 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
101 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
102
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
103 call writefile(['// vim>' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
104 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
105 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
106 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
107
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
108 call writefile(['// vim>' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
109 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
110 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
111 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
112
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
113 " Test with vim<{vers}: (version before {vers}).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
114 call writefile(['// vim<' .. v:version .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
115 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
116 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
117 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
118
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
119 call writefile(['// vim<' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
120 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
121 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
122 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
123
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
124 call writefile(['// vim<' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
125 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
126 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
127 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
128
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
129 " Test with vim={vers}: (version {vers} only).
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
130 call writefile(['// vim=' .. v:version .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
131 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
132 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
133 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
134
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
135 call writefile(['// vim=' .. (v:version - 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
136 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
137 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
138 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
139
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
140 call writefile(['// vim=' .. (v:version + 100) .. ': ts=2:'], 'Xmodeline_version')
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
141 edit Xmodeline_version
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
142 call assert_equal(8, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
143 bwipe!
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
144
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
145 let &modeline = modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
146 endfunc
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
147
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
148 func Test_modeline_colon()
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
149 let modeline = &modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
150 set modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
151
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
152 call writefile(['// vim: set showbreak=\: ts=2: sw=2'], 'Xmodeline_colon', 'D')
18908
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
153 edit Xmodeline_colon
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
154
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
155 " backlash colon should become colon.
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
156 call assert_equal(':', &showbreak)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
157
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
158 " 'ts' should be set.
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
159 " 'sw' should be ignored because it is after the end colon.
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
160 call assert_equal(2, &ts)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
161 call assert_equal(8, &sw)
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
162
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
163 let &modeline = modeline
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
164 endfunc
61fa1a9d09dd patch 8.2.0015: not all modeline variants are tested
Bram Moolenaar <Bram@vim.org>
parents: 16798
diff changeset
165
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
166 func s:modeline_fails(what, text, error)
33727
2bfde43727e9 patch 9.0.2093: Unsupported option causes skipping of modeline test
Christian Brabandt <cb@256bit.org>
parents: 30582
diff changeset
167 " Don't use CheckOption(), it would skip the whole test
2bfde43727e9 patch 9.0.2093: Unsupported option causes skipping of modeline test
Christian Brabandt <cb@256bit.org>
parents: 30582
diff changeset
168 " just for a single un-supported option
2bfde43727e9 patch 9.0.2093: Unsupported option causes skipping of modeline test
Christian Brabandt <cb@256bit.org>
parents: 30582
diff changeset
169 if !exists('+' .. a:what)
2bfde43727e9 patch 9.0.2093: Unsupported option causes skipping of modeline test
Christian Brabandt <cb@256bit.org>
parents: 30582
diff changeset
170 return
2bfde43727e9 patch 9.0.2093: Unsupported option causes skipping of modeline test
Christian Brabandt <cb@256bit.org>
parents: 30582
diff changeset
171 endif
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
172 let fname = "Xmodeline_fails_" . a:what
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
173 call writefile(['vim: set ' . a:text . ' :', 'nothing'], fname, 'D')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
174 let modeline = &modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
175 set modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
176 filetype plugin on
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
177 syntax enable
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
178 call assert_fails('split ' . fname, a:error)
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
179 call assert_equal("", &filetype)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
180 call assert_equal("", &syntax)
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
181
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
182 bwipe!
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
183 let &modeline = modeline
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
184 filetype plugin off
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
185 syntax off
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
186 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
187
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
188 func Test_modeline_filetype_fails()
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
189 call s:modeline_fails('filetype', 'ft=evil$CMD', 'E474:')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
190 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
191
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
192 func Test_modeline_syntax_fails()
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
193 call s:modeline_fails('syntax', 'syn=evil$CMD', 'E474:')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
194 endfunc
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
195
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
196 func Test_modeline_keymap_fails()
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
197 call s:modeline_fails('keymap', 'keymap=evil$CMD', 'E474:')
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 14989
diff changeset
198 endfunc
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
199
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
200 func Test_modeline_fails_always()
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
201 call s:modeline_fails('backupdir', 'backupdir=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
202 call s:modeline_fails('cdpath', 'cdpath=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
203 call s:modeline_fails('charconvert', 'charconvert=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
204 call s:modeline_fails('completefunc', 'completefunc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
205 call s:modeline_fails('cscopeprg', 'cscopeprg=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
206 call s:modeline_fails('diffexpr', 'diffexpr=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
207 call s:modeline_fails('directory', 'directory=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
208 call s:modeline_fails('equalprg', 'equalprg=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
209 call s:modeline_fails('errorfile', 'errorfile=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
210 call s:modeline_fails('exrc', 'exrc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
211 call s:modeline_fails('formatprg', 'formatprg=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
212 call s:modeline_fails('fsync', 'fsync=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
213 call s:modeline_fails('grepprg', 'grepprg=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
214 call s:modeline_fails('helpfile', 'helpfile=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
215 call s:modeline_fails('imactivatefunc', 'imactivatefunc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
216 call s:modeline_fails('imstatusfunc', 'imstatusfunc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
217 call s:modeline_fails('imstyle', 'imstyle=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
218 call s:modeline_fails('keywordprg', 'keywordprg=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
219 call s:modeline_fails('langmap', 'langmap=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
220 call s:modeline_fails('luadll', 'luadll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
221 call s:modeline_fails('makeef', 'makeef=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
222 call s:modeline_fails('makeprg', 'makeprg=Something()', 'E520:')
16798
63ac51f16ea1 patch 8.1.1401: misspelled mkspellmem as makespellmem
Bram Moolenaar <Bram@vim.org>
parents: 16732
diff changeset
223 call s:modeline_fails('mkspellmem', 'mkspellmem=Something()', 'E520:')
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
224 call s:modeline_fails('mzschemedll', 'mzschemedll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
225 call s:modeline_fails('mzschemegcdll', 'mzschemegcdll=Something()', 'E520:')
16730
000350f8e4d1 patch 8.1.1367: can set 'modelineexpr' in modeline
Bram Moolenaar <Bram@vim.org>
parents: 16728
diff changeset
226 call s:modeline_fails('modelineexpr', 'modelineexpr', 'E520:')
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
227 call s:modeline_fails('omnifunc', 'omnifunc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
228 call s:modeline_fails('operatorfunc', 'operatorfunc=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
229 call s:modeline_fails('perldll', 'perldll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
230 call s:modeline_fails('printdevice', 'printdevice=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
231 call s:modeline_fails('patchexpr', 'patchexpr=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
232 call s:modeline_fails('printexpr', 'printexpr=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
233 call s:modeline_fails('pythondll', 'pythondll=Something()', 'E520:')
16732
6411f8ef550d patch 8.1.1368: modeline test fails with python but without pythonhome
Bram Moolenaar <Bram@vim.org>
parents: 16730
diff changeset
234 call s:modeline_fails('pythonhome', 'pythonhome=Something()', 'E520:')
16728
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
235 call s:modeline_fails('pythonthreedll', 'pythonthreedll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
236 call s:modeline_fails('pythonthreehome', 'pythonthreehome=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
237 call s:modeline_fails('pyxversion', 'pyxversion=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
238 call s:modeline_fails('rubydll', 'rubydll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
239 call s:modeline_fails('runtimepath', 'runtimepath=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
240 call s:modeline_fails('secure', 'secure=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
241 call s:modeline_fails('shell', 'shell=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
242 call s:modeline_fails('shellcmdflag', 'shellcmdflag=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
243 call s:modeline_fails('shellpipe', 'shellpipe=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
244 call s:modeline_fails('shellquote', 'shellquote=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
245 call s:modeline_fails('shellredir', 'shellredir=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
246 call s:modeline_fails('shellxquote', 'shellxquote=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
247 call s:modeline_fails('spellfile', 'spellfile=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
248 call s:modeline_fails('spellsuggest', 'spellsuggest=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
249 call s:modeline_fails('tcldll', 'tcldll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
250 call s:modeline_fails('titleold', 'titleold=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
251 call s:modeline_fails('viewdir', 'viewdir=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
252 call s:modeline_fails('viminfo', 'viminfo=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
253 call s:modeline_fails('viminfofile', 'viminfofile=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
254 call s:modeline_fails('winptydll', 'winptydll=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
255 call s:modeline_fails('undodir', 'undodir=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
256 " only check a few terminal options
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
257 call s:modeline_fails('t_AB', 't_AB=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
258 call s:modeline_fails('t_ce', 't_ce=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
259 call s:modeline_fails('t_sr', 't_sr=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
260 call s:modeline_fails('t_8b', 't_8b=Something()', 'E520:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
261 endfunc
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
262
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
263 func Test_modeline_fails_modelineexpr()
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
264 call s:modeline_fails('balloonexpr', 'balloonexpr=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
265 call s:modeline_fails('foldexpr', 'foldexpr=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
266 call s:modeline_fails('foldtext', 'foldtext=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
267 call s:modeline_fails('formatexpr', 'formatexpr=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
268 call s:modeline_fails('guitablabel', 'guitablabel=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
269 call s:modeline_fails('iconstring', 'iconstring=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
270 call s:modeline_fails('includeexpr', 'includeexpr=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
271 call s:modeline_fails('indentexpr', 'indentexpr=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
272 call s:modeline_fails('rulerformat', 'rulerformat=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
273 call s:modeline_fails('statusline', 'statusline=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
274 call s:modeline_fails('tabline', 'tabline=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
275 call s:modeline_fails('titlestring', 'titlestring=Something()', 'E992:')
e55c26aaf484 patch 8.1.1366: using expressions in a modeline is unsafe
Bram Moolenaar <Bram@vim.org>
parents: 15073
diff changeset
276 endfunc
20269
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
277
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
278 func Test_modeline_setoption_verbose()
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
279 let modeline = &modeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
280 set modeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
281
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
282 let lines =<< trim END
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
283 1 vim:ts=2
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
284 2 two
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
285 3 three
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
286 4 four
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
287 5 five
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
288 6 six
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
289 7 seven
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
290 8 eight
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
291 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
292 call writefile(lines, 'Xmodeline', 'D')
20269
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
293 edit Xmodeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
294 let info = split(execute('verbose set tabstop?'), "\n")
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
295 call assert_match('^\s*Last set from modeline line 1$', info[-1])
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
296 bwipe!
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
297
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
298 let lines =<< trim END
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
299 1 one
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
300 2 two
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
301 3 three
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
302 4 vim:ts=4
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
303 5 five
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
304 6 six
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
305 7 seven
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
306 8 eight
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
307 END
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
308 call writefile(lines, 'Xmodeline')
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
309 edit Xmodeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
310 let info = split(execute('verbose set tabstop?'), "\n")
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
311 call assert_match('^\s*Last set from modeline line 4$', info[-1])
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
312 bwipe!
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
313
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
314 let lines =<< trim END
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
315 1 one
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
316 2 two
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
317 3 three
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
318 4 four
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
319 5 five
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
320 6 six
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
321 7 seven
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
322 8 vim:ts=8
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
323 END
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
324 call writefile(lines, 'Xmodeline')
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
325 edit Xmodeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
326 let info = split(execute('verbose set tabstop?'), "\n")
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
327 call assert_match('^\s*Last set from modeline line 8$', info[-1])
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
328 bwipe!
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
329
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
330 let &modeline = modeline
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 18908
diff changeset
331 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
332
24914
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
333 " Test for the 'modeline' default value in compatible and non-compatible modes
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
334 " for root and non-root accounts
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
335 func Test_modeline_default()
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
336 set compatible
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
337 call assert_false(&modeline)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
338 set nocompatible
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
339 call assert_equal(IsRoot() ? 0 : 1, &modeline)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
340 set compatible&vi
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
341 call assert_false(&modeline)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
342 set compatible&vim
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
343 call assert_equal(IsRoot() ? 0 : 1, &modeline)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
344 set compatible& modeline&
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
345 endfunc
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
346
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
347 " Some options cannot be set from the modeline when 'diff' option is set
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
348 func Test_modeline_diff_buffer()
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
349 call writefile(['vim: diff foldmethod=marker wrap'], 'Xmdifile', 'D')
24914
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
350 set foldmethod& nowrap
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 25696
diff changeset
351 new Xmdifile
24914
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
352 call assert_equal('manual', &foldmethod)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
353 call assert_false(&wrap)
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
354 set wrap&
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
355 bw
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
356 endfunc
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
357
25696
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
358 func Test_modeline_disable()
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
359 set modeline
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
360 call writefile(['vim: sw=2', 'vim: nomodeline', 'vim: sw=3'], 'Xmodeline_disable', 'D')
25696
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
361 edit Xmodeline_disable
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
362 call assert_equal(2, &sw)
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
363 endfunc
64fa341cc33b patch 8.2.3384: cannot disable modeline for an individual file
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
364
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
365 " vim: shiftwidth=2 sts=2 expandtab