Skip to content

Commit

Permalink
Merged from the latest developing branch.
Browse files Browse the repository at this point in the history
git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1497 2a77ed30-b011-0410-a7ad-c7884a0aa172
  • Loading branch information
edyfox committed May 27, 2009
1 parent 90f02ca commit 24fa017
Show file tree
Hide file tree
Showing 15 changed files with 1,166 additions and 561 deletions.
97 changes: 39 additions & 58 deletions runtime/doc/if_mzsch.txt
@@ -1,4 +1,4 @@
*if_mzsch.txt* For Vim version 7.2. Last change: 2008 Jun 28 *if_mzsch.txt* For Vim version 7.2. Last change: 2009 May 26




VIM REFERENCE MANUAL by Sergey Khorev VIM REFERENCE MANUAL by Sergey Khorev
Expand Down Expand Up @@ -42,10 +42,6 @@ Note: On FreeBSD you should use the "drscheme" port.


*:mzfile* *:mzf* *:mzfile* *:mzf*
:[range]mzf[ile] {file} Execute the MzScheme script in {file}. {not in Vi} :[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 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 MzScheme code, with the "current range" set to the given line
Expand All @@ -54,8 +50,6 @@ range.
In the case of :mzscheme, the code to execute is in the command-line. 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. 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. MzScheme interface defines exception exn:vim, derived from exn.
It is raised for various Vim errors. It is raised for various Vim errors.


Expand All @@ -79,40 +73,8 @@ To avoid clashes with MzScheme, consider using prefix when requiring module,
e.g.: > e.g.: >
:mzscheme (require (prefix vim- vimext)) :mzscheme (require (prefix vim- vimext))
< <
All the examples below assume this naming scheme. Note that you need to do All the examples below assume this naming scheme.
this again for every buffer.


The auto-instantiation can be achieved with autocommands, e.g. you can put
something like this in your .vimrc (EOFs should not have indentation): >
function s:MzRequire()
if has("mzscheme")
:mz << EOF
(require (prefix vim- vimext))
(let ((buf (vim-get-buff-by-name (vim-eval "expand(\"<afile>\")"))))
(when (and buf (not (eq? buf (vim-curr-buff))))
(parameterize ((current-namespace (vim-get-buff-namespace buf)))
(namespace-attach-module vim-global-namespace 'vimext)
(namespace-require '(prefix vim vimext)))))
EOF
endif
endfunction
function s:MzStartup()
if has("mzscheme")
au BufNew,BufNewFile,BufAdd,BufReadPre * :call s:MzRequire()
:mz << EOF
(current-library-collection-paths
(cons
(build-path (find-system-path 'addon-dir) (version) "collects")
(current-library-collection-paths)))
EOF
endif
endfunction
call s:MzStartup()
<

The global namespace just instantiated this module with the prefix "vimext:".
*mzscheme-sandbox* *mzscheme-sandbox*
When executed in the |sandbox|, access to some filesystem and Vim interface When executed in the |sandbox|, access to some filesystem and Vim interface
procedures is restricted. procedures is restricted.
Expand All @@ -121,33 +83,54 @@ procedures is restricted.
2. Examples *mzscheme-examples* 2. Examples *mzscheme-examples*
> >
:mzscheme (display "Hello") :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") :mzscheme (vim-set-buff-line 10 "This is line #10")
< <
Inline script usage: > Inline script usage: >
function! <SID>SetFirstLine() function! <SID>SetFirstLine()
:mz << EOF :mz << EOF
(display "!!!") (display "!!!")
(require (prefix vim- vimext))
; for newer versions (require (prefix-in vim- 'vimext))
(vim-set-buff-line 1 "This is line #1") (vim-set-buff-line 1 "This is line #1")
(vim-beep) (vim-beep)
EOF EOF
endfunction endfunction
nmap <F9> :call <SID>SetFirstLine() <CR> nmap <F9> :call <SID>SetFirstLine() <CR>
< <
File execution: > File execution: >
:mzfile supascript.scm :mzfile supascript.scm
< <
Accessing the current buffer namespace from an MzScheme program running in Vim exception handling: >
another buffer within |:mzfile|-executed script : > :mz << EOF
; Move to the window below (require (prefix vim- vimext))
(vim-command "wincmd j") ; for newer versions (require (prefix-in vim- 'vimext))
; execute in the context of buffer, to which window belongs (with-handlers
; assume that buffer has 'textstring' defined ([exn:vim? (lambda (e) (display (exn-message e)))])
(parameterize ((current-namespace (vim-eval "nonsense-string"))
(vim-get-buff-namespace (vim-curr-buff)))) EOF
(eval '(vim-set-buff-line 1 textstring)))
< <
Auto-instantiation of vimext module (can be placed in your |vimrc|): >
function! MzRequire()
:redir => l:mzversion
:mz (version)
:redir END
if 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. Threads *mzscheme-threads* 3. Threads *mzscheme-threads*


Expand All @@ -168,11 +151,11 @@ interface.
Common Common
------ ------
(command {command-string}) Perform the vim ":Ex" style command. (command {command-string}) Perform the vim ":Ex" style command.
(eval {expr-string}) Evaluate the vim expression to a string. (eval {expr-string}) Evaluate the vim expression into
A |List| is turned into a string by respective MzScheme object: |Lists| are
joining the items and inserting line represented as Scheme lists,
breaks. |Dictionaries| as hash tables.
NOTE clashes with MzScheme eval NOTE the name clashes with MzScheme eval
(range-start) Start/End of the range passed with (range-start) Start/End of the range passed with
(range-end) the Scheme command. (range-end) the Scheme command.
(beep) beep (beep) beep
Expand All @@ -186,7 +169,6 @@ Common
be set. The symbol 'global can be passed be set. The symbol 'global can be passed
as {buffer-or-window}. Then |:setglobal| as {buffer-or-window}. Then |:setglobal|
will be used. will be used.
global-namespace The MzScheme main namespace.


Buffers *mzscheme-buffer* Buffers *mzscheme-buffer*
------- -------
Expand Down Expand Up @@ -228,7 +210,6 @@ Buffers *mzscheme-buffer*
if there is no such buffer. if there is no such buffer.
(get-buff-by-num {buffernum}) Get a buffer by its number (return #f if (get-buff-by-num {buffernum}) Get a buffer by its number (return #f if
there is no buffer with this number). there is no buffer with this number).
(get-buff-namespace [buffer]) Get buffer namespace.


Windows *mzscheme-window* Windows *mzscheme-window*
------ ------
Expand All @@ -250,7 +231,7 @@ Windows *mzscheme-window*
(set-cursor (line . col) [window]) Set cursor position. (set-cursor (line . col) [window]) Set cursor position.


============================================================================== ==============================================================================
5. Dynamic loading *mzscheme-dynamic* 5. Dynamic loading *mzscheme-dynamic* *E812*


On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version| On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
output then includes |+mzscheme/dyn|. output then includes |+mzscheme/dyn|.
Expand Down
26 changes: 26 additions & 0 deletions src/Make_ming.mak
Expand Up @@ -115,8 +115,21 @@ ifndef MZSCHEME_VER
MZSCHEME_VER=205_000 MZSCHEME_VER=205_000
endif endif


ifndef MZSCHEME_PRECISE_GC
MZSCHEME_PRECISE_GC=no
endif

# for version 4.x we need to generate byte-code for Scheme base
ifndef MZSCHEME_GENERATE_BASE
MZSCHEME_GENERATE_BASE=no
endif

ifeq (no,$(DYNAMIC_MZSCHEME)) ifeq (no,$(DYNAMIC_MZSCHEME))
ifeq (yes,$(MZSCHEME_PRECISE_GC))
MZSCHEME_LIB=-lmzsch$(MZSCHEME_VER)
else
MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER) MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER)
endif
# the modern MinGW can dynamically link to dlls directly. # the modern MinGW can dynamically link to dlls directly.
# point MZSCHEME_DLLS to where you put libmzschXXXXXXX.dll and libgcXXXXXXX.dll # point MZSCHEME_DLLS to where you put libmzschXXXXXXX.dll and libgcXXXXXXX.dll
ifndef MZSCHEME_DLLS ifndef MZSCHEME_DLLS
Expand Down Expand Up @@ -410,6 +423,13 @@ endif
ifdef MZSCHEME ifdef MZSCHEME
OBJ += $(OUTDIR)/if_mzsch.o OBJ += $(OUTDIR)/if_mzsch.o
MZSCHEME_INCL = if_mzsch.h MZSCHEME_INCL = if_mzsch.h
ifeq (yes,$(MZSCHEME_GENERATE_BASE))
CFLAGS += -DINCLUDE_MZSCHEME_BASE
MZ_EXTRA_DEP += mzscheme_base.c
endif
ifeq (yes,$(MZSCHEME_PRECISE_GC))
CFLAGS += -DMZ_PRECISE_GC
endif
endif endif
ifdef PYTHON ifdef PYTHON
OBJ += $(OUTDIR)/if_python.o OBJ += $(OUTDIR)/if_python.o
Expand Down Expand Up @@ -588,6 +608,12 @@ if_perl.c: if_perl.xs typemap
$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC) $(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
$(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o


$(OUTDIR)/if_mzsch.o: if_mzsch.c $(INCL) if_mzsch.h $(MZ_EXTRA_DEP)
$(CC) -c $(CFLAGS) if_mzsch.c -o $(OUTDIR)/if_mzsch.o

mzscheme_base.c:
$(MZSCHEME)/mzc --c-mods mzscheme_base.c ++lib scheme/base

pathdef.c: $(INCL) pathdef.c: $(INCL)
ifneq (sh.exe, $(SHELL)) ifneq (sh.exe, $(SHELL))
@echo creating pathdef.c @echo creating pathdef.c
Expand Down
27 changes: 26 additions & 1 deletion src/Make_mvc.mak
Expand Up @@ -34,6 +34,7 @@
# MZSCHEME=[Path to MzScheme directory] # MZSCHEME=[Path to MzScheme directory]
# DYNAMIC_MZSCHEME=yes (to load the MzScheme DLLs dynamically) # DYNAMIC_MZSCHEME=yes (to load the MzScheme DLLs dynamically)
# MZSCHEME_VER=[version, 205_000, ...] # MZSCHEME_VER=[version, 205_000, ...]
# MZSCHEME_DEBUG=no
# #
# Perl interface: # Perl interface:
# PERL=[Path to Perl directory] # PERL=[Path to Perl directory]
Expand Down Expand Up @@ -621,15 +622,37 @@ PYTHON_LIB = $(PYTHON)\libs\python$(PYTHON_VER).lib
MZSCHEME_VER = 205_000 MZSCHEME_VER = 205_000
!endif !endif
CFLAGS = $(CFLAGS) -DFEAT_MZSCHEME -I $(MZSCHEME)\include CFLAGS = $(CFLAGS) -DFEAT_MZSCHEME -I $(MZSCHEME)\include
!if EXIST("$(MZSCHEME)\collects\scheme\base.ss")
# for MzScheme 4.x we need to include byte code for basic Scheme stuff
MZSCHEME_EXTRA_DEP = mzscheme_base.c
CFLAGS = $(CFLAGS) -DINCLUDE_MZSCHEME_BASE
!endif
!if EXIST("$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib") \
&& !EXIST("$(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib")
!message Building with Precise GC
MZSCHEME_PRECISE_GC = yes
CFLAGS = $(CFLAGS) -DMZ_PRECISE_GC
!endif
!if "$(DYNAMIC_MZSCHEME)" == "yes" !if "$(DYNAMIC_MZSCHEME)" == "yes"
!if "$(MZSCHEME_PRECISE_GC)" == "yes"
!error MzScheme with Precise GC cannot be loaded dynamically
!endif
!message MzScheme DLLs will be loaded dynamically !message MzScheme DLLs will be loaded dynamically
CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME \ CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME \
-DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" \ -DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" \
-DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
!else !else
!if "$(MZSCHEME_DEBUG)" == "yes"
CFLAGS = $(CFLAGS) -DMZSCHEME_FORCE_GC
!endif
!if "$(MZSCHEME_PRECISE_GC)" == "yes"
# Precise GC does not use separate dll
MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib
!else
MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \ MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \
$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib $(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib
!endif !endif
!endif
MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj
!endif !endif


Expand Down Expand Up @@ -930,9 +953,11 @@ $(OUTDIR)/if_perl.obj: $(OUTDIR) if_perl.c $(INCL)
$(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c $(INCL) $(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c $(INCL)
$(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c $(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c


$(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c $(INCL) $(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c $(INCL) $(MZSCHEME_EXTRA_DEP)
$(CC) $(CFLAGS) if_mzsch.c \ $(CC) $(CFLAGS) if_mzsch.c \
-DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\" -DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\"
mzscheme_base.c:
$(MZSCHEME)\mzc --c-mods mzscheme_base.c ++lib scheme/base


$(OUTDIR)/if_python.obj: $(OUTDIR) if_python.c $(INCL) $(OUTDIR)/if_python.obj: $(OUTDIR) if_python.c $(INCL)
$(CC) $(CFLAGS) $(PYTHON_INC) if_python.c $(CC) $(CFLAGS) $(PYTHON_INC) if_python.c
Expand Down
8 changes: 6 additions & 2 deletions src/Makefile
Expand Up @@ -536,7 +536,7 @@ CClink = $(CC)
# Use this with GCC to check for mistakes, unused arguments, etc. # Use this with GCC to check for mistakes, unused arguments, etc.
#CFLAGS = -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code #CFLAGS = -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code
#PYTHON_CFLAGS_EXTRA = -Wno-missing-field-initializers #PYTHON_CFLAGS_EXTRA = -Wno-missing-field-initializers
#MZSCHEME_CFLAGS_EXTRA = -Wno-unreachable-code #MZSCHEME_CFLAGS_EXTRA = -Wno-unreachable-code -Wno-unused-parameter


# EFENCE - Electric-Fence malloc debugging: catches memory accesses beyond # EFENCE - Electric-Fence malloc debugging: catches memory accesses beyond
# allocated memory (and makes every malloc()/free() very slow). # allocated memory (and makes every malloc()/free() very slow).
Expand Down Expand Up @@ -2200,6 +2200,7 @@ clean celan: testclean
-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c
-rm -f conftest* *~ auto/link.sed -rm -f conftest* *~ auto/link.sed
-rm -rf $(APPDIR) -rm -rf $(APPDIR)
-rm -rf mzscheme_base.c
if test -d $(PODIR); then \ if test -d $(PODIR); then \
cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \ cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \
fi fi
Expand Down Expand Up @@ -2433,8 +2434,11 @@ objects/if_cscope.o: if_cscope.c
objects/if_xcmdsrv.o: if_xcmdsrv.c objects/if_xcmdsrv.o: if_xcmdsrv.c
$(CCC) -o $@ if_xcmdsrv.c $(CCC) -o $@ if_xcmdsrv.c


objects/if_mzsch.o: if_mzsch.c objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c $(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c

mzscheme_base.c:
$(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base


objects/if_perl.o: auto/if_perl.c objects/if_perl.o: auto/if_perl.c
$(CCC) -o $@ auto/if_perl.c $(CCC) -o $@ auto/if_perl.c
Expand Down

0 comments on commit 24fa017

Please sign in to comment.