To: vim-dev@vim.org Subject: Patch 5.7.015 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.7.015 Problem: Syntax files for Vim 6.0 can't be used with 5.x. Solution: Add the "default" argument to the ":highlight" command: Ignore the command if highlighting was already specified. Files: src/syntax.c *** ../vim-5.7.14/src/syntax.c Mon May 22 09:42:51 2000 --- src/syntax.c Wed Nov 8 19:33:11 2000 *************** *** 78,83 **** --- 78,84 ---- static int highlight_list_arg __ARGS((int id, int didh, int type, int iarg, char_u *sarg, char *name)); static int syn_add_group __ARGS((char_u *name)); static int syn_list_header __ARGS((int did_header, int outlen, int id)); + static int hl_has_settings __ARGS((int idx, int check_link)); static void highlight_clear __ARGS((int idx)); #ifdef USE_GUI *************** *** 4841,4846 **** --- 4842,4848 ---- int attr; int id; int idx; + int dodefault = FALSE; int doclear = FALSE; int dolink = FALSE; int error = FALSE; *************** *** 4868,4873 **** --- 4870,4886 ---- name_end = skiptowhite(line); linep = skipwhite(name_end); + /* + * Check for "default" argument. + */ + if (STRNCMP(line, "default", name_end - line) == 0) + { + dodefault = TRUE; + line = linep; + name_end = skiptowhite(line); + linep = skipwhite(name_end); + } + if (STRNCMP(line, "clear", name_end - line) == 0) doclear = TRUE; if (STRNCMP(line, "link", name_end - line) == 0) *************** *** 4927,4940 **** * for the group, unless '!' is used */ if (to_id > 0 && !forceit && !init ! && (HL_TABLE()[from_id - 1].sg_term_attr != 0 ! || HL_TABLE()[from_id - 1].sg_cterm_attr != 0 ! #ifdef USE_GUI ! || HL_TABLE()[from_id - 1].sg_gui_attr != 0 ! #endif ! )) { ! if (sourcing_name == NULL) EMSG("group has settings, highlight link ignored"); } else --- 4940,4948 ---- * for the group, unless '!' is used */ if (to_id > 0 && !forceit && !init ! && hl_has_settings(from_id - 1, dodefault)) { ! if (sourcing_name == NULL && !dodefault) EMSG("group has settings, highlight link ignored"); } else *************** *** 4971,4976 **** --- 4979,4989 ---- if (id == 0) /* failed (out of memory) */ return; idx = id - 1; /* index is ID minus one */ + + /* Return if "default" was used and the group already has settings. */ + if (dodefault && hl_has_settings(idx, TRUE)) + return; + if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) is_normal_group = TRUE; #ifdef USE_GUI_X11 *************** *** 5473,5478 **** --- 5486,5509 ---- /* Only call highlight_changed() once, after sourcing a syntax file */ need_highlight_changed = TRUE; } + + /* + * Return TRUE if highlight group "idx" has any settings. + * When "check_link" is TRUE also check for an existing link. + */ + static int + hl_has_settings(idx, check_link) + int idx; + int check_link; + { + return ( HL_TABLE()[idx].sg_term_attr != 0 + || HL_TABLE()[idx].sg_cterm_attr != 0 + #ifdef FEAT_GUI + || HL_TABLE()[idx].sg_gui_attr != 0 + #endif + || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK))); + } + /* * Clear highlighting for one group. *** ../vim-5.7.14/src/version.c Wed Nov 1 09:55:17 2000 --- src/version.c Wed Nov 8 19:33:20 2000 *************** *** 439,440 **** --- 439,442 ---- { /* Add new patch number below this line */ + /**/ + 15, /**/ -- Time is money. Especially if you make clocks. /// Bram Moolenaar Bram@moolenaar.net http://www.moolenaar.net \\\ \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///