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?

  • 2
    $\begingroup$ +1. I was wondering about the same thing, for my LetL. Did not find the answer yet. $\endgroup$ Dec 12, 2013 at 14:58
  • 1
    $\begingroup$ 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. $\endgroup$
    – Silvia
    Dec 12, 2013 at 19:23
  • 2
    $\begingroup$ Somewhat related: What is ColorEqualSigns and how does one use it? $\endgroup$ Sep 17, 2014 at 10:25
  • 1
    $\begingroup$ @Gyebro Yes, you have to use HoldAll or similar. See for example Leonid's LetL here which is a scoping construct similar to With. $\endgroup$ Dec 1, 2016 at 15:48
  • 1
    $\begingroup$ FYI, I've asked WRI Support about that but no answer so far. $\endgroup$
    – Kuba
    Dec 12, 2016 at 12:36

1 Answer 1


Unfortunately, the current answer is "you can't". These are hard coded into the FE. Module/With, in particular, are not treated as local variables since they are really lexically scoped. If you look carefully, you'll see they are a slightly different color, and if you look in the syntax coloring prefs you'll see they have a dedicated section.

One of our own iternal wishlist items is to unify the implementation of these different color schemes as well as allowing new rules to be written in Wolfram Language so users can define they own local variable rules. As with everything, this is just one of many competing features. If this sounds like something you would want, I suggest you contact support with your request. The more evidence we have that users are interested in this, the more likely it is we will spend the resources needed to make it happen.

  • $\begingroup$ Thanks for your answer. Would you kindly answer this question with an official "no"? Many thanks! $\endgroup$
    – QuantumDot
    Dec 23, 2016 at 17:17
  • $\begingroup$ Is the same true for Compile and Function? $\endgroup$
    – QuantumDot
    Jun 6, 2017 at 20:25
  • $\begingroup$ Yes, if there's no "LocalVariable" rule returned by SyntaxInformation, it must be hard coded in the FE. $\endgroup$ Jul 8, 2017 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.