Function Repository Resource:

QueryCodeCompletion

Source Notebook

Query the autocompletion system

Contributed by: Tom Sherlock

ResourceFunction["QueryCodeCompletion"]["string"]

queries the autocompletion system for a list of suggestions that partially match "string".

ResourceFunction["QueryCodeCompletion"]["string","sel"]

uses the selector specified by "sel".

ResourceFunction["QueryCodeCompletion"]["string","sel",fun]

uses the function fun as the enclosing function for the autocompletion.

ResourceFunction["QueryCodeCompletion"]["string","sel",fun,pos]

queries the autocompletion system for the function fun corresponding to the argument with position specified by pos.

ResourceFunction["QueryCodeCompletion"]["string","sel",fun,pos,filter]

limits the results of the autocompletion with filter.

ResourceFunction["QueryCodeCompletion"]["string","sel",fun,pos,filter,nb]

uses the notebook nb for defining advanced autocompletion options.

Details

The argument "sel" can take any of the following values:
"KernelSymbol"kernel symbol completion (default)
"RawListOfValues"list of string values completion
"LongName"long special character completion
"ShortName"short special character completion
"Color"color completion
"PackageName"package name completion
"AbsoluteFilename"absolute filename completion
"DirectoryName"directory name completion
"InterpreterType"interpreter type completion
"FontName"font name completion
"StyleName"style completion
fun can be any function like Plot that ResourceFunction["QueryCodeCompletion"] will use for determining autocompletions for the argument position specified by the argument pos.
The argument pos describes where inside the enclosing function, if named, the completion is taking place. It can be any of the following strings:
"NotInOptionPosition"not in an optional argument position (default)
"InOptionPosition"in an optional argument position
"InPossibleOptionPosition"in a position that may be an optional argument position
"InOptionValuePosition"on the right-hand side of an option rule
When set to an integer, pos corresponds to the zero-based argument number for the "RawListOfValues" completions.
The argument filter limits the results to the top hits when set to True, and returns the full completion list otherwise.

Examples

Basic Examples (1) 

Get all top level autocompletions for kernel symbols beginning with "Pl":

In[1]:=
ResourceFunction["QueryCodeCompletion"]["Pl"]
Out[1]=

Scope (5) 

Get all autocompletions for the first argument of NebulaData beginning with "M":

In[2]:=
ResourceFunction[
 "QueryCodeCompletion"]["M", "RawListOfValues", "NebulaData"]
Out[2]=

Get all autocompletions for the second argument of NebulaData beginning with "M":

In[3]:=
ResourceFunction[
 "QueryCodeCompletion"]["M", "RawListOfValues", "NebulaData", 1]
Out[3]=

Get all long name special character autocompletions beginning with 'A':

In[4]:=
ResourceFunction["QueryCodeCompletion"]["A", "LongName"]
Out[4]=

Get all short name special character autocompletions beginning with 'A':

In[5]:=
ResourceFunction["QueryCodeCompletion"]["A", "ShortName"]
Out[5]=

Get all font names autocompletions beginning with 'T':

In[6]:=
ResourceFunction["QueryCodeCompletion"]["T", "FontName"]
Out[6]=

Get all the option value autocompletions for PlotRange when used inside of 'Plot'. The result include two additional items which correspond to menu items used for accessing help topics for 'PlotRange' as well as 'Plot':

In[7]:=
ResourceFunction[
 "QueryCodeCompletion"]["PlotRange", "KernelSymbol", "Plot", "InOptionValuePosition"]
Out[7]=

Get all the package names on the $Path for local kernels beginning with 'N':

In[8]:=
ResourceFunction["QueryCodeCompletion"]["N", "PackageName"]
Out[8]=

Publisher

Tom Sherlock

Version History

  • 1.0.0 – 07 February 2022

Related Resources

Author Notes

This is a simple wrapper around a Notebook packet that can be used to test the autocompletion system.

License Information