*if_mzsch.txt* For Vim version 6.3.  Last change: 2004 Jun 08


		  VIM REFERENCE MANUAL    by Sergey Khorev


The MzScheme Interface to Vim				*mzscheme* *MzScheme*

1. Commands				|mzscheme-commands|
2. Examples				|mzscheme-examples|
3. Threads				|mzscheme-threads|
4. Event handling			|mzscheme-events|
5. The Vim access procedures		|mzscheme-vim|
6. Integration with VimL		|mzscheme-viml|
7. Invoking Vim commands		|mzscheme-vimcmd|
8. Questions and answers		|mzscheme-faq|

{Vi does not have any of these commands}

The MzScheme interface is available only if Vim was compiled with the
|+mzscheme| feature.

Based on the work of Brent Fulgham.

==============================================================================
1. Commands						*mzscheme-commands*

							*:mzscheme* *:mz*
:[range]mz[scheme] {stmt}	Execute MzScheme statement {stmt}.  {not in Vi}

:[range]mz[scheme] << {endmarker}
{script}
{endmarker}
			Execute inlined MzScheme script {script}.
			Note: This command doesn't work if the MzScheme
			feature wasn't compiled in.  To avoid errors, see
			|script-here|.

							*:mzfile* *:mzf*
:[range]mzf[ile] {file}	Execute the MzScheme script in {file}.  {not in Vi}
			All statements are executed in the namespace of the
                        buffer that was current during :mzfile start.
			If you want to access other namespaces, use
			'parameterize'.

All of these commands do essentially the same thing - they execute a piece of
MzScheme code, with the "current range" set to the given line
range.

In the case of :mzscheme, the code to execute is in the command-line.
In the case of :mzfile, the code to execute is the contents of the given file.

Each buffer has its own MzScheme namespace. Global namespace is bound to
the `global-namespace' value from the 'vimext' module.
MzScheme interface defines exception exn:vim, derived from exn.
It is raised for various Vim errors.

During compilation, the MzScheme interface will remember the current MzScheme 
collection path. If you want to specify additional paths use the
'current-library-collection-paths' parameter. E.g., to cons the user-local
MzScheme collection path: >
    :mz << EOF
    (current-library-collection-paths
	(cons
	    (build-path (find-system-path 'addon-dir) (version) "collects")
	    (current-library-collection-paths)))
    EOF
<

All functionality is provided through three modules:
    vimext  - useful utilities implemented by the MzScheme interface.
    viml    - VimL |functions| and variables (|v:var|), available in MzScheme
		as procedures.
    vimcmd  - Vim commands, available as procedures.

The exn:vim is available without explicit import.

To avoid clashes with MzScheme, consider using prefixes when requiring modules,
e.g.: >
	:mzscheme (require (prefix vim- vimext))
	:mzscheme (require (prefix vim- viml))
	:mzscheme (require (prefix vim: vimcmd))
<
All the examples below assume this naming scheme.
 
The auto-instantiation can be achieved with autocommands, e.g. you can put 
something like this in your .vimrc: >
    au VimEnter,BufNew,BufNewFile,BufAdd,BufReadPre * 
	\:mz (require (prefix vim- vimext) (prefix vim- viml) (prefix vim: vimcmd))
<

The global namespace just instantiated all these modules with the prefixes
"vimext:", "viml:" and "vimcmd:".

==============================================================================
2. Examples						*mzscheme-examples*
>
	:mzscheme (display "Hello")
	:mzscheme (vim-set-buff-line 10 "This is line #10")
<
Inline script usage: >
	function! <SID>SetFirstLine()
	    :mz << EOF
	    (display "!!!")
	    (vim-set-buff-line 1 "This is line #1")
	    (vim-beep)
	    EOF
	endfunction

	nmap <F9> :call <SID>SetFirstLine() <CR>
<
File execution: >
	:mzfile supascript.scm
<
Accessing the current buffer namespace from an MzScheme program running in another
buffer within |:mzfile|-executed script : >
	; Move to the window below
	(vim-command "wincmd j")
	; execute in the context of buffer, to which window belongs
	; assume that buffer has 'textstring' defined
	(parameterize ((current-namespace 
			(vim-get-buff-namespace (vim-curr-buff))))
	 (eval '(vim-set-buff-line 1 textstring)))
<
Calling VimL function byte2line: >
	:mz (display (vim-byte2line 4))
<
Accessing VimL variable v:version: >
	:mz (vim-version)
<
Edit buffer with name "cscope" from the buffer list: >
	:mz (vim:buffer "cscope")
<
Execute current Scheme script: >
    :mz (load (vim-expand "%"))  
<

For examples on event-handling, keyboard mapping and menus see
|mzscheme-events|, |mzscheme-mapping|, |mzscheme-menu|

==============================================================================
3. Threads						*mzscheme-threads*

The MzScheme interface supports threads. They are independent from OS threads,
thus scheduling is required. The option 'mzquantum' determines how often
Vim should poll for available MzScheme threads.
NOTE
Thread scheduling in the console version of Vim is less reliable than in the
GUI version.
					
==============================================================================
4. Event handling					*mzscheme-events*

The MzScheme interface can handle Vim events, some of which represent the Vim
autocommands. Their names are converted from the corresponding Vim autocommand
names as follows:
    uppercase letters at the beginning of a word are downcased.
    all other uppercase letters are prepended with '-' and then downcased.

For example, the autocommand BufEnter will have the name 'buf-enter', GUIEnter
will be 'gui-enter', and FileChangedRO becomes 'file-changed-ro'.

All event-handling procedures are provided with the module 'vimext'

Working with autocommand event handlers
---------------------------------------

To understand this section you have to know about MzScheme parameters.
Read the section "Threads" in the "PLT MzScheme Language Manual" for details
about parameters.

All event handlers are available as MzScheme parameters. Their names are event
names, prefixed with 'on-'. E.g., 'on-vim-enter' corresponds to the VimEnter
autocommand. To temporarily change event handlers, one may use the
`parameterize' MzScheme form. Each parameter value must be a _LIST_ of thunks
(procedures without arguments).

