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