Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there any way to have the same syntax coloring with SyntaxInformation that Block has?

SyntaxInformation[func] = {"ArgumentsPattern" -> {{__}, _},
                        "LocalVariables" -> {"Solve", {1, Infinity}}};
func[vars : {__}, body_] := {};

After evaluating the above definition, the following two lines have different coloring:

func[{parameter, variable, constant = 0}, parameter + variable + constant]

Block[{parameter, variable, constant = 0}, parameter + variable + constant]

Mathematica graphics

As you can notice, any local variable with an initial value is not highlighted as local. I use the default syntax coloring, no changes were applied. SyntaxInformation accepts the following values: {"Table", "Solve", "Integrate", "Limit", "Plot", "Manipulate"} none of which produces the same behaviour as Block does. Perhaps someone knows about an undocumented option value?

share|improve this question
    
+1. I was wondering about the same thing, for my LetL. Did not find the answer yet. –  Leonid Shifrin Dec 12 '13 at 14:58
1  
Maybe have a look at GetFEKernelInit.tr, which has a section called Syntax coloring and other syntax information. It's not very detail, but might provide some clues. –  Silvia Dec 12 '13 at 19:23
    
@Silvia Thanks for the pointer. Unfortunately, the syntax-coloring code in th .tr file refers to another textresource file (FunctionInformation2.m) containing syntax and usage information for almost all symbols, but not for Block, Module, With or DynamicModule. All their "LocalVariables" information is missing. The only new type for "LocalVariables" that I could found is "D" which might be identical to "Integrate". –  István Zachar Dec 12 '13 at 21:45
    
@IstvánZachar In FunctionInformation.m there is a line {"Module", {{__}, _}}, but nothing more. Guess we'll have to wait for someone from WRI to answer this puzzle.. (Strange I didn't get the comment notice. Sorry for reply late.) –  Silvia Dec 14 '13 at 2:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.