The execution of nested event handlers can be disabled by setting the
parameter 'enable-subevents' to #f (i.e with (vim-enable-seubevents #f) or
`parameterize').

Vim autocommands are presented as procedures with names with -auto appended,
e.g., 'on-file-read-pre-auto'.

All of these are available in the vimext module.

If a handler returns #f, all handlers in a chain are cancelled.
If a handler raises an exception, all remaining handlers will be skipped and
an error message will be displayed.

    Here are some examples (load them with :mzf {script-file-name}):

1) Adding event handlers: >

    (define q #f)

    ; setting up CursorHold handler
    (vim-on-cursor-hold
     (cons 
      (lambda ()
       (set! q (cons 'hold q))
       (vim:edit "if_cscope.c")) 
      (vim-on-cursor-hold)))

    ; setting up BufReadPre handler
    (vim-on-buf-read-pre
     (cons
      (lambda ()
       (set! q (cons 'read-pre q)))
      (vim-on-buf-read-pre)))
<
    When 4 seconds have elapsed Vim should open the file if_cscope.c. If it
    exists, the value of q (one can use the command ':mz q') must be 
    '(read-pre hold).

2) Temporarily disabling nested events: >

    (define q #f)

    ; setting up CursorHold handler
    (vim-on-cursor-hold
     (cons 
      (lambda ()
       (set! q (cons 'hold q))
       ;;; disabling subevents
       (parameterize ((vim-enable-subevents #f))
	(vim:edit "if_cscope.c")))
      (vim-on-cursor-hold)))

    ; setting up BufReadPre handler
    (vim-on-buf-read-pre
     (cons
      (lambda ()
       (set! q (cons 'read-pre q)))
      (vim-on-buf-read-pre)))
<
    When 4 seconds have elapsed Vim should open the file if_cscope.c. The
    value of q will be '(hold).

3) Premature ending of event handlers chain: >

    (define q '())

    ; setting up BufReadPre handler, removing original ones
    (vim-on-buf-read-pre
     (list
      (lambda ()
       (set! q (cons 1 q)))
      (lambda ()
       (set! q (cons 2 q)) #f) ;; return #f - exit
      (lambda ()
       (set! q (cons 3 q)))))
<
    After opening a file, q should have value '(2 1)

Notifications on buffer changes
-------------------------------

    There are three kinds of changes that can be handled:
    1) line insertion;
    2) line deletion;
    3) line modification.

    Event handlers are set up with the procedures
    1) (set-insert-handler {handler} [buffer])
    2) (set-delete-handler {handler} [buffer])
    3) (set-change-handler {handler} [buffer])

    {handler} is a 2-argument procedure or #f. Changing buffer contents from
    the handler may lead to unpredictable results.
    set-XXX-handler returns the preceding handler.

    Handler values can be obtained by executing
    (get-XXX-handler [buffer])

    Handler arguments are line numbers and counts of changed lines. Their
    return values are ignored.

    Example (running against an empty buffer): >

    (define q '())

    (vim-set-change-handler
     (lambda (line count)
      (set! q `((change ,line ,count) ,@q))))

    (vim-set-insert-handler
     (lambda (line count)
      (set! q `((insert ,line ,count) ,@q))))

    (vim-set-delete-handler
     (lambda (line count)
      (set! q `((delete ,line ,count) ,@q))))

    (vim-insert-buff-line-list 0 '("line1" "line2")) 
    ; q => ((insert 0 2)) :
    ; inserted 2 lines after line #0

    (set! q '())
    (vim-set-buff-line-list 2 3 '("line2-2" "line3")) 
    ; q => ((insert 2 1) (change 2 1)) :
    ; changed line #2 and inserted line after #2
    ; remember that the second argument of set-buff-line-list 
    ; isn't included in the range

    (set! q '())
    (vim-set-buff-line-list 2 4 '("line2-3"))
    ; q => ((delete 3 1) (change 2 1))
    ; changed line #2 and deleted #3

    (set! q '())
    (vim-set-buff-line 2 #f)
    ; q => ((delete 2 1))
    ; deleted line #2
<

Low-level hooks
---------------

    The MzScheme interface provides low-level hooks for keyboard input.
    For efficiency reasons their values are procedures, NOT lists.

    1) The parameter 'on-input' must be a procedure of one argument -
    string input by user. If the handler returns a string, this will replace
    user input (but not longer than the original string length). Vim calls it 
    before looking for mappings.

    2) The 'on-typed' procedure takes an integer value - Vim's representation
    of the character that the user input. The procedure may return either
    integer, char, or string (only the first character will be used). If #f 
    or void, the character will not be replaced.

    3) The 'on-char' procedure is complimentary to the 'on-typed' parameter.
    It will be called if a character wasn't typed by the user (e.g. was derived
    from the mapping).

    Examples: >
    " This hook will replace "1" in user input with "3"
    :mz (vim-on-input (lambda (str) (if (equal? str "1") "3"))) 
    " now to enter "1" ;)

    " This hook will replace "2" with "4" 
    " if it was typed by user and not remapped
    " enter this IN ONE LINE:
    :mz (vim-on-typed (lambda (ch) (if (= ch (char->integer #\2))
		    (char->integer #\4)))) 
    " now try to enter "2" ;)
    " but mappings with "2" will work!

    " This hook will replace "5" with "6" 
    " if it wasn't typed by user
    " enter this IN ONE LINE:
    :mz (vim-on-char (lambda (ch) (if (= ch (char->integer #\5))
		    (char->integer #\6)))) 
    " now all "5"s will be replaced with "6"s in mappings results
<
    Low-level hooks that raise exceptions during execution will be removed.


==============================================================================
5. VIM Functions					*mzscheme-vim*

							*mzscheme-vimext*
The 'vimext' module provides access to procedures defined in the MzScheme
interface.

Common
------
    (command {command-string})	    Perform the vim ":Ex" style command.
    (eval {expr-string})	    Evaluate the vim command string.
				    NOTE clashes with MzScheme eval
    (range-start)		    Start/End of the range passed with
    (range-end)			    the Scheme command.
    (beep)			    beep
    (get-option {option-name} [buffer-or-window]) Get Vim option value (either
				    local or global, see set-option).
    (set-option {string} [buffer-or-window])
				    Set a Vim option. String must have option
				    setting form (like optname=optval, or
				    optname+=optval, etc.) When called with
				    {buffer} or {window} the local option will
				    be set. The symbol 'global can be passed
				    as {buffer-or-window}. Then |:setglobal|
				    will be used.
    (visual) -> (line . col)	    Start of the current visual selection.
    global-namespace		    The MzScheme main namespace.
					    
Buffers							 *mzscheme-buffer*
-------
    (buff? {object})		    Is object a buffer?
    (buff-valid? {object})	    Is object a valid buffer? (i.e.
				    corresponds to the real Vim buffer)
    (get-buff-line {linenr} [buffer])
				    Get line from a buffer.
    (set-buff-line {linenr} {string} [buffer])
				    Set a line in a buffer. If {string} is #f,
				    the line gets deleted.  The [buffer]
                                    argument is optional. If omitted, the
                                    current buffer will be used.
    (get-buff-line-list {start} {end} [buffer])
				    Get a list of lines in a buffer. {Start}
				    and {end} are 1-based. {Start} is
				    inclusive, {end} - exclusive.
    (set-buff-line-list {start} {end} {string-list} [buffer]) 
				    Set a list of lines in a buffer. If
				    string-list is #f or null, the lines get
				    deleted. If a list is shorter than
				    {end}-{start} the remaining lines will
				    be deleted.
    (get-buff-name [buffer])	    Get a buffer's text name.
    (get-buff-num [buffer])	    Get a buffer's number.
    (get-buff-size [buffer])	    Get buffer line count.
    (insert-buff-line-list {linenr} {string/string-list} [buffer])
				    Insert a list of lines into a buffer after
				    {linenr}. If {linenr} is 0, lines will be
				    inserted at start.
    (curr-buff)			    Get the current buffer. Use procedures
				    from `vimcmd' module to change it.
    (buff-count)		    Get count of total buffers in the editor.
    (get-next-buff [buffer])	    Get next buffer.
    (get-prev-buff [buffer])	    Get previous buffer. Return #f when there
				    are no more buffers.
    (open-buff {filename})	    Open a new buffer (for file "name")
    (get-buff-by-name {buffername}) Get a buffer by its filename or #f
					if there is no such buffer.
    (get-buff-by-num {buffernum})   Get a buffer by its number (return #f if
				    there is no buffer with this number).
    (get-buff-namespace [buffer])   Get buffer namespace.
    (keep-current {thunk})	    Execute {thunk} (procedure without
				    arguments). Restore current window and
				    buffer if they were changed in {thunk}.
				    NOTE this is an ad hoc function, consider
				    using {buffer} and {window} arguments 
				    (including |mzscheme-vimcmd| procedures)

Windows							    *mzscheme-window*
------
    (win? {object})		    Is object a window?
    (win-valid? {object})	    Is object a valid window (i.e. corresponds
				    to the real Vim window)?
    (curr-win)			    Get the current window.
    (win-count)			    Get count of windows.
    (get-win-num [window])	    Get window number.
    (get-win-by-num {windownum})    Get window by its number.
    (get-win-buffer	[window])   Get the buffer for a given window.
    (get-win-height [window])
    (set-win-height {height} [window])  Get/Set height of window.
    (get-win-width [window])	
    (set-win-width {width} [window])Get/Set width of window.
    (get-win-list [buffer])	    Get list of windows for a buffer.
    (get-cursor [window])	    Get cursor position in a window as
				    a pair (linenr . column).
    (set-cursor (line . col) [window])  Set cursor position.

Conversion with lines, columns, offsets			*mzscheme-conversion*
---------------------------------------
    (line-col->pos (line . col) [buffer])
    (line-vcol->pos (line . vcol) [window])
    (pos->line-col {offset} [buffer]) -> (line . col)
    (pos->line-vcol {offset} [window]) -> (line . vcol)
			{line} and {col} are 1-based, {offset} - 0-based
			{vcol} is a virtual column in a given window
			
    For |multibyte| characters, {col} means 1-based character position in a
    string rather than raw byte offset.
    To convert between character positions and byte offsets one can use
    `cell' and `uncell' procedures (as usual, vim-col and char-pos are 1-based):
    (cell (line . vim-col) [buffer]) -> (line . char-pos)
    (uncell (line . char-pos) [buffer]) -> (line . vim-col)

Registers						*mzscheme-register*
---------
    Access to special registers is currently unsupported. 
    (get-register {regname})	    Get contents from register. {regname} must
				    be either a character, a one-char string or
				    a symbol.
    (set-register {regname} {string})
				    Set register contents. If {regname} is in
				    uppercase, then append (in the case of
                                    a symbol you must have case-sensitivity
                                    enabled).
				    {string} also can be a list of strings (in
				    that case append doesn't work yet).
    
Buffer contents as a port			*mzscheme-port* *buffer-port*
-------------------------
    (open-buff-input-port [start [end]] [buffer])
		Open input port to obtain buffer contents.
		{start} and {end} are 0-based offsets in the buffer
		(inclusive and exclusive respectively).
		-1 value for {start} or {end} means the end of a buffer,
		-2 means the start of a buffer.
		If {start} > {end} and {end} != -1, then buffer will be read 
		backwards.
		NOTE 1. Currently, {start} and {end} positions are corrected
		against actual buffer contents.
		2. Reading buffer input port during changes can lead to
		unpredictable behaviour.
		3. buffer-input-port represents the stream of characters
		rather than bytes. Thus |multibyte| characters should be
		processed properly even with the backward-directed port.
		4. If you plan to read from this buffer when it is invisible,
		consider setting its 'bufhidden' option to 'hide'.

		Examples: >
		; port to read from position 3 until EOF
		(vim-open-buff-input-port 3 -1)
		; port to read from position 3 until 10 (not including 10)
		(vim-open-buff-input-port 3 10)
		; port to read from position 10 until 3 (i.e. backwards)
		(vim-open-buff-input-port 10 3)
		; port to read from position 10 until BOF
		(vim-open-buff-input-port 10 -2)
		; port to get the reversed buffer contents
		(vim-open-buff-input-port -1 -2)
<
    (get-buff-input-port-pos {port}) -> (line . col)
		Returns the current (line, col) position of the buffer input
		port. For multibyte characters, {col} is a character position
		rather than byte offset.
		
    (open-buff-output-port [buffer] [update-screen])
		Open output port to append to buffer contents.
		NOTE this function sets 'bufhidden' option to 'hide'.
		The optional [update-screen] argument (default value #f)
		specifies whether to update the whole screen on write. You may
		want to use it in the multithreaded environment.
    
    (get-port-buff [port]) Return corresponding buffer for the port.

User-defined text objects			*mzscheme-text-objects*
-------------------------
	MzVim allows you to define custom |text-objects| (and override default
	ones) with the procedure
    (add-text-object {char} {proc} [buffer])
	{char} is a character for text objects.
	{proc} must be a 2-argument procedure or #f (to remove a custom text
	object). Its arguments are {count} and {include} - count and whether
	to return inclusive interval (i.e., 'i' instead of 'a' was issued).
	{proc} must return two values (start and end). Each value must be a 
	pair (linenum .  column). {linenum} and {column} are 1-based.
	NOTE For |multibyte| and |UTF-8| strings {column} is a character
        position rather than a byte offset.
	The current cursor position can be obtained with (get-cursor)
	Example (input this in one line): >
	" make 'F' text object, so vaF in normal mode will
	" select text from (1, 2) to (3, 4)
	:mz (vim-add-text-object #\F 
	    (lambda (count include?) (values '(1 . 2) '(3 . 4))))
<

==============================================================================
6. Integration with VimL				 *mzscheme-viml*

VimL mzeval() function					*mzeval* *mzeval()*
The mzeval() function can be used when the result of evaluating an MzScheme
expression is required. It accepts a string to evaluate. This can be useful
in 'indentexr', 'foldexpr' etc.

The 'viml' module provides access to VimL functions and built-in variables from
|function-list| and |vim-variable| respectively.
VimL procedures can accept {buffer} or {window} as an additional argument.
The current window or current buffer will be set to this value for the
duration of the call.
Variables are provided as 0-arity procedures.

==============================================================================
7. Invoking Vim comamnds				*mzscheme-vimcmd*

The 'vimcmd' module provides access to Vim colon commands.
    Vim commands are provided as procedures.
    The modifiers like :rightabove, :silent, !, etc., can be passed as symbols: >
	:rightabove new a1	=>  :mz (vim:new 'rightabove "a1")
	:buffer! val		=>  :mz (vim:buffer '! "val")
	:write >> file		=>  :mz (vim:write '>> "file")
	:read !infile		=>  :mz (vim:read 'filter "infile")
<							

The commands-procedures can accept buffer and window arguments. In that case
the current buffer/window will be set to this value for the duration of the
call. 
For example, to define syntax for a particular buffer: >
	(vim:syntax buf "match pltDir /^.*\\/$/")
	(vim:highlight buf "def link pltDir Keyword")
<
Read |mzscheme-cmdargs| for information about specifying additional modifiers
and arguments. 

MzScheme's `exit' procedure is mapped to the Vim's :quit command. So one can
use (exit '!) for forced exit.

The MzScheme interface tries to be a closed system, so some commands (usually
those which deal with VimL) are not exported.
    TODO put list here

							*mzscheme-cmdargs*
Support for additional arguments
------------------------------------
							*mzscheme-range*
The range can be passed as structure "range", defined in module vimcmd.
Its fields have the names: lower, upper, and stay-on-lower?
The "stay-on-lower?" field is analogous to ";" in a Vim |range| specification.
Constructor (make-range) can accept from 0 to 3 arguments, default field 
values are MAXLNUM (invalid line number), MAXLNUM and #f respectively.
Example: >
	:5,/abc/write >> ouf	=>  
		:mz (vim:write (vim:make-range 5 "/abc/") '>> "ouf")
<						
							*mzscheme-count*
The count can be passed directly as a number argument, e.g. >
	:2 buffer		=>  :mz (vim:buffer 2)
<
NOTE Count arguments for |:>| and |:<| commands have different semantics: 
they refer to shift numbers rather than line counts.

							*mzscheme-registers*
Vim registers can be passed to a command as characters, e.g. >
	:put a			=>  :mz (vim:put #\a)
<
							*mzscheme-verbose*
Verbosity level can be set with symbol "verbose" with optional following
number (defaults to 1): >
	:mz (vim:buffer 'verbose 10 "val")
<
							*mzscheme-+command*
The |+cmd| argument can be passed with symbol "+" followed by command text: >
	:mz (vim:edit '+ "split" "eval.c") 
<

Vim keymaps						*mzscheme-mapping*
-----------

The Vim mapping commands (i.e. |:map|, |:imap|, |:abbr| etc) are replaced 
with one procedure ({lhs} and {rhs} must be strings):
    (map [flag]... [lhs [rhs]])

If {rhs} is omitted, the current mappings will be shown.

{flag} arguments can be the following symbols: 
    1) Mode flags: 'insert, 'normal, 'visual, 'op-pending, 'langmap, 'cmdline.
    2) Other flags: 'abbrev, 'noremap, 'buffer, 'silent, 'script, 'unique
(the last four flags are analogous to <buffer>, <silent>, <script> and
<unique> for the regular Vim :map command).
    3) If {flag} is a buffer value, local mapping for that buffer will be
    created.

A few examples: >
    show all current mappings:
        :mz (vim:map)
    map Z to yy in normal mode:
        :mz (vim:map 'normal "Z" "yy")
    show mapping for Z in normal mode:
	:mz (vim:map 'normal "Z")
<

{rhs} can be a procedure without arguments. In that case the displayed result
of its application will be inserted. If it returns #f or void, nothing will be
inserted.
    The following handler will replace "RRR" in insert mode with "zzz" and
    "ZZZ" alternately: >
    :mz << EOF
    (vim:map 'insert "RRR" 
     (let ((upcase #f))
      (lambda ()
      (set! upcase (not upcase))
      (if upcase "zzz" "ZZZ"))))
    EOF
<
The procedure (unmap [flag]... {lhs}) removes a mapping.

Vim menus						*mzscheme-menu*
---------

The MzScheme procedure (menu [flag]... [priority] [menu-path [target]])
replaces all Vim |:menu|, |:cnoremenu|, |:omenu|, etc., commands.

Valid {flag} values are:
    1) Mode flags: 'insert, 'normal, 'visual, 'op-pending, 'cmdline.
    2) Other flags: 'noremap, 'silent, 'enable, 'disable.

{priority} may be either an integer or a list of integers (see
|menu-priority| for explanation).

{menu-path} is either a string with full menu path in the Vim notation
(dot-separated), or a list of strings.

If a target is not presented, then the list of mappings will be shown.

The {target} argument can be a string or a thunk (procedure without
arguments). In the latter case it will be invoked on menu item selection.
If it returns any value except void or #f, it will be used in the same way as
for keyboard mapping.

The procedure (vim:unmenu [flag]... {menu-path}) removes menu items.

Examples: >
    " adding menu item which deletes line in normal mode
    " notice the doubled backslash before whitespace
    " because Vim wants to have escaped whitespaces
	:mz (vim:menu 'normal "MzVim.Delete\\ line" "dd")

    " adding menu item before preceding one
	:mz (vim:menu 'normal 10 '("MzVim" "Yank\\ line") "yy")

    " disabling the 'Delete' item
	:mz (vim:menu 'normal 'disable "MzVim.Delete\\ line" "dd")

    " adding item for editing file if_cscope.c for all modes
    " type this in one line!
	:mz (vim:menu '("MzVim" "Edit\\ file") 
	    (lambda () (vim:edit "if_cscope.c")))
<

==============================================================================
8. Questions and (certainly!) answers			    *mzscheme-faq*

    Common questions
	1. If you like parentheses, why not Emacs?
	    First of all, using Emacs is literally a pain for me -
	    one of my fingers is injured, so pressing Control is very
	    uncomfortable. Emacs's VI emulation isn't very usable.
	    And Emacs seems to be too heavy to be an editor ;-)
	    In the end, I don't like parentheses and don't hate them.
	    But they are the lesser evil for make languages more 
	    powerful and preserving simplicity and maintainability.

	2. Why did you cripple Vim?
	    I didn't cripple Vim, I embedded a Scheme interpreter.
	    If you don't need it, simply don't use it!

	3. Why not VimL, Perl, Python, Ruby, Tcl?
	    VimL is too primitive to be the right language even for
	    editor scripting, most of the time (at least mine) is spent on
	    fighting with the syntax. VimL and Perl scripts are very
	    unmaintainable (I can't understand what I did a month ago in 
	    these languages ;))). Perl is easy to write, but extremely
	    hard to read. Python seems to me a very inconsistent language.
	    Ruby - too OO ;)) I even don't want to say anything about Tcl.
	    Please don't bombard me with flames about this subject
	    - I won't respond. Period.
	    
	4. How mature is the code now?
	    The vimext and viml modules are considered mature and robust
	    enough. Currently, the vimcmd is somewhat beta. Although most
	    of its functionality is implemented and can be used, extensive 
	    testing and some backfitting are required.

	5. What are your plans?
	    See if_mzsch.c for small TODOs. 
	    Also, I'm dreaming about something like Emacs's Quack or even
	    better ;). And there are NO PLANS to emulate (X)Emacs ;)

	6. Do you speak English?
	    Very badly. Don't hesitate to correct me, it'll be highly
	    appreciated.

	7. Does MzVim support Unicode?
	    If your version of MzScheme does (versions >= 299).
	    Else you'll get the bytes instead of code points.
	    All MzVim procedures return byte strings.

    MzVim usage
	1. I have a problem, or nothing works, or I can't compile MzVim.
	    Technically speaking, these aren't questions! ;))
	    But don't hesitate to contact me at iamphet@nm.ru. Any feedback
	    will be highly appreciated. Response is guaranteed.

	2. How do I create compiled scripts?
	    Use the `compiler' MzScheme collection.
	    E.g. for creating bytecode, issue: >
	    (require (lib "compiler.ss" "compiler"))
	    ((compile-zos #f) (list "your-mzvim-script.ss") 'auto)
<
            Of course your 'current-library-collection-paths' have to be set
            up properly).

	    You can even create modules: >
	    ;;; module which provides 'reverse-line' procedure
	    ;;; save it as "mzvim-utils.ss"
	    (module mzvim-utils mzscheme
		; one can import all Vim stuff if wants with
		; (require (prefix vim- vimext)
		;	    (prefix vim- viml)
		;	    (prefix vim: vimcmd))

		(require (rename vimext vim-get-buff-line get-buff-line)
			 (rename vimext vim-set-buff-line set-buff-line))
		(require (rename (lib "string.ss" "srfi" "13")
		    string-reverse string-reverse))

		(provide reverse-line)

		(define (reverse-line lineno)
		 (vim-set-buff-line lineno (string-reverse (vim-get-buff-line lineno))))
	    )

	    ;;; script for compiling "mzvim-utils.ss" to bytecode
	    ;;; execute it from the Vim
	    (require (lib "compiler.ss" "compiler"))
	    ((compile-zos #f) (list "mzvim-utils.ss") 'auto)

	    ;;; usage example for "mzvim-utils" module
	    ;;; check that you execute it
	    ;;; in the same directory as "mzvim-utils.ss"
	    ;;; or setup current-library-collection-paths
	    (require "mzvim-utils.ss")
	    (reverse-line 2)
<

======================================================================
  vim:tw=78:ts=8:sts=4:ft=help:norl:
