Short answer
The file format that the FrontEnd reads out of “ *.trie ” files is not documented and is not written by any public-facing Wolfram-Language function.
Only the internal “Code Assist” paclet that ships with the product knows how to turn a list of strings (or of rules) into the compact binary form that the FrontEnd loads. Consequently a compiled trie can only be produced with the same private code that Wolfram Research uses when it builds the product.
The good news is that this code is shipped with every desktop installation, so you can call it yourself if you do not mind relying on undocumented symbols.
The two key functions are
CA`CACompileTriePacket (* writes a .trie file *)
CA`CADumpTriePacket (* reads / dumps a trie *)
Both live in the paclet AutoCompletionData (context CA).
Load the private context
Needs["CA`"]
Prepare the data you want to compile
A completion trie is built out of rules of the form
"head" -> listOfCompletions
For example
completions =
{
"myFun" -> {"opt1", "opt2", "opt3"},
"anotherFunction" -> {"first", "second"},
"π" -> {"ω", "φ"}
};
The left–hand side must be a String.
The right-hand side can be a list of strings or a single string (both
are accepted by the compiler).
Call the compiler
outFile = FileNameJoin[{$TemporaryDirectory, "MySpecialArgs.trie"}];
CA`CACompileTriePacket[completions, outFile]
When the function returns $Succeeded the file has been written.
Optional switches that can be supplied as third-argument rules are
"CaseSensitive" -> True|False (default False)
"WhitespaceSensitive"-> True|False (default False)
"IncludeHeads" -> True|False (default True)
"IgnoreDiacritics" -> True|False (default False)
Exactly the same options are used when Wolfram Research builds the specialArgFunctions.tr file that ships with the system.
Test the file (optional)
CA`CADumpTriePacket[outFile] (* → Association that shows you ) ( what has been written *)
Tell the FrontEnd to use it
Put the newly produced file on the FrontEnd’s $Path for auto-completion. One possibility is to create a small paclet
CreatePaclet[
<|
"Name" -> "MyCompletionData",
"Version" -> "1.0",
"WolframVersion" -> "11+",
"Extensions" ->
{
{"AutoCompletionData", "Root" -> ".",
"Symbols" -> "MySpecialArgs.trie"}
}
|>,
FileNameJoin[{$UserBaseDirectory, "Paclets", "MyCompletionData"}]
]
After PacletInstall (or simply dropping the directory in
$UserBaseDirectory/Paclets) you have a fully integrated, updateable
trie that the FrontEnd picks up automatically on the next start.
Whenever your list of argument completions changes, re-run CA`CACompileTriePacket on the new data and overwrite “MySpecialArgs.trie”. No manual editing of the system files is ever necessary.
Because CACACompileTriePacket` is not documented it may change its name or
its calling sequence in future versions. In the unlikely case that it
disappears one would have to fall back to the un-compiled
specialArgFunctions.tr format, which is just a plain text list that the
FrontEnd can still read.
For the time being (v11, v12, v13) the method above works unchanged.
• The FrontEnd’s compiled completion files are created with the private
function CA`CACompileTriePacket .
• Supply a list "head" -> listOfArguments and a target file name.
• Place the resulting .trie in a paclet of extension “AutoCompletionData”
or drop it in the same directory that already contains the other
completion tries.
• The format itself is not documented, but you do not need to know its
internals—the compiler that ships with every copy of Mathematica will do
the work for you.
Was this answer helpful?
version: o3-2025-04-16
Status: UQ Validated
Validated: 8 months ago
Status: Needs Human Verification
Loading model reviews...
Loading reviews...