home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 7.1.215
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 7.1.215
- Problem: It is difficult to figure out what syntax items are nested at a
- certain position.
- Solution: Add the synstack() function.
- Files: runtime/doc/eval.txt, src/eval.c, src/proto/syntax.pro,
- src/syntax.c
-
-
- *** ../vim-7.1.214/runtime/doc/eval.txt Sun Jan 6 20:05:36 2008
- --- runtime/doc/eval.txt Thu Jan 10 22:20:31 2008
- ***************
- *** 1,4 ****
- ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 06
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
- --- 1,4 ----
- ! *eval.txt* For Vim version 7.1. Last change: 2008 Jan 10
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
- ***************
- *** 1786,1791 ****
- --- 1786,1792 ----
- 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,4967 ****
- --- 4966,4989 ----
- 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
- *** ../vim-7.1.214/src/eval.c Sun Jan 6 20:05:36 2008
- --- src/eval.c Wed Jan 9 13:42:56 2008
- ***************
- *** 651,656 ****
- --- 651,657 ----
- 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,7257 ****
- --- 7253,7259 ----
- {"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},
- ***************
- *** 15843,15848 ****
- --- 15845,15890 ----
- id = 0;
-
- 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
- }
-
- /*
- *** ../vim-7.1.214/src/proto/syntax.pro Tue Jul 24 14:32:44 2007
- --- src/proto/syntax.pro Wed Jan 9 13:38:20 2008
- ***************
- *** 13,18 ****
- --- 13,19 ----
- 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));
- *** ../vim-7.1.214/src/syntax.c Sun Oct 7 15:21:31 2007
- --- src/syntax.c Wed Jan 9 15:17:47 2008
- ***************
- *** 6104,6109 ****
- --- 6102,6123 ----
-
- 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)
- /*
- *** ../vim-7.1.214/src/version.c Wed Jan 9 22:39:55 2008
- --- src/version.c Thu Jan 10 22:17:38 2008
- ***************
- *** 668,669 ****
- --- 668,671 ----
- { /* Add new patch number below this line */
- + /**/
- + 215,
- /**/
-
- --
- TALL KNIGHT: We are now no longer the Knights Who Say Ni!
- ONE KNIGHT: Ni!
- OTHERS: Sh!
- ONE KNIGHT: (whispers) Sorry.
- "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
-
- /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
- /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
- \\\ download, build and distribute -- http://www.A-A-P.org ///
- \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
-