Message Boards Message Boards

GROUPS:

Add Custom Autocompletions

Posted 17 days ago
89 Views
|
0 Replies
|
1 Total Likes
|

Mathematica can add autocompletions to functions very nicely. There are ways to do this you can find on the stack-exchange, but operationally they look like:

AddFunctionAutocompletions[myFunc, {{"arg1", "arg2", "arg3"}}];

And then I can test this like:

myFunc["ar

enter image description here

But how the front-end does this for Entity is beyond me and something I'd love to have. Consider this:

enter image description here

But the box form of this looks like:

ToBoxes@Entity["Country", "China"]

TemplateBox[{
  "\"China\"", 
  RowBox[{
     "Entity", "[", 
       RowBox[{"\"Country\"", ",", "\"China\""}], 
     "]"
    }], 
 "\"Entity[\\\"Country\\\", \\\"China\\\"]\"", 
 "\"country\""
 }, 
"Entity"
]

Some simple debugging lets me know that all the FE is doing is using the second argument to that TemplateBox to get this out, but how it does that is beyond me and how this is set in the kernel I don't know.

So...how do I do this myself? This would be a great feature to have for OOP.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract