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