# Why does SyntaxInformation “ColorEqualSigns” color like wrong options?

In my copy of Mathematica 11.1,

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


colors like wrong options:

How do I make it not color like wrong options?

• So Options[f] = {myOption->..., mySecondOption->...} is not an answer? – Kuba Aug 8 '17 at 19:36
• @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. – QuantumDot Aug 8 '17 at 19:38
• Why not pass your function a list of rules instead of individual rules as parameters? – Edmund Aug 8 '17 at 20:35
• @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. – QuantumDot Aug 8 '17 at 21:18
• Simply write your function to operate on a list of rules. Why would it matter if here was only one item in the list? – Edmund Aug 8 '17 at 21:58

## 1 Answer

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 =
ToExpression[
Names["*"],
StandardForm,
Function[Null,
If[Length[Quiet[OwnValues[#]]] === 0 && !
SystemPrivateHasOwnCodeQ[#],
Thread[ToString[Unevaluated[#]] -> Keys@SyntaxInformation[#]],
{}
],
HoldAllComplete
]
] // Flatten // GroupBy[Last -> First];


Then look at the keys:

siData // Keys

{"ArgumentsPattern", "LocalVariables", "ColorEqualSigns", \
"OptionNames"}


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", \
"$FrontEndSession"}  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 = Block[{$Context = "Global",
\$ContextPath = {"BoxForm", "System", "Global"}
},
AssociationThread[
withOpsNames ->
ToExpression[withOpsNames, StandardForm,
{
Complement[Keys@Options[#],
ToExpression@Lookup[SyntaxInformation[#], "OptionNames", {}]],
Complement[
ToExpression@
Lookup[SyntaxInformation[#], "OptionNames", {}],
Keys@Options[#]
]
} &
]
]
];


And here's some fun stuff from there:

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

<|"Cell" -> {{Clickable, FillForm, Name,
VariableChangesAreEdits}, {BoxFormClickable, BoxFormFillForm,
BoxFormName, BoxFormVariableChangesAreEdits}},
"CopyFile" -> {{OverwriteTarget}, {"MIMEType", Automatic}},
"NotebookRead" -> {{CellContext}, {"WrapBoxesWithBoxData"}},
"StyleBox" -> {{Clickable, FillForm,
VariableChangesAreEdits}, {BoxFormClickable, BoxFormFillForm,
BoxFormVariableChangesAreEdits}}|>


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:

SyntaxInformation[CopyFile]

{"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"}
}


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.

• Quite excellent. Please mark my question as a duplicate for sure. – QuantumDot Sep 15 '17 at 12:55