Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
if_mzsch.txt  ForVim version 9.2.  Last change: 2026 Feb 14VIM REFERENCE MANUAL  by Sergey KhorevTheMzSchemeInterface to VimmzschemeMzScheme1. Commandsmzscheme-commands2. Examplesmzscheme-examples3. Threadsmzscheme-threads4. Vim access fromMzSchememzscheme-vim5.mzeval() Vim functionmzscheme-mzeval6. Using Function referencesmzscheme-funcref7. Dynamic loadingmzscheme-dynamic8.MzScheme setupmzscheme-setup{only available when Vim was compiled with the |+mzscheme| feature}Based on the work of Brent Fulgham.Dynamic loading added by Sergey KhorevMzScheme and PLT Scheme names have been rebrandedas Racket.  For moreinformation please checkhttp://racket-lang.orgFutures and places of Racket version 5.x up to and including 5.3.1do notwork correctly with processes created by Vim.The simplest solutionis to build Racket on your own with these featuresdisabled:  ./configure --disable-futures --disable-places --prefix=your-install-prefixTo speed up the process, you might also want to use --disable-gracket and--disable-docs==============================================================================1. Commandsmzscheme-commands:mzscheme:mz:[range]mz[scheme]{stmt}ExecuteMzScheme statement{stmt}.:[range]mz[scheme]<<[trim] [{endmarker}]{script}{endmarker}Execute inlinedMzSchemescript{script}.Note: This command doesn't work when theMzSchemefeature wasn't compiled in.  To avoid errors, seescript-here.If[endmarker]is omitted from after the "<<",a dot'.'must be used after{script}, like for the:append and:insert commands.  Refer to:let-heredoc for more information.:mzfile:mzf:[range]mzf[ile]{file}Execute theMzSchemescript in{file}.All of these commandsdo essentially the same thing- they executea piece ofMzScheme code, with the "current range" set to the given linerange.In thecase of :mzscheme, the code to executeis in the command-line.In thecase of :mzfile, the code to executeis the contents of the given file.MzSchemeinterface defines exception exn:vim, derived from exn.Itis raised forvarious Vim errors.During compilation, theMzSchemeinterface will remember the currentMzSchemecollection path.  If you want to specify additional paths use the"current-library-collection-paths" parameter.  E.g., to cons the user-localMzScheme collection path:    :mz << EOF    (current-library-collection-paths(cons    (build-path (find-system-path 'addon-dir) (version) "collects")    (current-library-collection-paths)))    EOFAll functionalityis provided through module vimext.The exn:vimis available without explicit import.To avoid clashes with MzScheme, consider using prefix when requiring module,e.g.::mzscheme (require (prefix vim- vimext))All the examples below assume this naming scheme.mzscheme-sandboxWhen executed in thesandbox, access to some filesystem and Viminterfaceproceduresis restricted.==============================================================================2. Examplesmzscheme-examples:mzscheme (display "Hello"):mz (display (string-append "Using MzScheme version " (version))):mzscheme (require (prefix vim- vimext)) ; for MzScheme < 4.x:mzscheme (require (prefix-in vim- 'vimext)) ; MzScheme 4.x:mzscheme (vim-set-buff-line 10 "This is line #10")To see what version ofMzScheme you have::mzscheme (display (version))Inlinescript usage:function! <SID>SetFirstLine()    :mz << EOF    (display "!!!")    (require (prefix vim- vimext))    ; for newer versions (require (prefix-in vim- 'vimext))    (vim-set-buff-line 1 "This is line #1")    (vim-beep)EOFendfunctionnmap <F9> :call <SID>SetFirstLine() <CR>File execution::mzfile supascript.scmVim exception handling::mz << EOF(require (prefix vim- vimext)); for newer versions (require (prefix-in vim- 'vimext))(with-handlers  ([exn:vim? (lambda (e) (display (exn-message e)))])  (vim-eval "nonsense-string"))EOFAuto-instantiation of vimext module (can be placed in yourvimrc):    function! MzRequire():redir => l:mzversion:mz (version):redir ENDif strpart(l:mzversion, 1, 1) < "4"    " MzScheme versions < 4.x:    :mz (require (prefix vim- vimext))else    " newer versions:    :mz (require (prefix-in vim- 'vimext))endif    endfunction    if has("mzscheme")silent call MzRequire()    endif==============================================================================3. Threadsmzscheme-threadsTheMzSchemeinterface supports threads.  They are independent from OSthreads, thus schedulingis required.  The option'mzquantum' determines howoften Vim should poll for availableMzScheme threads.NOTEThread scheduling in the console version of Vimisless reliable than in theGUI version.==============================================================================4. Vim access fromMzSchememzscheme-vimmzscheme-vimextThe'vimext' module provides access to procedures defined in theMzSchemeinterface.Common------    (command{command-string})    Perform the vim ":Ex" style command.    (eval{expr-string})    Evaluate the vimexpression into    respectiveMzScheme object:Lists are    representedas Scheme lists,Dictionariesas hash tables,Funcrefsasfunctions (see alsomzscheme-funcref)NOTE the name clashes withMzScheme eval,    use module qualifiers to overcome this.    (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])    Seta Vim option.Stringmust 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 passedas{buffer-or-window}.  Then:setglobal    will be used.Buffersmzscheme-buffer-------    (buff?{object})    Isobjecta buffer?    (buff-valid?{object})    Isobjecta valid buffer? (i.e.    corresponds to the real Vim buffer)    (get-buff-line{linenr}[buffer])    Get line froma buffer.    (set-buff-line{linenr}{string}[buffer])    Seta line ina buffer.  If{string}is    #f, the line gets deleted.  The[buffer]    argumentis optional.  If omitted, the    current buffer will be used.    (get-buff-line-list{start}{end}[buffer])    Getalist of lines ina buffer.{Start}    and{end} are 1-based and inclusive.    (set-buff-line-list{start}{end}{string-list}[buffer])    Setalist of lines ina buffer.  If    string-listis #f or null, the lines get    deleted.  Ifalistis shorter than{end}-{start} the remaining lines will    be deleted.    (get-buff-name[buffer])    Geta buffer's text name.    (get-buff-num[buffer])    Geta buffer's number.    (get-buff-size[buffer])    Get buffer line count.    (insert-buff-line-list{linenr}{string/string-list}[buffer])Insertalist of lines intoa buffer after{linenr}.  If{linenr}is 0, lines will be    insertedat start.    (curr-buff)    Get the current buffer.  Use otherMzSchemeinterface procedures to change    it.    (buff-count)    Getcount of totalbuffers 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})    Opena new buffer (for file "name")    (get-buff-by-name{buffername}) Geta buffer by its filename or #fif thereis no such buffer.    (get-buff-by-num{buffernum})   Geta buffer by its number (return #f if    thereis no buffer with this number).Windowsmzscheme-window------    (win?{object})    Isobjecta window?    (win-valid?{object})    Isobjecta validwindow (i.e. corresponds    to the real Vim window)?    (curr-win)    Get the current window.    (win-count)    Getcount of windows.    (get-win-num[window])    Getwindow number.    (get-win-by-num{windownum})    Getwindow by its number.    (get-win-buffer[window])   Get the buffer fora 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])    Getlist ofwindows fora buffer.    (get-cursor[window])    Get cursor position inawindowasa pair (linenr. column).    (set-cursor (line. col)[window])  Set cursor position.==============================================================================5.mzeval() Vim functionmzscheme-mzevalTo facilitate bi-directional interface, you can usemzeval() function toevaluateMzScheme expressions and pass their values to Vim script.==============================================================================6. Using Function referencesmzscheme-funcrefMzSchemeinterface allows use ofFuncrefs so you can call Vimfunctionsdirectly from Scheme.  For instance:    function! MyAdd2(arg)return a:arg + 2    endfunction    mz (define f2 (vim-eval "function(\"MyAdd2\")"))    mz (f2 7) or:    :mz (define indent (vim-eval "function('indent')"))    " return Vim indent for line 12    :mz (indent 12)==============================================================================7. Dynamic loadingmzscheme-dynamicE815OnMS-Windows theMzScheme libraries can be loaded dynamically.  The:versionoutput then includes+mzscheme/dyn.This means that Vim will search for theMzScheme DLL files only when needed.When you don't use theMzSchemeinterface you don't need them, thus you canuse Vim without these DLL files.NOTE: Newer version ofMzScheme (Racket) require earlier (trampolined)initialisation via scheme_main_setup.  So Vim always loads theMzScheme DLLatstartup if possible.  This may make Vimstartup slower.To use theMzSchemeinterface theMzScheme DLLsmust be in your search path.Ina consolewindow type "path" to see what directories are used.OnMS-Windows theoptions'mzschemedll' and'mzschemegcdll' are used for thename of the library to load.  The initial valueis specifiedat build time.The version of the DLLmust match theMzScheme version Vim was compiled with.ForMzScheme version 209 they will be "libmzsch209_000.dll" and"libmzgc209_000.dll".  To know for sure lookat the output of the ":version"command, look for -DDYNAMIC_MZSCH_DLL="something" and-DDYNAMIC_MZGC_DLL="something" in the "Compilation" info.For example, ifMzScheme (Racket)is installedat C:\Racket63, you may needto set the environment variableas the following:  PATH=%PATH%;C:\Racket63\lib  PLTCOLLECTS=C:\Racket63\collects  PLTCONFIGDIR=C:\Racket63\etc==============================================================================8.MzScheme setupmzscheme-setupE895Vim requires "racket/base" module for if_mzsch core (fallback to "scheme/base"ifit doesn't exist), "r5rs" module for test and "raco ctool" command forbuilding Vim.  IfMzScheme did not have them, you caninstall them withMzScheme's raco command:  raco pkg install scheme-lib       # scheme/base module  raco pkg install r5rs-lib         # r5rs module  raco pkg install cext-lib         # raco ctool command======================================================================  vim:tw=78:ts=8:noet:sts=4:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2026 Movatter.jp