Mercurial > vim
comparison runtime/doc/if_mzsch.txt @ 14:946da5994c01
updated for version 7.0006
author | vimboss |
---|---|
date | Mon, 05 Jul 2004 15:58:32 +0000 |
parents | |
children | 404aac550f35 |
comparison
equal
deleted
inserted
replaced
13:24d5189d3956 | 14:946da5994c01 |
---|---|
1 *if_mzsch.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 | |
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| | |
13 | |
14 {Vi does not have any of these commands} | |
15 | |
16 The MzScheme interface is available only if Vim was compiled with the | |
17 |+mzscheme| feature. | |
18 | |
19 Based on the work of Brent Fulgham. | |
20 | |
21 For downloading MzScheme and other info: | |
22 http://www.plt-scheme.org/software/mzscheme/ | |
23 | |
24 ============================================================================== | |
25 1. Commands *mzscheme-commands* | |
26 | |
27 *:mzscheme* *:mz* | |
28 :[range]mz[scheme] {stmt} | |
29 Execute MzScheme statement {stmt}. {not in Vi} | |
30 | |
31 :[range]mz[scheme] << {endmarker} | |
32 {script} | |
33 {endmarker} | |
34 Execute inlined MzScheme script {script}. | |
35 Note: This command doesn't work if the MzScheme | |
36 feature wasn't compiled in. To avoid errors, see | |
37 |script-here|. | |
38 | |
39 *:mzfile* *:mzf* | |
40 :[range]mzf[ile] {file} Execute the MzScheme script in {file}. {not in Vi} | |
41 All statements are executed in the namespace of the | |
42 buffer that was current during :mzfile start. | |
43 If you want to access other namespaces, use | |
44 'parameterize'. | |
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 Each buffer has its own MzScheme namespace. Global namespace is bound to | |
54 the `global-namespace' value from the 'vimext' module. | |
55 MzScheme interface defines exception exn:vim, derived from exn. | |
56 It is raised for various Vim errors. | |
57 | |
58 During compilation, the MzScheme interface will remember the current MzScheme | |
59 collection path. If you want to specify additional paths use the | |
60 'current-library-collection-paths' parameter. E.g., to cons the user-local | |
61 MzScheme collection path: > | |
62 :mz << EOF | |
63 (current-library-collection-paths | |
64 (cons | |
65 (build-path (find-system-path 'addon-dir) (version) "collects") | |
66 (current-library-collection-paths))) | |
67 EOF | |
68 < | |
69 | |
70 All functionality is provided through module vimext. | |
71 | |
72 The exn:vim is available without explicit import. | |
73 | |
74 To avoid clashes with MzScheme, consider using prefix when requiring module, | |
75 e.g.: > | |
76 :mzscheme (require (prefix vim- vimext)) | |
77 < | |
78 All the examples below assume this naming scheme. Note that you need to do | |
79 this again for every buffer. | |
80 | |
81 The auto-instantiation can be achieved with autocommands, e.g. you can put | |
82 something like this in your .vimrc: > | |
83 au VimEnter,BufNew,BufNewFile,BufAdd,BufReadPre * | |
84 \:mz (require (prefix vim- vimext) | |
85 < | |
86 | |
87 The global namespace just instantiated this module with the prefix "vimext:". | |
88 | |
89 ============================================================================== | |
90 2. Examples *mzscheme-examples* | |
91 > | |
92 :mzscheme (display "Hello") | |
93 :mzscheme (vim-set-buff-line 10 "This is line #10") | |
94 < | |
95 Inline script usage: > | |
96 function! <SID>SetFirstLine() | |
97 :mz << EOF | |
98 (display "!!!") | |
99 (vim-set-buff-line 1 "This is line #1") | |
100 (vim-beep) | |
101 EOF | |
102 endfunction | |
103 | |
104 nmap <F9> :call <SID>SetFirstLine() <CR> | |
105 < | |
106 File execution: > | |
107 :mzfile supascript.scm | |
108 < | |
109 Accessing the current buffer namespace from an MzScheme program running in | |
110 another buffer within |:mzfile|-executed script : > | |
111 ; Move to the window below | |
112 (vim-command "wincmd j") | |
113 ; execute in the context of buffer, to which window belongs | |
114 ; assume that buffer has 'textstring' defined | |
115 (parameterize ((current-namespace | |
116 (vim-get-buff-namespace (vim-curr-buff)))) | |
117 (eval '(vim-set-buff-line 1 textstring))) | |
118 < | |
119 | |
120 ============================================================================== | |
121 3. Threads *mzscheme-threads* | |
122 | |
123 The MzScheme interface supports threads. They are independent from OS threads, | |
124 thus scheduling is required. The option 'mzquantum' determines how often | |
125 Vim should poll for available MzScheme threads. | |
126 NOTE | |
127 Thread scheduling in the console version of Vim is less reliable than in the | |
128 GUI version. | |
129 | |
130 ============================================================================== | |
131 5. VIM Functions *mzscheme-vim* | |
132 | |
133 *mzscheme-vimext* | |
134 The 'vimext' module provides access to procedures defined in the MzScheme | |
135 interface. | |
136 | |
137 Common | |
138 ------ | |
139 (command {command-string}) Perform the vim ":Ex" style command. | |
140 (eval {expr-string}) Evaluate the vim command string. | |
141 NOTE clashes with MzScheme eval | |
142 (range-start) Start/End of the range passed with | |
143 (range-end) the Scheme command. | |
144 (beep) beep | |
145 (get-option {option-name} [buffer-or-window]) Get Vim option value (either | |
146 local or global, see set-option). | |
147 (set-option {string} [buffer-or-window]) | |
148 Set a Vim option. String must have option | |
149 setting form (like optname=optval, or | |
150 optname+=optval, etc.) When called with | |
151 {buffer} or {window} the local option will | |
152 be set. The symbol 'global can be passed | |
153 as {buffer-or-window}. Then |:setglobal| | |
154 will be used. | |
155 global-namespace The MzScheme main namespace. | |
156 | |
157 Buffers *mzscheme-buffer* | |
158 ------- | |
159 (buff? {object}) Is object a buffer? | |
160 (buff-valid? {object}) Is object a valid buffer? (i.e. | |
161 corresponds to the real Vim buffer) | |
162 (get-buff-line {linenr} [buffer]) | |
163 Get line from a buffer. | |
164 (set-buff-line {linenr} {string} [buffer]) | |
165 Set a line in a buffer. If {string} is #f, | |
166 the line gets deleted. The [buffer] | |
167 argument is optional. If omitted, the | |
168 current buffer will be used. | |
169 (get-buff-line-list {start} {end} [buffer]) | |
170 Get a list of lines in a buffer. {Start} | |
171 and {end} are 1-based. {Start} is | |
172 inclusive, {end} - exclusive. | |
173 (set-buff-line-list {start} {end} {string-list} [buffer]) | |
174 Set a list of lines in a buffer. If | |
175 string-list is #f or null, the lines get | |
176 deleted. If a list is shorter than | |
177 {end}-{start} the remaining lines will | |
178 be deleted. | |
179 (get-buff-name [buffer]) Get a buffer's text name. | |
180 (get-buff-num [buffer]) Get a buffer's number. | |
181 (get-buff-size [buffer]) Get buffer line count. | |
182 (insert-buff-line-list {linenr} {string/string-list} [buffer]) | |
183 Insert a list of lines into a buffer after | |
184 {linenr}. If {linenr} is 0, lines will be | |
185 inserted at start. | |
186 (curr-buff) Get the current buffer. Use procedures | |
187 from `vimcmd' module to change it. | |
188 (buff-count) Get count of total buffers in the editor. | |
189 (get-next-buff [buffer]) Get next buffer. | |
190 (get-prev-buff [buffer]) Get previous buffer. Return #f when there | |
191 are no more buffers. | |
192 (open-buff {filename}) Open a new buffer (for file "name") | |
193 (get-buff-by-name {buffername}) Get a buffer by its filename or #f | |
194 if there is no such buffer. | |
195 (get-buff-by-num {buffernum}) Get a buffer by its number (return #f if | |
196 there is no buffer with this number). | |
197 (get-buff-namespace [buffer]) Get buffer namespace. | |
198 | |
199 Windows *mzscheme-window* | |
200 ------ | |
201 (win? {object}) Is object a window? | |
202 (win-valid? {object}) Is object a valid window (i.e. corresponds | |
203 to the real Vim window)? | |
204 (curr-win) Get the current window. | |
205 (win-count) Get count of windows. | |
206 (get-win-num [window]) Get window number. | |
207 (get-win-by-num {windownum}) Get window by its number. | |
208 (get-win-buffer [window]) Get the buffer for a given window. | |
209 (get-win-height [window]) | |
210 (set-win-height {height} [window]) Get/Set height of window. | |
211 (get-win-width [window]) | |
212 (set-win-width {width} [window])Get/Set width of window. | |
213 (get-win-list [buffer]) Get list of windows for a buffer. | |
214 (get-cursor [window]) Get cursor position in a window as | |
215 a pair (linenr . column). | |
216 (set-cursor (line . col) [window]) Set cursor position. | |
217 | |
218 ====================================================================== | |
219 vim:tw=78:ts=8:sts=4:ft=help:norl: |