In my copy of Mathematica 11.1,

SyntaxInformation[f] = {"ColorEqualSigns" -> {1, 1}}

colors like wrong options:

enter image description here

How do I make it not color like wrong options?

  • $\begingroup$ So Options[f] = {myOption->..., mySecondOption->...} is not an answer? $\endgroup$
    – Kuba
    Commented Aug 8, 2017 at 19:36
  • $\begingroup$ @Kuba Well, actually my function f actually takes bunch of arbitrary rules as its argument. While syntactically equivalent to options, there isn't a finite set of possibilities for the lhs of the rules. $\endgroup$
    – QuantumDot
    Commented Aug 8, 2017 at 19:38
  • $\begingroup$ Why not pass your function a list of rules instead of individual rules as parameters? $\endgroup$
    – Edmund
    Commented Aug 8, 2017 at 20:35
  • $\begingroup$ @Edmund That's not a bad idea; but sometimes if there is only one rule to pass, it's more convenient to just provide the rule without enclosing it in a list. $\endgroup$
    – QuantumDot
    Commented Aug 8, 2017 at 21:18
  • $\begingroup$ Simply write your function to operate on a list of rules. Why would it matter if here was only one item in the list? $\endgroup$
    – Edmund
    Commented Aug 8, 2017 at 21:58

1 Answer 1


So I remembered running into this while answering an old SyntaxInformation based question, but here's a more systematic way to get at it.

Note that this has been pointed out on the StackExchange both by Szabolcs, by jkuczm answering pretty much this exact question, and by Jacob Akkerboom citing jkuczm.

We can get all of the standard SyntaxInformation patterns like so:

siData =
      If[Length[Quiet[OwnValues[#]]] === 0 && ! 
       Thread[ToString[Unevaluated[#]] -> Keys@SyntaxInformation[#]],
     ] // Flatten // GroupBy[Last -> First];

Then look at the keys:

siData // Keys

{"ArgumentsPattern", "LocalVariables", "ColorEqualSigns", \

And we see that curious, undocumented "OptionNames" thing.

We can see what functions have that:

withOpsNames = siData["OptionNames"]

{"CDFDeploy", "Cell", "ChoiceDialog", "CoefficientArrays", \
"CopyFile", "CreateDialog", "CreateDocument", "CreateNotebook", \
"CreatePalette", "CreateScheduledTask", "CreateWindow", \
"DefineInputStreamMethod", "DialogInput", "DialogNotebook", \
"DirectedEdges", "DocumentNotebook", "DumpSave", "Dynamic", \
"DynamicBox", "DynamicModuleBox", "DynamicWrapper", \
"DynamicWrapperBox", "ExpressionCell", "GraphAssortativity", \
"GroebnerBasis", "Input", "InputString", "LibraryFunctionLoad", \
"MessageDialog", "Notebook", "NotebookPut", "NotebookRead", \
"Notebooks", "PaletteNotebook", "PopupWindow", "Printout3D", \
"Rasterize", "ResetScheduledTask", "RunScheduledTask", "Style", \
"StyleBox", "SystemOpen", "TextCell", "URLBuild", "URLFetch", \
"URLFetchAsynchronous", "URLParse", "URLQueryDecode", \
"URLQueryEncode", "URLResponseTime", "URLSave", \
"URLSaveAsynchronous", "WaitAsynchronousTask", "WhenEvent", \

And then just for fun we'll find those options that are in the syntax info, but aren't in the basic Options list and vice versa:

opsNamesComplement =
    $Context = "Global`",
    $ContextPath = {"BoxForm`", "System`", "Global`"}
    withOpsNames ->
     ToExpression[withOpsNames, StandardForm,
         ToExpression@Lookup[SyntaxInformation[#], "OptionNames", {}]],
          Lookup[SyntaxInformation[#], "OptionNames", {}],
        } &

And here's some fun stuff from there:

 Length@#[[2]] > 0 && Length@Flatten@# < 10 &]

<|"Cell" -> {{Clickable, FillForm, Name, 
    VariableChangesAreEdits}, {BoxForm`Clickable, BoxForm`FillForm, 
    BoxForm`Name, BoxForm`VariableChangesAreEdits}}, 
 "CopyFile" -> {{OverwriteTarget}, {"MIMEType", Automatic}}, 
 "NotebookRead" -> {{CellContext}, {"WrapBoxesWithBoxData"}}, 
 "StyleBox" -> {{Clickable, FillForm, 
    VariableChangesAreEdits}, {BoxForm`Clickable, BoxForm`FillForm, 

Which pops out, e.g., "MIMType" for CopyFile (an option I use all the time to make things auto-downloading in the cloud).

And note, too, what the standard CopyFile sytax info is:


{"ArgumentsPattern" -> {_, _, OptionsPattern[]}, 
 "OptionNames" -> {Automatic, "\"MIMEType\""}}

Which I think shows us a way to prevent that red coloring (I'm gonna bet the Automatic is just inheriting the base options):

SyntaxInformation[f] = {
  "ColorEqualSigns" -> {1, 1},
  "OptionNames" -> {Automatic, "Option1", "Option2", "Option3"}

no red

So if you know the potential names of the options, you don't need to set Options at all. If you don't know the potential names and have no way of guessing them... Well then we have a problem.

  • $\begingroup$ Quite excellent. Please mark my question as a duplicate for sure. $\endgroup$
    – QuantumDot
    Commented Sep 15, 2017 at 12:55

Your Answer

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

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