Skip to content

Commit

Permalink
updated for version 7.2.336
Browse files Browse the repository at this point in the history
Problem:    MzScheme interface can't evaluate an expression.
Solution:   Add mzeval(). (Sergey Khorev)
  • Loading branch information
Bram Moolenaar committed Jan 19, 2010
1 parent 9590862 commit 588c51a
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 22 deletions.
18 changes: 18 additions & 0 deletions runtime/doc/eval.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,7 @@ min( {list}) Number minimum value of items in {list}
mkdir( {name} [, {path} [, {prot}]])
Number create directory {name}
mode( [expr]) String current editing mode
mzeval( {expr}) any evaluate |MzScheme| expression
nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum}
nr2char( {expr}) String single char with ASCII value {expr}
pathshorten( {expr}) String shorten directory names in a path
Expand Down Expand Up @@ -4102,6 +4103,23 @@ mode([expr]) Return a string that indicates the current mode.
"c" or "n".
Also see |visualmode()|.

mzeval({expr}) *mzeval()*
Evaluate MzScheme expression {expr} and return its result
convert to Vim data structures.
Numbers and strings are returned as they are.
Pairs (including lists and improper lists) and vectors are
returned as Vim |Lists|.
Hash tables are represented as Vim |Dictionary| type with keys
converted to strings.
All other types are converted to string with display function.
Examples: >
:mz (define l (list 1 2 3))
:mz (define h (make-hash)) (hash-set! h "list" l)
:echo mzeval("l")
:echo mzeval("h")
<
{only available when compiled with the |+mzscheme| feature}

nextnonblank({lnum}) *nextnonblank()*
Return the line number of the first line at or below {lnum}
that is not blank. Example: >
Expand Down
17 changes: 12 additions & 5 deletions runtime/doc/if_mzsch.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*if_mzsch.txt* For Vim version 7.2. Last change: 2009 Jun 24
*if_mzsch.txt* For Vim version 7.2. Last change: 2010 Jan 19


VIM REFERENCE MANUAL by Sergey Khorev
Expand All @@ -9,8 +9,9 @@ The MzScheme Interface to Vim *mzscheme* *MzScheme*
1. Commands |mzscheme-commands|
2. Examples |mzscheme-examples|
3. Threads |mzscheme-threads|
4. The Vim access procedures |mzscheme-vim|
5. Dynamic loading |mzscheme-dynamic|
4. Vim access from MzScheme |mzscheme-vim|
5. mzeval() Vim function |mzscheme-mzeval|
6. Dynamic loading |mzscheme-dynamic|

{Vi does not have any of these commands}

Expand Down Expand Up @@ -142,7 +143,7 @@ Thread scheduling in the console version of Vim is less reliable than in the
GUI version.

==============================================================================
5. VIM Functions *mzscheme-vim*
4. Vim access from MzScheme *mzscheme-vim*

*mzscheme-vimext*
The 'vimext' module provides access to procedures defined in the MzScheme
Expand Down Expand Up @@ -231,7 +232,13 @@ Windows *mzscheme-window*
(set-cursor (line . col) [window]) Set cursor position.

==============================================================================
5. Dynamic loading *mzscheme-dynamic* *E815*
5. mzeval() Vim function *mzscheme-mzeval*

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*

On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
output then includes |+mzscheme/dyn|.
Expand Down
2 changes: 2 additions & 0 deletions runtime/doc/usr_41.txt
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ Various:
taglist() get list of matching tags
tagfiles() get a list of tags files

mzeval() evaluate |MzScheme| expression

==============================================================================
*41.7* Defining a function

