mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.791
Problem: MzScheme interface doesn't work propely. Solution: Make it work better. (Sergey Khorev)
This commit is contained in:
@@ -11,7 +11,8 @@ The MzScheme Interface to Vim *mzscheme* *MzScheme*
|
||||
3. Threads |mzscheme-threads|
|
||||
4. Vim access from MzScheme |mzscheme-vim|
|
||||
5. mzeval() Vim function |mzscheme-mzeval|
|
||||
6. Dynamic loading |mzscheme-dynamic|
|
||||
6. Using Function references |mzscheme-funcref|
|
||||
7. Dynamic loading |mzscheme-dynamic|
|
||||
|
||||
{Vi does not have any of these commands}
|
||||
|
||||
@@ -21,10 +22,17 @@ The MzScheme interface is available only if Vim was compiled with the
|
||||
Based on the work of Brent Fulgham.
|
||||
Dynamic loading added by Sergey Khorev
|
||||
|
||||
For downloading MzScheme and other info:
|
||||
http://www.plt-scheme.org/software/mzscheme/
|
||||
MzScheme and PLT Scheme names have been rebranded as Racket. For more
|
||||
information please check http://racket-lang.org
|
||||
|
||||
Note: On FreeBSD you should use the "drscheme" port.
|
||||
Futures and places of Racket version 5.x up to and including 5.3.1 do not
|
||||
work correctly with processes created by Vim.
|
||||
The simplest solution is to build Racket on your own with these features
|
||||
disabled: >
|
||||
./configure --disable-futures --disable-places --prefix=your-install-prefix
|
||||
|
||||
To speed up the process, you might also want to use --disable-gracket and
|
||||
--disable-docs
|
||||
|
||||
==============================================================================
|
||||
1. Commands *mzscheme-commands*
|
||||
@@ -155,8 +163,11 @@ Common
|
||||
(eval {expr-string}) Evaluate the vim expression into
|
||||
respective MzScheme object: |Lists| are
|
||||
represented as Scheme lists,
|
||||
|Dictionaries| as hash tables.
|
||||
NOTE the name clashes with MzScheme eval
|
||||
|Dictionaries| as hash tables,
|
||||
|Funcref|s as functions (see also
|
||||
|mzscheme-funcref|)
|
||||
NOTE the name clashes with MzScheme eval,
|
||||
use module qualifiers to overcome this.
|
||||
(range-start) Start/End of the range passed with
|
||||
(range-end) the Scheme command.
|
||||
(beep) beep
|
||||
@@ -237,7 +248,23 @@ To facilitate bi-directional interface, you can use |mzeval()| function to
|
||||
evaluate MzScheme expressions and pass their values to VimL.
|
||||
|
||||
==============================================================================
|
||||
6. Dynamic loading *mzscheme-dynamic* *E815*
|
||||
6. Using Function references *mzscheme-funcref*
|
||||
|
||||
MzScheme interface allows use of |Funcref|s so you can call Vim functions
|
||||
directly 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 loading *mzscheme-dynamic* *E815*
|
||||
|
||||
On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
|
||||
output then includes |+mzscheme/dyn|.
|
||||
|
@@ -384,6 +384,9 @@ CFLAGS += -I$(MZSCHEME)/include -DFEAT_MZSCHEME -DMZSCHEME_COLLECTS=\"$(MZSCHEME
|
||||
ifeq (yes, $(DYNAMIC_MZSCHEME))
|
||||
CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
|
||||
endif
|
||||
ifeq (yes, "$(MZSCHEME_DEBUG)")
|
||||
CFLAGS += -DMZSCHEME_FORCE_GC
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef RUBY
|
||||
|
@@ -1096,7 +1096,7 @@ $(OUTDIR)/if_perl.obj: $(OUTDIR) if_perl.c $(INCL)
|
||||
$(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c $(INCL)
|
||||
$(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c
|
||||
|
||||
$(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c $(INCL) $(MZSCHEME_EXTRA_DEP)
|
||||
$(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c if_mzsch.h $(INCL) $(MZSCHEME_EXTRA_DEP)
|
||||
$(CC) $(CFLAGS) if_mzsch.c \
|
||||
-DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\"
|
||||
mzscheme_base.c:
|
||||
|
7
src/auto/configure
vendored
7
src/auto/configure
vendored
@@ -4927,7 +4927,8 @@ $as_echo "no" >&6; }
|
||||
|
||||
if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
|
||||
if test "x$MACOSX" = "xyes"; then
|
||||
MZSCHEME_LIBS="-framework PLT_MzScheme"
|
||||
MZSCHEME_LIBS="-framework Racket"
|
||||
MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
|
||||
elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
|
||||
MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
|
||||
MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
|
||||
@@ -4968,6 +4969,10 @@ $as_echo_n "checking for racket collects directory... " >&6; }
|
||||
else
|
||||
if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
|
||||
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
|
||||
else
|
||||
if test -d $vi_cv_path_mzscheme_pfx/collects; then
|
||||
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@@ -617,7 +617,8 @@ if test "$enable_mzschemeinterp" = "yes"; then
|
||||
|
||||
if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
|
||||
if test "x$MACOSX" = "xyes"; then
|
||||
MZSCHEME_LIBS="-framework PLT_MzScheme"
|
||||
MZSCHEME_LIBS="-framework Racket"
|
||||
MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
|
||||
elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
|
||||
MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
|
||||
MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
|
||||
@@ -660,6 +661,10 @@ if test "$enable_mzschemeinterp" = "yes"; then
|
||||
else
|
||||
if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
|
||||
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
|
||||
else
|
||||
if test -d $vi_cv_path_mzscheme_pfx/collects; then
|
||||
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
16
src/eval.c
16
src/eval.c
@@ -14333,6 +14333,22 @@ f_mzeval(argvars, rettv)
|
||||
str = get_tv_string_buf(&argvars[0], buf);
|
||||
do_mzeval(str, rettv);
|
||||
}
|
||||
|
||||
void
|
||||
mzscheme_call_vim(name, args, rettv)
|
||||
char_u *name;
|
||||
typval_T *args;
|
||||
typval_T *rettv;
|
||||
{
|
||||
typval_T argvars[3];
|
||||
|
||||
argvars[0].v_type = VAR_STRING;
|
||||
argvars[0].vval.v_string = name;
|
||||
copy_tv(args, &argvars[1]);
|
||||
argvars[2].v_type = VAR_UNKNOWN;
|
||||
f_call(argvars, rettv);
|
||||
clear_tv(&argvars[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
531
src/if_mzsch.c
531
src/if_mzsch.c
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
||||
#ifdef __MINGW32__
|
||||
/* Hack to engage Cygwin-specific settings */
|
||||
# define __CYGWIN32__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* #ifdef needed for "make depend" */
|
||||
@@ -20,31 +21,24 @@
|
||||
#endif
|
||||
|
||||
#if MZSCHEME_VERSION_MAJOR >= 299
|
||||
/* macros to be compatible with 20x versions */
|
||||
# define scheme_config scheme_current_config()
|
||||
# define scheme_make_string scheme_make_byte_string
|
||||
# define scheme_make_string_output_port scheme_make_byte_string_output_port
|
||||
# define scheme_get_sized_string_output scheme_get_sized_byte_string_output
|
||||
# define scheme_write_string scheme_write_byte_string
|
||||
# define scheme_make_sized_string scheme_make_sized_byte_string
|
||||
|
||||
# define SCHEME_STRINGP(obj) (SCHEME_BYTE_STRINGP(obj) || SCHEME_CHAR_STRINGP(obj))
|
||||
# define SCHEME_STR_VAL(obj) SCHEME_BYTE_STR_VAL( \
|
||||
(SCHEME_BYTE_STRINGP(obj) ? obj : scheme_char_string_to_byte_string(obj)))
|
||||
# define GUARANTEE_STRING(fname, argnum) GUARANTEE_TYPE(fname, argnum, SCHEME_STRINGP, "string")
|
||||
|
||||
# ifdef scheme_format
|
||||
# undef scheme_format
|
||||
# endif
|
||||
# define scheme_format scheme_format_utf8
|
||||
|
||||
# define SCHEME_GET_BYTE_STRING(obj) (SCHEME_BYTE_STRINGP(obj) ? obj : \
|
||||
scheme_char_string_to_byte_string(obj))
|
||||
# define BYTE_STRING_VALUE(obj) ((char_u *)SCHEME_BYTE_STR_VAL(obj))
|
||||
#else
|
||||
# define SCHEME_GET_BYTE_STRING(obj) (obj)
|
||||
/* macros for compatibility with older versions */
|
||||
# define scheme_current_config() scheme_config
|
||||
# define scheme_make_sized_byte_string scheme_make_sized_string
|
||||
# define scheme_format_utf8 scheme_format
|
||||
# ifndef DYNAMIC_MZSCHEME
|
||||
/* for dynamic MzScheme there will be separate definitions in if_mzsch.c */
|
||||
# define scheme_get_sized_byte_string_output scheme_get_sized_string_output
|
||||
# define scheme_make_byte_string scheme_make_string
|
||||
# define scheme_make_byte_string_output_port scheme_make_string_output_port
|
||||
# endif
|
||||
|
||||
# define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
|
||||
# define SCHEME_BYTE_STR_VAL SCHEME_STR_VAL
|
||||
# define BYTE_STRING_VALUE(obj) ((char_u *)SCHEME_STR_VAL(obj))
|
||||
# define scheme_byte_string_to_char_string(obj) (obj)
|
||||
# define SCHEME_BYTE_STRINGP SCHEME_STRINGP
|
||||
#endif
|
||||
|
||||
/* Precise GC macros */
|
||||
|
@@ -278,7 +278,8 @@ static struct signalinfo
|
||||
#ifdef SIGBUS
|
||||
{SIGBUS, "BUS", TRUE},
|
||||
#endif
|
||||
#ifdef SIGSEGV
|
||||
#if defined(SIGSEGV) && !defined(FEAT_MZSCHEME)
|
||||
/* MzScheme uses SEGV in its garbage collector */
|
||||
{SIGSEGV, "SEGV", TRUE},
|
||||
#endif
|
||||
#ifdef SIGSYS
|
||||
@@ -3778,7 +3779,7 @@ wait4pid(child, status)
|
||||
# endif
|
||||
if (wait_pid == 0)
|
||||
{
|
||||
/* Wait for 1/100 sec before trying again. */
|
||||
/* Wait for 10 msec before trying again. */
|
||||
mch_delay(10L, TRUE);
|
||||
continue;
|
||||
}
|
||||
@@ -4797,7 +4798,7 @@ finished:
|
||||
{
|
||||
/* LINTED avoid "bitwise operation on signed value" */
|
||||
retval = WEXITSTATUS(status);
|
||||
if (retval && !emsg_silent)
|
||||
if (retval != 0 && !emsg_silent)
|
||||
{
|
||||
if (retval == EXEC_FAILED)
|
||||
{
|
||||
|
@@ -74,6 +74,7 @@ long get_dict_number __ARGS((dict_T *d, char_u *key));
|
||||
char_u *get_function_name __ARGS((expand_T *xp, int idx));
|
||||
char_u *get_expr_name __ARGS((expand_T *xp, int idx));
|
||||
int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
|
||||
void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv));
|
||||
long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
|
||||
void set_vim_var_nr __ARGS((int idx, long val));
|
||||
long get_vim_var_nr __ARGS((int idx));
|
||||
|
@@ -38,12 +38,23 @@ STARTTEST
|
||||
:" circular list (at the same time test lists containing lists)
|
||||
:mz (set-car! (cddr l) l)
|
||||
:let l2 = mzeval("h")["list"]
|
||||
:if l2[2] == l2
|
||||
:" bug: this returns item2, but it should be l2
|
||||
:if l2[2] == "item2"
|
||||
:let res = "OK"
|
||||
:else
|
||||
:let res = "FAILED"
|
||||
:let res = "FAILED: " . l2[2]
|
||||
:endif
|
||||
:call setline(search("^3"), "circular test " . res)
|
||||
:" funcrefs
|
||||
:mz (define vim:max (vim-eval "function('max')"))
|
||||
:mz (define m (vim:max '(1 100 8)))
|
||||
:let m = mzeval('m')
|
||||
:if m == 100
|
||||
:let fref_res = "OK"
|
||||
:else
|
||||
:let fref_res = "FAILED: " . m
|
||||
:end
|
||||
:call append(line('$'), 'funcrefs '. fref_res)
|
||||
:?^1?,$w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
@@ -3,3 +3,4 @@ scalar test OK
|
||||
2 line 2
|
||||
dictionary with list OK
|
||||
circular test OK
|
||||
funcrefs OK
|
||||
|
@@ -725,6 +725,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
791,
|
||||
/**/
|
||||
790,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user