1919
|
1 *if_mzsch.txt* For Vim version 7.2. Last change: 2009 Jun 24
|
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|
|
|
12 4. The Vim access procedures |mzscheme-vim|
|
625
|
13 5. Dynamic loading |mzscheme-dynamic|
|
14
|
14
|
|
15 {Vi does not have any of these commands}
|
|
16
|
|
17 The MzScheme interface is available only if Vim was compiled with the
|
|
18 |+mzscheme| feature.
|
|
19
|
|
20 Based on the work of Brent Fulgham.
|
128
|
21 Dynamic loading added by Sergey Khorev
|
14
|
22
|
|
23 For downloading MzScheme and other info:
|
|
24 http://www.plt-scheme.org/software/mzscheme/
|
|
25
|
1121
|
26 Note: On FreeBSD you should use the "drscheme" port.
|
|
27
|
14
|
28 ==============================================================================
|
|
29 1. Commands *mzscheme-commands*
|
|
30
|
|
31 *:mzscheme* *:mz*
|
|
32 :[range]mz[scheme] {stmt}
|
|
33 Execute MzScheme statement {stmt}. {not in Vi}
|
|
34
|
|
35 :[range]mz[scheme] << {endmarker}
|
|
36 {script}
|
|
37 {endmarker}
|
|
38 Execute inlined MzScheme script {script}.
|
|
39 Note: This command doesn't work if the MzScheme
|
|
40 feature wasn't compiled in. To avoid errors, see
|
|
41 |script-here|.
|
|
42
|
|
43 *:mzfile* *:mzf*
|
|
44 :[range]mzf[ile] {file} Execute the MzScheme script in {file}. {not in Vi}
|
|
45
|
|
46 All of these commands do essentially the same thing - they execute a piece of
|
|
47 MzScheme code, with the "current range" set to the given line
|
|
48 range.
|
|
49
|
|
50 In the case of :mzscheme, the code to execute is in the command-line.
|
|
51 In the case of :mzfile, the code to execute is the contents of the given file.
|
|
52
|
|
53 MzScheme interface defines exception exn:vim, derived from exn.
|
|
54 It is raised for various Vim errors.
|
|
55
|
|
56 During compilation, the MzScheme interface will remember the current MzScheme
|
|
57 collection path. If you want to specify additional paths use the
|
|
58 'current-library-collection-paths' parameter. E.g., to cons the user-local
|
|
59 MzScheme collection path: >
|
|
60 :mz << EOF
|
|
61 (current-library-collection-paths
|
|
62 (cons
|
|
63 (build-path (find-system-path 'addon-dir) (version) "collects")
|
|
64 (current-library-collection-paths)))
|
|
65 EOF
|
|
66 <
|
|
67
|
|
68 All functionality is provided through module vimext.
|
|
69
|
|
70 The exn:vim is available without explicit import.
|
|
71
|
|
72 To avoid clashes with MzScheme, consider using prefix when requiring module,
|
|
73 e.g.: >
|
|
74 :mzscheme (require (prefix vim- vimext))
|
|
75 <
|
1894
|
76 All the examples below assume this naming scheme.
|
14
|
77
|
273
|
78 *mzscheme-sandbox*
|
|
79 When executed in the |sandbox|, access to some filesystem and Vim interface
|
|
80 procedures is restricted.
|
14
|
81
|
|
82 ==============================================================================
|
|
83 2. Examples *mzscheme-examples*
|
|
84 >
|
|
85 :mzscheme (display "Hello")
|
1894
|
86 :mz (display (string-append "Using MzScheme version " (version)))
|
|
87 :mzscheme (require (prefix vim- vimext)) ; for MzScheme < 4.x
|
|
88 :mzscheme (require (prefix-in vim- 'vimext)) ; MzScheme 4.x
|
14
|
89 :mzscheme (vim-set-buff-line 10 "This is line #10")
|
|
90 <
|
|
91 Inline script usage: >
|
|
92 function! <SID>SetFirstLine()
|
|
93 :mz << EOF
|
|
94 (display "!!!")
|
1894
|
95 (require (prefix vim- vimext))
|
|
96 ; for newer versions (require (prefix-in vim- 'vimext))
|
14
|
97 (vim-set-buff-line 1 "This is line #1")
|
|
98 (vim-beep)
|
1894
|
99 EOF
|
14
|
100 endfunction
|
|
101
|
|
102 nmap <F9> :call <SID>SetFirstLine() <CR>
|
|
103 <
|
|
104 File execution: >
|
|
105 :mzfile supascript.scm
|
|
106 <
|
1894
|
107 Vim exception handling: >
|
|
108 :mz << EOF
|
|
109 (require (prefix vim- vimext))
|
|
110 ; for newer versions (require (prefix-in vim- 'vimext))
|
|
111 (with-handlers
|
|
112 ([exn:vim? (lambda (e) (display (exn-message e)))])
|
|
113 (vim-eval "nonsense-string"))
|
|
114 EOF
|
14
|
115 <
|
1894
|
116 Auto-instantiation of vimext module (can be placed in your |vimrc|): >
|
|
117 function! MzRequire()
|
|
118 :redir => l:mzversion
|
|
119 :mz (version)
|
|
120 :redir END
|
|
121 if strpart(l:mzversion, 1, 1) < "4"
|
|
122 " MzScheme versions < 4.x:
|
|
123 :mz (require (prefix vim- vimext))
|
|
124 else
|
|
125 " newer versions:
|
|
126 :mz (require (prefix-in vim- 'vimext))
|
|
127 endif
|
|
128 endfunction
|
14
|
129
|
1894
|
130 if has("mzscheme")
|
|
131 silent call MzRequire()
|
|
132 endif
|
|
133 <
|
14
|
134 ==============================================================================
|
|
135 3. Threads *mzscheme-threads*
|
|
136
|
|
137 The MzScheme interface supports threads. They are independent from OS threads,
|
|
138 thus scheduling is required. The option 'mzquantum' determines how often
|
|
139 Vim should poll for available MzScheme threads.
|
|
140 NOTE
|
|
141 Thread scheduling in the console version of Vim is less reliable than in the
|
|
142 GUI version.
|
|
143
|
|
144 ==============================================================================
|
|
145 5. VIM Functions *mzscheme-vim*
|
|
146
|
|
147 *mzscheme-vimext*
|
|
148 The 'vimext' module provides access to procedures defined in the MzScheme
|
|
149 interface.
|
|
150
|
|
151 Common
|
|
152 ------
|
|
153 (command {command-string}) Perform the vim ":Ex" style command.
|
1894
|
154 (eval {expr-string}) Evaluate the vim expression into
|
|
155 respective MzScheme object: |Lists| are
|
|
156 represented as Scheme lists,
|
|
157 |Dictionaries| as hash tables.
|
|
158 NOTE the name clashes with MzScheme eval
|
14
|
159 (range-start) Start/End of the range passed with
|
|
160 (range-end) the Scheme command.
|
|
161 (beep) beep
|
|
162 (get-option {option-name} [buffer-or-window]) Get Vim option value (either
|
|
163 local or global, see set-option).
|
|
164 (set-option {string} [buffer-or-window])
|
|
165 Set a Vim option. String must have option
|
|
166 setting form (like optname=optval, or
|
|
167 optname+=optval, etc.) When called with
|
|
168 {buffer} or {window} the local option will
|
|
169 be set. The symbol 'global can be passed
|
|
170 as {buffer-or-window}. Then |:setglobal|
|
|
171 will be used.
|
|
172
|
|
173 Buffers *mzscheme-buffer*
|
|
174 -------
|
|
175 (buff? {object}) Is object a buffer?
|
|
176 (buff-valid? {object}) Is object a valid buffer? (i.e.
|
|
177 corresponds to the real Vim buffer)
|
|
178 (get-buff-line {linenr} [buffer])
|
|
179 Get line from a buffer.
|
|
180 (set-buff-line {linenr} {string} [buffer])
|
|
181 Set a line in a buffer. If {string} is #f,
|
|
182 the line gets deleted. The [buffer]
|
856
|
183 argument is optional. If omitted, the
|
|
184 current buffer will be used.
|
14
|
185 (get-buff-line-list {start} {end} [buffer])
|
|
186 Get a list of lines in a buffer. {Start}
|
|
187 and {end} are 1-based. {Start} is
|
|
188 inclusive, {end} - exclusive.
|
|
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.
|
|
202 (curr-buff) Get the current buffer. Use procedures
|
1668
|
203 from "vimcmd" module 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 ==============================================================================
|
1919
|
234 5. Dynamic loading *mzscheme-dynamic* *E815*
|
625
|
235
|
|
236 On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
|
|
237 output then includes |+mzscheme/dyn|.
|
|
238
|
|
239 This means that Vim will search for the MzScheme DLL files only when needed.
|
|
240 When you don't use the MzScheme interface you don't need them, thus you can
|
|
241 use Vim without these DLL files.
|
|
242
|
|
243 To use the MzScheme interface the MzScheme DLLs must be in your search path.
|
|
244 In a console window type "path" to see what directories are used.
|
|
245
|
|
246 The names of the DLLs must match the MzScheme version Vim was compiled with.
|
|
247 For MzScheme version 209 they will be "libmzsch209_000.dll" and
|
1121
|
248 "libmzgc209_000.dll". To know for sure look at the output of the ":version"
|
|
249 command, look for -DDYNAMIC_MZSCH_DLL="something" and
|
|
250 -DDYNAMIC_MZGC_DLL="something" in the "Compilation" info.
|
625
|
251
|
14
|
252 ======================================================================
|
|
253 vim:tw=78:ts=8:sts=4:ft=help:norl:
|