Expand Down
38 changes: 28 additions & 10 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ static listitem_T *list_find __ARGS((list_T *l, long n));
static long list_find_nr __ARGS((list_T *l, long idx, int *errorp));
static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
static void list_append __ARGS((list_T *l, listitem_T *item));
static int list_append_tv __ARGS((list_T *l, typval_T *tv));
static int list_append_number __ARGS((list_T *l, varnumber_T n));
static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
static int list_extend __ARGS((list_T *l1, list_T *l2, listitem_T *bef));
Expand All @@ -448,12 +447,9 @@ static void set_ref_in_list __ARGS((list_T *l, int copyID));
static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
static void dict_unref __ARGS((dict_T *d));
static void dict_free __ARGS((dict_T *d, int recurse));
static dictitem_T *dictitem_alloc __ARGS((char_u *key));
static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item));
static void dictitem_free __ARGS((dictitem_T *item));
static dict_T *dict_copy __ARGS((dict_T *orig, int deep, int copyID));
static int dict_add __ARGS((dict_T *d, dictitem_T *item));
static long dict_len __ARGS((dict_T *d));
static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
static char_u *dict2string __ARGS((typval_T *tv, int copyID));
Expand Down Expand Up @@ -628,6 +624,9 @@ static void f_min __ARGS((typval_T *argvars, typval_T *rettv));
static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv));
#endif
static void f_mode __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_MZSCHEME
static void f_mzeval __ARGS((typval_T *argvars, typval_T *rettv));
#endif
static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv));
Expand Down Expand Up @@ -764,7 +763,6 @@ static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
static int var_check_ro __ARGS((int flags, char_u *name));
static int var_check_fixed __ARGS((int flags, char_u *name));
static int tv_check_lock __ARGS((int lock, char_u *name));
static void copy_tv __ARGS((typval_T *from, typval_T *to));
static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
Expand Down Expand Up @@ -6155,7 +6153,7 @@ list_append(l, item)
* Append typval_T "tv" to the end of list "l".
* Return FAIL when out of memory.
*/
static int
int
list_append_tv(l, tv)
list_T *l;
typval_T *tv;
Expand Down Expand Up @@ -6812,7 +6810,7 @@ dict_free(d, recurse)
* Note that the value of the item "di_tv" still needs to be initialized!
* Returns NULL when out of memory.
*/
static dictitem_T *
dictitem_T *
dictitem_alloc(key)
char_u *key;
{
Expand Down Expand Up @@ -6868,7 +6866,7 @@ dictitem_remove(dict, item)
/*
* Free a dict item. Also clears the value.
*/
static void
void
dictitem_free(item)
dictitem_T *item;
{
Expand Down Expand Up @@ -6948,7 +6946,7 @@ dict_copy(orig, deep, copyID)
* Add item "item" to Dictionary "d".
* Returns FAIL when out of memory and when key already existed.
*/
static int
int
dict_add(d, item)
dict_T *d;
dictitem_T *item;
Expand Down Expand Up @@ -7699,6 +7697,9 @@ static struct fst
{"mkdir", 1, 3, f_mkdir},
#endif
{"mode", 0, 1, f_mode},
#ifdef FEAT_MZSCHEME
{"mzeval", 1, 1, f_mzeval},
#endif
{"nextnonblank", 1, 1, f_nextnonblank},
{"nr2char", 1, 1, f_nr2char},
{"pathshorten", 1, 1, f_pathshorten},
Expand Down Expand Up @@ -13591,6 +13592,23 @@ f_mode(argvars, rettv)
rettv->v_type = VAR_STRING;
}

#ifdef FEAT_MZSCHEME
/*
* "mzeval()" function
*/
static void
f_mzeval(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
char_u *str;
char_u buf[NUMBUFLEN];

str = get_tv_string_buf(&argvars[0], buf);
do_mzeval(str, rettv);
}
#endif

/*
* "nextnonblank()" function
*/
Expand Down Expand Up @@ -19274,7 +19292,7 @@ tv_check_lock(lock, name)
* It is OK for "from" and "to" to point to the same item. This is used to
* make a copy later.
*/
static void
void
copy_tv(from, to)
typval_T *from;
typval_T *to;
Expand Down
Loading

0 comments on commit 588c51a

Please sign in to comment.