4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: It is difficult to figure out what syntax items are nested at a
13 Solution: Add the synstack() function.
14 Files: runtime/doc/eval.txt, src/eval.c, src/proto/syntax.pro,
18 *** ../vim-7.1.214/runtime/doc/eval.txt Sun Jan 6 20:05:36 2008
19 --- runtime/doc/eval.txt Thu Jan 10 22:20:31 2008
22 ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 06
25 VIM REFERENCE MANUAL by Bram Moolenaar
27 ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 10
30 VIM REFERENCE MANUAL by Bram Moolenaar
34 synIDattr( {synID}, {what} [, {mode}])
35 String attribute {what} of syntax ID {synID}
36 synIDtrans( {synID}) Number translated syntax ID of {synID}
37 + synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col}
38 system( {expr} [, {input}]) String output of shell command/filter {expr}
39 tabpagebuflist( [{arg}]) List list of buffer numbers in tab page
40 tabpagenr( [{arg}]) Number number of current or last tab page
44 highlight the character. Highlight links given with
45 ":highlight link" are followed.
47 + synstack({lnum}, {col}) *synstack()*
48 + Return a |List|, which is the stack of syntax items at the
49 + position {lnum} and {col} in the current window. Each item in
50 + the List is an ID like what |synID()| returns.
51 + The stack is the situation in between the character at "col"
52 + and the next character. Note that a region of only one
53 + character will not show up, it only exists inside that
54 + character, not in between characters.
55 + The first item in the List is the outer region, following are
56 + items contained in that one. The last one is what |synID()|
57 + returns, unless not the whole item is highlighted or it is a
59 + This function is useful for debugging a syntax file.
60 + Example that shows the syntax stack under the cursor: >
61 + for id in synstack(line("."), col("."))
62 + echo synIDattr(id, "name")
65 system({expr} [, {input}]) *system()* *E677*
66 Get the output of the shell command {expr}.
67 When {input} is given, this string is written to a file and
68 *** ../vim-7.1.214/src/eval.c Sun Jan 6 20:05:36 2008
69 --- src/eval.c Wed Jan 9 13:42:56 2008
73 static void f_synID __ARGS((typval_T *argvars, typval_T *rettv));
74 static void f_synIDattr __ARGS((typval_T *argvars, typval_T *rettv));
75 static void f_synIDtrans __ARGS((typval_T *argvars, typval_T *rettv));
76 + static void f_synstack __ARGS((typval_T *argvars, typval_T *rettv));
77 static void f_system __ARGS((typval_T *argvars, typval_T *rettv));
78 static void f_tabpagebuflist __ARGS((typval_T *argvars, typval_T *rettv));
79 static void f_tabpagenr __ARGS((typval_T *argvars, typval_T *rettv));
83 {"synID", 3, 3, f_synID},
84 {"synIDattr", 2, 3, f_synIDattr},
85 {"synIDtrans", 1, 1, f_synIDtrans},
86 + {"synstack", 2, 2, f_synstack},
87 {"system", 1, 2, f_system},
88 {"tabpagebuflist", 0, 1, f_tabpagebuflist},
89 {"tabpagenr", 0, 1, f_tabpagenr},
95 rettv->vval.v_number = id;
99 + * "synstack(lnum, col)" function
103 + f_synstack(argvars, rettv)
114 + rettv->v_type = VAR_LIST;
115 + rettv->vval.v_list = NULL;
118 + lnum = get_tv_lnum(argvars); /* -1 on type error */
119 + col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */
121 + if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
122 + && col >= 0 && col < (long)STRLEN(ml_get(lnum))
123 + && rettv_list_alloc(rettv) != FAIL)
125 + (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL);
128 + id = syn_get_stack_item(i);
131 + if (list_append_number(rettv->vval.v_list, id) == FAIL)
139 *** ../vim-7.1.214/src/proto/syntax.pro Tue Jul 24 14:32:44 2007
140 --- src/proto/syntax.pro Wed Jan 9 13:38:20 2008
144 void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg));
145 char_u *get_syntax_name __ARGS((expand_T *xp, int idx));
146 int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp));
147 + int syn_get_stack_item __ARGS((int i));
148 int syn_get_foldlevel __ARGS((win_T *wp, long lnum));
149 void init_highlight __ARGS((int both, int reset));
150 int load_colors __ARGS((char_u *name));
151 *** ../vim-7.1.214/src/syntax.c Sun Oct 7 15:21:31 2007
152 --- src/syntax.c Wed Jan 9 15:17:47 2008
157 return (trans ? current_trans_id : current_id);
160 + #if defined(FEAT_EVAL) || defined(PROTO)
162 + * Return the syntax ID at position "i" in the current stack.
163 + * The caller must have called syn_get_id() before to fill the stack.
164 + * Returns -1 when "i" is out of range.
167 + syn_get_stack_item(i)
170 + if (i >= current_state.ga_len )
172 + return CUR_STATE(i).si_id;
176 #if defined(FEAT_FOLDING) || defined(PROTO)
178 *** ../vim-7.1.214/src/version.c Wed Jan 9 22:39:55 2008
179 --- src/version.c Thu Jan 10 22:17:38 2008
183 { /* Add new patch number below this line */
189 TALL KNIGHT: We are now no longer the Knights Who Say Ni!
192 ONE KNIGHT: (whispers) Sorry.
193 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
195 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
196 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
197 \\\ download, build and distribute -- http://www.A-A-P.org ///
198 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///