Modified patch. There was a bug in foldhidef(); one too many levels of 
indirection. It now just returns the HLF_FL constant.

Noel

-- 

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com     Chips, firmware and embedded systems
  www.vimoutliner.org   Work fast. Think well.



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

diff -rpuN original/eval.c new/eval.c
--- original/eval.c	2009-09-13 03:36:29.000000000 -0700
+++ new/eval.c	2009-09-13 11:40:07.000000000 -0700
@@ -537,6 +537,7 @@ static void f_foldclosedend __ARGS((typv
 static void f_foldlevel __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_foldtext __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_foldtextresult __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_foldhidef __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_foreground __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_function __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_garbagecollect __ARGS((typval_T *argvars, typval_T *rettv));
@@ -1725,6 +1726,56 @@ eval_foldexpr(arg, cp)
 
     return retval;
 }
+
+/*
+ * Evaluate 'foldhighlight'.  Returns the fold hlID
+ */
+    int
+/* eval_foldhighlight(arg)*/
+eval_foldhighlight(fdt, lnum, lnume, foldinfo)
+    char_u	*fdt;
+    linenr_T	lnum, lnume;
+    foldinfo_T	*foldinfo;
+
+{
+    typval_T	tv;
+    int		retval;
+    int         level;
+    int		use_sandbox = was_set_insecurely((char_u *)"foldhighlight",
+								   OPT_LOCAL);
+
+    /* Set "v:foldstart" and "v:foldend". */
+    set_vim_var_nr(VV_FOLDSTART, lnum);
+    set_vim_var_nr(VV_FOLDEND, lnume);
+
+    /* Set "v:foldlevel" to "level". */
+    level = foldinfo->fi_level;
+    if (level > 50)
+        level = 50;
+    set_vim_var_nr(VV_FOLDLEVEL, (long)level);
+
+    ++emsg_off;
+    if (use_sandbox)
+	++sandbox;
+    ++textlock;
+    if (eval0(fdt, &tv, NULL, TRUE) == FAIL)
+	retval = syn_get_foldhidef();
+    else
+    {
+	/* If the result is a number, just return the number. */
+	if (tv.v_type == VAR_NUMBER)
+	    retval = tv.vval.v_number;
+	else 
+	    retval = syn_get_foldhidef();
+	clear_tv(&tv);
+    }
+    --emsg_off;
+    if (use_sandbox)
+	--sandbox;
+    --textlock;
+
+    return retval;
+}
 #endif
 
 /*
@@ -7496,6 +7547,7 @@ static struct fst
     {"foldlevel",	1, 1, f_foldlevel},
     {"foldtext",	0, 0, f_foldtext},
     {"foldtextresult",	1, 1, f_foldtextresult},
+    {"foldhidef",	0, 0, f_foldhidef},
     {"foreground",	0, 0, f_foreground},
     {"function",	1, 1, f_function},
     {"garbagecollect",	0, 1, f_garbagecollect},
@@ -10162,6 +10214,17 @@ f_foldlevel(argvars, rettv)
 }
 
 /*
+ * "foldhidef()" function
+ */
+    static void
+f_foldhidef(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+	rettv->vval.v_number = HLF_FL;
+}
+
+/*
  * "foldtext()" function
  */
 /*ARGSUSED*/
diff -rpuN original/option.c new/option.c
--- original/option.c	2009-09-13 03:36:29.000000000 -0700
+++ new/option.c	2009-09-13 03:36:44.000000000 -0700
@@ -200,6 +200,7 @@
 # ifdef FEAT_EVAL
 #  define PV_FDE	OPT_WIN(WV_FDE)
 #  define PV_FDT	OPT_WIN(WV_FDT)
+#  define PV_FDH	OPT_WIN(WV_FDH)
 # endif
 # define PV_FMR		OPT_WIN(WV_FMR)
 #endif
@@ -1125,6 +1126,15 @@ static struct vimoption
 			    {(char_u *)NULL, (char_u *)0L}
 # endif
 			    },
