From d3439f0d7efa5942b0c19f546de80870f89ffcbd Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Thu, 5 May 2016 16:58:04 -0400 Subject: [PATCH] recipe macro handle curly --- src/recipes.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 08d73901..6b713941 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -84,7 +84,7 @@ function replace_recipe_arrows!(expr::Expr) set_expr end - @show quiet, force, expr.args[i] + # @show quiet, force, expr.args[i] elseif e.head != :call # we want to recursively replace the arrows, but not inside function calls @@ -107,12 +107,20 @@ macro recipe(funcexpr::Expr) end args = lhs.args[2:end] + # for parametric definitions, take the "curly" expression and add the func + front = lhs.args[1] + func = :(Plots._apply_recipe) + if isa(front, Expr) && front.head == :curly + front.args[1] = func + func = front + end + # replace all the key => value lines with argument setting logic replace_recipe_arrows!(body) # now build a function definition for _apply_recipe, wrapping the return value in a tuple if needed esc(quote - function Plots._apply_recipe(d::KW, $(args...); issubplot=false, kw...) + function $func(d::KW, $(args...); issubplot=false, kw...) ret = $body if typeof(ret) <: Tuple ret