]> granicus.if.org Git - vim/commitdiff
updated for version 7.1-215 v7.1.215
authorBram Moolenaar <Bram@vim.org>
Thu, 10 Jan 2008 21:24:39 +0000 (21:24 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Jan 2008 21:24:39 +0000 (21:24 +0000)
runtime/doc/eval.txt
src/eval.c
src/proto/syntax.pro
src/syntax.c
src/version.c

index c82a8f8ad5c53a056e92b99f1b42669106a51f93..97439fa98ccb7dd30001f818d6d280d568499d3f 100644 (file)
@@ -1,4 +1,4 @@
-*eval.txt*      For Vim version 7.1.  Last change: 2008 Jan 06
+*eval.txt*      For Vim version 7.1.  Last change: 2008 Jan 10
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1786,6 +1786,7 @@ synID( {lnum}, {col}, {trans})    Number  syntax ID at {lnum} and {col}
 synIDattr( {synID}, {what} [, {mode}])
                                String  attribute {what} of syntax ID {synID}
 synIDtrans( {synID})           Number  translated syntax ID of {synID}
+synstack({lnum}, {col})                List    stack of syntax IDs at {lnum} and {col}
 system( {expr} [, {input}])    String  output of shell command/filter {expr}
 tabpagebuflist( [{arg}])       List    list of buffer numbers in tab page
 tabpagenr( [{arg}])            Number  number of current or last tab page
@@ -4962,6 +4963,24 @@ synIDtrans({synID})                                      *synIDtrans()*
                highlight the character.  Highlight links given with
                ":highlight link" are followed.
 
+synstack({lnum}, {col})                                        *synstack()*
+               Return a |List|, which is the stack of syntax items at the
+               position {lnum} and {col} in the current window.  Each item in
+               the List is an ID like what |synID()| returns.
+               The stack is the situation in between the character at "col"
+               and the next character.  Note that a region of only one
+               character will not show up, it only exists inside that
+               character, not in between characters.
+               The first item in the List is the outer region, following are
+               items contained in that one.  The last one is what |synID()|
+               returns, unless not the whole item is highlighted or it is a
+               transparent item.
+               This function is useful for debugging a syntax file.
+               Example that shows the syntax stack under the cursor: >
+                       for id in synstack(line("."), col("."))
+                          echo synIDattr(id, "name")
+                       endfor
+
 system({expr} [, {input}])                             *system()* *E677*
                Get the output of the shell command {expr}.
                When {input} is given, this string is written to a file and
index 4afcb189cb947277c39364caa98551057fd1990b..ade6f5a1cea1117bc5ce5b3b004161a89d3460bd 100644 (file)
@@ -651,6 +651,7 @@ static void f_substitute __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_synID __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_synIDattr __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_synIDtrans __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_synstack __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_system __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_tabpagebuflist __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_tabpagenr __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7252,6 +7253,7 @@ static struct fst
     {"synID",          3, 3, f_synID},
     {"synIDattr",      2, 3, f_synIDattr},
     {"synIDtrans",     1, 1, f_synIDtrans},
+    {"synstack",       2, 2, f_synstack},
     {"system",         1, 2, f_system},
     {"tabpagebuflist", 0, 1, f_tabpagebuflist},
     {"tabpagenr",      0, 1, f_tabpagenr},
@@ -15845,6 +15847,46 @@ f_synIDtrans(argvars, rettv)
     rettv->vval.v_number = id;
 }
 
+/*
+ * "synstack(lnum, col)" function
+ */
+/*ARGSUSED*/
+    static void
+f_synstack(argvars, rettv)
+    typval_T   *argvars;
+    typval_T   *rettv;
+{
+#ifdef FEAT_SYN_HL
+    long       lnum;
+    long       col;
+    int                i;
+    int                id;
+#endif
+
+    rettv->v_type = VAR_LIST;
+    rettv->vval.v_list = NULL;
+
+#ifdef FEAT_SYN_HL
+    lnum = get_tv_lnum(argvars);               /* -1 on type error */
+    col = get_tv_number(&argvars[1]) - 1;      /* -1 on type error */
+
+    if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
+           && col >= 0 && col < (long)STRLEN(ml_get(lnum))
+           && rettv_list_alloc(rettv) != FAIL)
+    {
+       (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL);
+       for (i = 0; ; ++i)
+       {
+           id = syn_get_stack_item(i);
+           if (id < 0)
+               break;
+           if (list_append_number(rettv->vval.v_list, id) == FAIL)
+               break;
+       }
+    }
+#endif
+}
+
 /*
  * "system()" function
  */
index 4fe080136afbd06372e558fd12d9d4c845a1488c..b6f008f6fe75eee544c14136a642bd5c597e485d 100644 (file)
@@ -13,6 +13,7 @@ void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg));
 void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg));
 char_u *get_syntax_name __ARGS((expand_T *xp, int idx));
 int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp));
+int syn_get_stack_item __ARGS((int i));
 int syn_get_foldlevel __ARGS((win_T *wp, long lnum));
 void init_highlight __ARGS((int both, int reset));
 int load_colors __ARGS((char_u *name));
index e321313bedc91288d67a3b3dd356aade718d3a52..f9fbb0129c98328b24a8c8cc2be87ab16f03aa42 100644 (file)
@@ -6105,6 +6105,22 @@ syn_get_id(wp, lnum, col, trans, spellp)
     return (trans ? current_trans_id : current_id);
 }
 
+#if defined(FEAT_EVAL) || defined(PROTO)
+/*
+ * Return the syntax ID at position "i" in the current stack.
+ * The caller must have called syn_get_id() before to fill the stack.
+ * Returns -1 when "i" is out of range.
+ */
+    int
+syn_get_stack_item(i)
+    int i;
+{
+    if (i >= current_state.ga_len )
+       return -1;
+    return CUR_STATE(i).si_id;
+}
+#endif
+
 #if defined(FEAT_FOLDING) || defined(PROTO)
 /*
  * Function called to get folding level for line "lnum" in window "wp".
index 0723d53319daf0ffc483c6650dfb8b85d8a87ff8..35227e3d6c2cd8e0a4704f6073561cfa8152defb 100644 (file)
@@ -666,6 +666,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    215,
 /**/
     214,
 /**/