+    {"foldhighlight",     "fdh",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
+# ifdef FEAT_EVAL
+			    (char_u *)VAR_WIN, PV_FDH,
+			    {(char_u *)"foldhidef()", (char_u *)NULL}
+# else
+			    (char_u *)NULL, PV_NONE,
+			    {(char_u *)NULL, (char_u *)0L}
+# endif
+			    },
 #endif
     {"formatexpr", "fex",   P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
 #ifdef FEAT_EVAL
@@ -5249,6 +5259,7 @@ insecure_flag(opt_idx, opt_flags)
 # ifdef FEAT_FOLDING
 	    case PV_FDE:	return &curwin->w_p_fde_flags;
 	    case PV_FDT:	return &curwin->w_p_fdt_flags;
+	    case PV_FDH:	return &curwin->w_p_fdh_flags;
 # endif
 # ifdef FEAT_BEVAL
 	    case PV_BEXPR:	return &curbuf->b_p_bexpr_flags;
@@ -9024,6 +9035,7 @@ get_varp(p)
 # ifdef FEAT_EVAL
 	case PV_FDE:	return (char_u *)&(curwin->w_p_fde);
 	case PV_FDT:	return (char_u *)&(curwin->w_p_fdt);
+	case PV_FDH:	return (char_u *)&(curwin->w_p_fdh);
 # endif
 	case PV_FMR:	return (char_u *)&(curwin->w_p_fmr);
 #endif
diff -rpuN original/option.h new/option.h
--- original/option.h	2009-09-13 03:36:33.000000000 -0700
+++ new/option.h	2009-09-13 03:36:49.000000000 -0700
@@ -1032,6 +1032,7 @@ enum
 # ifdef FEAT_EVAL
     , WV_FDE
     , WV_FDT
+    , WV_FDH
 # endif
     , WV_FMR
 #endif
diff -rpuN original/screen.c new/screen.c
--- original/screen.c	2009-09-13 03:36:29.000000000 -0700
+++ new/screen.c	2009-09-13 03:36:44.000000000 -0700
@@ -2171,7 +2171,11 @@ fold_line(wp, fold_count, foldinfo, lnum
 #endif
 
     /* Set all attributes of the 'number' column and the text */
-    RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
+    /* RL_MEMSET(col, syn_get_foldhi(eval_foldhighlight(wp->w_p_fdh)), W_WIDTH(wp) - col);*/
+    RL_MEMSET(col, syn_get_foldhi(eval_foldhighlight(wp->w_p_fdh, lnum, lnume,foldinfo)), 
+	                                                     W_WIDTH(wp) - col);
+   /* RL_MEMSET(col, eval_foldhighlight(wp->w_p_fdh), W_WIDTH(wp) - col);
+    */
 
 #ifdef FEAT_SIGNS
     /* If signs are being displayed, add two spaces. */
@@ -2186,10 +2190,10 @@ fold_line(wp, fold_count, foldinfo, lnum
 	    if (wp->w_p_rl)
 		/* the line number isn't reversed */
 		copy_text_attr(off + W_WIDTH(wp) - len - col,
-					(char_u *)"  ", len, hl_attr(HLF_FL));
+					(char_u *)"  ", len, syn_get_foldhidef());
 	    else
 # endif
-		copy_text_attr(off + col, (char_u *)"  ", len, hl_attr(HLF_FL));
+		copy_text_attr(off + col, (char_u *)"  ", len, syn_get_foldhidef());
 	    col += len;
 	}
     }
@@ -2212,10 +2216,10 @@ fold_line(wp, fold_count, foldinfo, lnum
 	    if (wp->w_p_rl)
 		/* the line number isn't reversed */
 		copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
-							     hl_attr(HLF_FL));
+							     syn_get_foldhidef());
 	    else
 #endif
-		copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
+		copy_text_attr(off + col, buf, len, syn_get_foldhidef());
 	    col += len;
 	}
     }
diff -rpuN original/structs.h new/structs.h
--- original/structs.h	2009-09-13 03:36:33.000000000 -0700
+++ new/structs.h	2009-09-13 03:36:49.000000000 -0700
@@ -157,6 +157,8 @@ typedef struct
 # define w_p_fde w_onebuf_opt.wo_fde	/* 'foldexpr' */
     char_u	*wo_fdt;
 #  define w_p_fdt w_onebuf_opt.wo_fdt	/* 'foldtext' */
+    char_u	*wo_fdh;
+#  define w_p_fdh w_onebuf_opt.wo_fdh	/* 'foldhighlight' */
 # endif
     char_u	*wo_fmr;
 # define w_p_fmr w_onebuf_opt.wo_fmr	/* 'foldmarker' */
@@ -1946,6 +1948,7 @@ struct window_S
 #ifdef FEAT_EVAL
     long_u	w_p_fde_flags;	    /* flags for 'foldexpr' */
     long_u	w_p_fdt_flags;	    /* flags for 'foldtext' */
+    long_u	w_p_fdh_flags;	    /* flags for 'foldhilight' */
 #endif
 
     /* transform a pointer to a "onebuf" option into a "allbuf" option */
diff -rpuN original/syntax.c new/syntax.c
--- original/syntax.c	2009-09-13 03:36:29.000000000 -0700
+++ new/syntax.c	2009-09-13 11:40:14.000000000 -0700
@@ -6187,6 +6187,27 @@ syn_get_foldlevel(wp, lnum)
     }
     return level;
 }
+
+/*
+ * Function called to get the default highlight ID for folded lines
+ */
+    int
+syn_get_foldhidef()
+{
+    return hl_attr(HLF_FL);
+}
+
+/*
+ * Function called to get the user-defined highlight ID for folded lines
+ */
+    int
+syn_get_foldhi(hlid)
+{
+    if (hlid<HLF_COUNT)
+	return hl_attr(hlid);
+    else
+	return syn_id2attr(hlid);
+}
 #endif
 
 #endif /* FEAT_SYN_HL */

Raspunde prin e-mail lui