Mercurial > vim
annotate runtime/doc/if_mzsch.txt @ 19826:293a22b677a8 v8.2.0469
patch 8.2.0469: Vim9: no error for missing ] after list
Commit: https://github.com/vim/vim/commit/ee619e5bc0992e818f2d9540b093b769b9c27651
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 28 21:38:06 2020 +0100
patch 8.2.0469: Vim9: no error for missing ] after list
Problem: Vim9: no error for missing ] after list.
Solution: Add error message. Add more tests.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 28 Mar 2020 21:45:06 +0100 |
parents | af69c9335223 |
children | 04ef2ccf2519 |
rev | line source |
---|---|
18879 | 1 *if_mzsch.txt* For Vim version 8.2. Last change: 2019 Dec 07 |
14 | 2 |
3 | |
4 VIM REFERENCE MANUAL by Sergey Khorev | |
5 | |
6 | |
7 The MzScheme Interface to Vim *mzscheme* *MzScheme* | |
8 | |
9 1. Commands |mzscheme-commands| | |
10 2. Examples |mzscheme-examples| | |
11 3. Threads |mzscheme-threads| | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
12 4. Vim access from MzScheme |mzscheme-vim| |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
13 5. mzeval() Vim function |mzscheme-mzeval| |
4074 | 14 6. Using Function references |mzscheme-funcref| |
15 7. Dynamic loading |mzscheme-dynamic| | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
16 8. MzScheme setup |mzscheme-setup| |
14 | 17 |
16553
0e473e9e70c2
patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
18 {only available when Vim was compiled with the |+mzscheme| feature} |
14 | 19 |
20 Based on the work of Brent Fulgham. | |
128 | 21 Dynamic loading added by Sergey Khorev |
14 | 22 |
4074 | 23 MzScheme and PLT Scheme names have been rebranded as Racket. For more |
24 information please check http://racket-lang.org | |
14 | 25 |
4074 | 26 Futures and places of Racket version 5.x up to and including 5.3.1 do not |
27 work correctly with processes created by Vim. | |
28 The simplest solution is to build Racket on your own with these features | |
29 disabled: > | |
30 ./configure --disable-futures --disable-places --prefix=your-install-prefix | |
31 | |
32 To speed up the process, you might also want to use --disable-gracket and | |
33 --disable-docs | |
1121 | 34 |
14 | 35 ============================================================================== |
36 1. Commands *mzscheme-commands* | |
37 | |
38 *:mzscheme* *:mz* | |
39 :[range]mz[scheme] {stmt} | |
16553
0e473e9e70c2
patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
40 Execute MzScheme statement {stmt}. |
14 | 41 |
17571 | 42 :[range]mz[scheme] << [endmarker] |
14 | 43 {script} |
44 {endmarker} | |
45 Execute inlined MzScheme script {script}. | |
46 Note: This command doesn't work if the MzScheme | |
47 feature wasn't compiled in. To avoid errors, see | |
48 |script-here|. | |
49 | |
17571 | 50 The {endmarker} below the {script} must NOT be |
51 preceded by any white space. | |
52 | |
53 If [endmarker] is omitted from after the "<<", a dot | |
54 '.' must be used after {script}, like for the | |
55 |:append| and |:insert| commands. | |
56 | |
14 | 57 *:mzfile* *:mzf* |
16553
0e473e9e70c2
patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents:
14421
diff
changeset
|
58 :[range]mzf[ile] {file} Execute the MzScheme script in {file}. |
14 | 59 |
60 All of these commands do essentially the same thing - they execute a piece of | |
61 MzScheme code, with the "current range" set to the given line | |
62 range. | |
63 | |
64 In the case of :mzscheme, the code to execute is in the command-line. | |
65 In the case of :mzfile, the code to execute is the contents of the given file. | |
66 | |
67 MzScheme interface defines exception exn:vim, derived from exn. | |
68 It is raised for various Vim errors. | |
69 | |
70 During compilation, the MzScheme interface will remember the current MzScheme | |
71 collection path. If you want to specify additional paths use the | |
72 'current-library-collection-paths' parameter. E.g., to cons the user-local | |
73 MzScheme collection path: > | |
74 :mz << EOF | |
75 (current-library-collection-paths | |
76 (cons | |
77 (build-path (find-system-path 'addon-dir) (version) "collects") | |
78 (current-library-collection-paths))) | |
79 EOF | |
80 < | |
81 | |
82 All functionality is provided through module vimext. | |
83 | |
84 The exn:vim is available without explicit import. | |
85 | |
86 To avoid clashes with MzScheme, consider using prefix when requiring module, | |
87 e.g.: > | |
88 :mzscheme (require (prefix vim- vimext)) | |
89 < | |
18831 | 90 All the examples below assume this naming scheme. |
14 | 91 |
273 | 92 *mzscheme-sandbox* |
93 When executed in the |sandbox|, access to some filesystem and Vim interface | |
94 procedures is restricted. | |
14 | 95 |
96 ============================================================================== | |
97 2. Examples *mzscheme-examples* | |
98 > | |
99 :mzscheme (display "Hello") | |
1894 | 100 :mz (display (string-append "Using MzScheme version " (version))) |
101 :mzscheme (require (prefix vim- vimext)) ; for MzScheme < 4.x | |
102 :mzscheme (require (prefix-in vim- 'vimext)) ; MzScheme 4.x | |
14 | 103 :mzscheme (vim-set-buff-line 10 "This is line #10") |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
7742
diff
changeset
|
104 |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
7742
diff
changeset
|
105 To see what version of MzScheme you have: > |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
7742
diff
changeset
|
106 :mzscheme (display (version)) |
14 | 107 < |
108 Inline script usage: > | |
109 function! <SID>SetFirstLine() | |
110 :mz << EOF | |
111 (display "!!!") | |
1894 | 112 (require (prefix vim- vimext)) |
113 ; for newer versions (require (prefix-in vim- 'vimext)) | |
14 | 114 (vim-set-buff-line 1 "This is line #1") |
115 (vim-beep) | |
1894 | 116 EOF |
14 | 117 endfunction |
118 | |
119 nmap <F9> :call <SID>SetFirstLine() <CR> | |
120 < | |
121 File execution: > | |
122 :mzfile supascript.scm | |
123 < | |
1894 | 124 Vim exception handling: > |
125 :mz << EOF | |
126 (require (prefix vim- vimext)) | |
127 ; for newer versions (require (prefix-in vim- 'vimext)) | |
128 (with-handlers | |
129 ([exn:vim? (lambda (e) (display (exn-message e)))]) | |
130 (vim-eval "nonsense-string")) | |
131 EOF | |
14 | 132 < |
1894 | 133 Auto-instantiation of vimext module (can be placed in your |vimrc|): > |
134 function! MzRequire() | |
135 :redir => l:mzversion | |
136 :mz (version) | |
137 :redir END | |
138 if strpart(l:mzversion, 1, 1) < "4" | |
139 " MzScheme versions < 4.x: | |
140 :mz (require (prefix vim- vimext)) | |
141 else | |
142 " newer versions: | |
143 :mz (require (prefix-in vim- 'vimext)) | |
144 endif | |
145 endfunction | |
14 | 146 |
1894 | 147 if has("mzscheme") |
148 silent call MzRequire() | |
149 endif | |
150 < | |
14 | 151 ============================================================================== |
152 3. Threads *mzscheme-threads* | |
153 | |
154 The MzScheme interface supports threads. They are independent from OS threads, | |
155 thus scheduling is required. The option 'mzquantum' determines how often | |
156 Vim should poll for available MzScheme threads. | |
157 NOTE | |
158 Thread scheduling in the console version of Vim is less reliable than in the | |
159 GUI version. | |
160 | |
161 ============================================================================== | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
162 4. Vim access from MzScheme *mzscheme-vim* |
14 | 163 |
164 *mzscheme-vimext* | |
165 The 'vimext' module provides access to procedures defined in the MzScheme | |
166 interface. | |
167 | |
168 Common | |
169 ------ | |
170 (command {command-string}) Perform the vim ":Ex" style command. | |
1894 | 171 (eval {expr-string}) Evaluate the vim expression into |
172 respective MzScheme object: |Lists| are | |
173 represented as Scheme lists, | |
4074 | 174 |Dictionaries| as hash tables, |
175 |Funcref|s as functions (see also | |
176 |mzscheme-funcref|) | |
177 NOTE the name clashes with MzScheme eval, | |
178 use module qualifiers to overcome this. | |
14 | 179 (range-start) Start/End of the range passed with |
180 (range-end) the Scheme command. | |
181 (beep) beep | |
182 (get-option {option-name} [buffer-or-window]) Get Vim option value (either | |
183 local or global, see set-option). | |
184 (set-option {string} [buffer-or-window]) | |
185 Set a Vim option. String must have option | |
186 setting form (like optname=optval, or | |
187 optname+=optval, etc.) When called with | |
188 {buffer} or {window} the local option will | |
189 be set. The symbol 'global can be passed | |
190 as {buffer-or-window}. Then |:setglobal| | |
191 will be used. | |
192 | |
193 Buffers *mzscheme-buffer* | |
194 ------- | |
195 (buff? {object}) Is object a buffer? | |
196 (buff-valid? {object}) Is object a valid buffer? (i.e. | |
197 corresponds to the real Vim buffer) | |
198 (get-buff-line {linenr} [buffer]) | |
199 Get line from a buffer. | |
200 (set-buff-line {linenr} {string} [buffer]) | |
201 Set a line in a buffer. If {string} is #f, | |
202 the line gets deleted. The [buffer] | |
856 | 203 argument is optional. If omitted, the |
204 current buffer will be used. | |
14 | 205 (get-buff-line-list {start} {end} [buffer]) |
206 Get a list of lines in a buffer. {Start} | |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
2050
diff
changeset
|
207 and {end} are 1-based and inclusive. |
14 | 208 (set-buff-line-list {start} {end} {string-list} [buffer]) |
209 Set a list of lines in a buffer. If | |
210 string-list is #f or null, the lines get | |
211 deleted. If a list is shorter than | |
212 {end}-{start} the remaining lines will | |
213 be deleted. | |
214 (get-buff-name [buffer]) Get a buffer's text name. | |
215 (get-buff-num [buffer]) Get a buffer's number. | |
216 (get-buff-size [buffer]) Get buffer line count. | |
217 (insert-buff-line-list {linenr} {string/string-list} [buffer]) | |
218 Insert a list of lines into a buffer after | |
219 {linenr}. If {linenr} is 0, lines will be | |
220 inserted at start. | |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
2050
diff
changeset
|
221 (curr-buff) Get the current buffer. Use other MzScheme |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
2050
diff
changeset
|
222 interface procedures to change it. |
14 | 223 (buff-count) Get count of total buffers in the editor. |
224 (get-next-buff [buffer]) Get next buffer. | |
225 (get-prev-buff [buffer]) Get previous buffer. Return #f when there | |
226 are no more buffers. | |
227 (open-buff {filename}) Open a new buffer (for file "name") | |
228 (get-buff-by-name {buffername}) Get a buffer by its filename or #f | |
229 if there is no such buffer. | |
230 (get-buff-by-num {buffernum}) Get a buffer by its number (return #f if | |
231 there is no buffer with this number). | |
232 | |
233 Windows *mzscheme-window* | |
234 ------ | |
235 (win? {object}) Is object a window? | |
236 (win-valid? {object}) Is object a valid window (i.e. corresponds | |
237 to the real Vim window)? | |
238 (curr-win) Get the current window. | |
239 (win-count) Get count of windows. | |
240 (get-win-num [window]) Get window number. | |
241 (get-win-by-num {windownum}) Get window by its number. | |
242 (get-win-buffer [window]) Get the buffer for a given window. | |
243 (get-win-height [window]) | |
244 (set-win-height {height} [window]) Get/Set height of window. | |
245 (get-win-width [window]) | |
246 (set-win-width {width} [window])Get/Set width of window. | |
247 (get-win-list [buffer]) Get list of windows for a buffer. | |
248 (get-cursor [window]) Get cursor position in a window as | |
249 a pair (linenr . column). | |
250 (set-cursor (line . col) [window]) Set cursor position. | |
251 | |
625 | 252 ============================================================================== |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
253 5. mzeval() Vim function *mzscheme-mzeval* |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
254 |
2249
6d3d35ff2c2b
Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
255 To facilitate bi-directional interface, you can use |mzeval()| function to |
10942
e05695e59f6d
patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
256 evaluate MzScheme expressions and pass their values to Vim script. |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
257 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
1919
diff
changeset
|
258 ============================================================================== |
4074 | 259 6. Using Function references *mzscheme-funcref* |
260 | |
261 MzScheme interface allows use of |Funcref|s so you can call Vim functions | |
262 directly from Scheme. For instance: > | |
263 function! MyAdd2(arg) | |
264 return a:arg + 2 | |
265 endfunction | |
266 mz (define f2 (vim-eval "function(\"MyAdd2\")")) | |
267 mz (f2 7) | |
268 < or : > | |
269 :mz (define indent (vim-eval "function('indent')")) | |
270 " return Vim indent for line 12 | |
271 :mz (indent 12) | |
272 < | |
273 | |
274 ============================================================================== | |
7742
5f6f35a3cb12
commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents:
7659
diff
changeset
|
275 7. Dynamic loading *mzscheme-dynamic* *E815* |
625 | 276 |
277 On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version| | |
278 output then includes |+mzscheme/dyn|. | |
279 | |
280 This means that Vim will search for the MzScheme DLL files only when needed. | |
281 When you don't use the MzScheme interface you don't need them, thus you can | |
282 use Vim without these DLL files. | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
283 NOTE: Newer version of MzScheme (Racket) require earlier (trampolined) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
284 initialisation via scheme_main_setup. So Vim always loads the MzScheme DLL at |
12608
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
285 startup if possible. This may make Vim startup slower. |
625 | 286 |
287 To use the MzScheme interface the MzScheme DLLs must be in your search path. | |
288 In a console window type "path" to see what directories are used. | |
289 | |
12608
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
290 On MS-Windows the options 'mzschemedll' and 'mzschemegcdll' are used for the |
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
291 name of the library to load. The initial value is specified at build time. |
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
292 |
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
293 The version of the DLL must match the MzScheme version Vim was compiled with. |
625 | 294 For MzScheme version 209 they will be "libmzsch209_000.dll" and |
1121 | 295 "libmzgc209_000.dll". To know for sure look at the output of the ":version" |
296 command, look for -DDYNAMIC_MZSCH_DLL="something" and | |
297 -DDYNAMIC_MZGC_DLL="something" in the "Compilation" info. | |
625 | 298 |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
299 For example, if MzScheme (Racket) is installed at C:\Racket63, you may need |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
300 to set the environment variable as the following: > |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
301 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
302 PATH=%PATH%;C:\Racket63\lib |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
303 PLTCOLLECTS=C:\Racket63\collects |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
304 PLTCONFIGDIR=C:\Racket63\etc |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
305 < |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
306 ============================================================================== |
7742
5f6f35a3cb12
commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents:
7659
diff
changeset
|
307 8. MzScheme setup *mzscheme-setup* *E895* |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
308 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
309 Vim requires "racket/base" module for if_mzsch core (fallback to "scheme/base" |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
310 if it doesn't exist), "r5rs" module for test and "raco ctool" command for |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
311 building Vim. If MzScheme did not have them, you can install them with |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
312 MzScheme's raco command: |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
313 > |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
314 raco pkg install scheme-lib # scheme/base module |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
315 raco pkg install r5rs-lib # r5rs module |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
316 raco pkg install cext-lib # raco ctool command |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
5294
diff
changeset
|
317 < |
14 | 318 ====================================================================== |
14421 | 319 vim:tw=78:ts=8:noet:sts=4:ft=help:norl: |