Function Repository Resource:

ResourceFunctionInput

Source Notebook

Add a way to interactively input ResourceFunction symbols inline

Contributed by: Lukas Lang

ResourceFunction["ResourceFunctionInput"]["InstallAlias"]

permanently adds an interactive input for ResourceFunction symbols as input alias ImagerfiImage.

ResourceFunction["ResourceFunctionInput"]["InstallAlias",alias]

installs the interactive input as input alias ImagealiasImage.

ResourceFunction["ResourceFunctionInput"]["InstallMenuItem"]

permanently adds the interactive input as a menu item with a hotkey.

ResourceFunction["ResourceFunctionInput"]["InstallMenuItem",MenuKey[]]

permanently adds the interactive input with the specified hotkey.

ResourceFunction["ResourceFunctionInput"]["Remove"]

removes any permanently installed changes.

Details and Options

The ResourceFunction input field added by ResourceFunction["ResourceFunctionInput"][] allows for inline creation of a ResourceFunction[] symbol.
Typing into the input field brings up a list of all available ResourceFunction names as known by the system.
If an unknown ResourceFunction is entered, a raw ResourceFunction["name"] expression is inserted.
The completion menu displayed by the input field can be navigated using the arrow keys. The selected function can be selected using either the Image key or the Image key.
The icon of the input field is colored blue to indicate that the input has not yet been confirmed.
ResourceFunction["ResourceFunctionInput"]["InstallAlias",] and ResourceFunction["ResourceFunctionInput"]["InstallMenuItem",] effectively install a paclet named "ResourceFunctionInput".
The alias or menu item can be removed again by using ResourceFunction["ResourceFunctionInput"]["Remove"] or by uninstalling the "ResourceFunctionInput" paclet manually.
Only the alias or the menu item can be installed at any given time, and installing one removes the other.
The default keyboard shortcut for the menu item is Image on Windows/Linux, and Image on macOS.
In ResourceFunction["ResourceFunctionInput"]["InstallMenuItem",MenuKey[]], the MenuKey[] expression can be anything supported by the MenuSetup.tr system menu configuration file.
Typical settings for the menu item hotkey are of the form MenuKey["letter",Modifiers{mod1,}], where the modi are one of "Shift", "Control", "Command" and "Option".
Since the ResourceFunction subsystem needs to be loaded for the completion list to be available, the first use might be slow to load. In those cases, a loading icon is displayed until everything is initialized.
ResourceFunction["ResourceFunctionInput"]["AddAlias",] and ResourceFunction["ResourceFunctionInput"]["AddMenuItem",] can be used to add the alias or menu item to the current front end session only.
ResourceFunction["ResourceFunctionInput"][] returns the interactive ResourceFunction symbol input without adding any aliases or menu items.
ResourceFunction["ResourceFunctionInput"] requires Mathematica 12.0 or newer.

Examples

Basic Examples (3) 

Install the input as an input alias:

In[1]:=
ResourceFunction["ResourceFunctionInput"]["InstallAlias"]

Insert a ResourceFunction input field by typing ImagerfiImage:

Image
Image

Enter the name of a ResourceFunction:

Image

Confirm the input by pressing the Image or Image key, or by clicking the name in the completion drop-down menu:

Image

Install the input field as a menu item instead:

In[2]:=
ResourceFunction["ResourceFunctionInput"]["InstallMenuItem"]

Insert an input field via Insert > ResourceFunction Input:

Image
Image

Use the keyboard shortcut Image (Image on macOS) to insert the input field:

Image

Remove the keyboard shortcut/alias (only effective after restarting Mathematica):

In[3]:=
ResourceFunction["ResourceFunctionInput"]["Remove"]

Scope (2) 

Create a one-off ResourceFunction input:

In[4]:=
ResourceFunction["ResourceFunctionInput"][]
Out[4]=
Image

Add the alias ImagerfiinputImage to the current front end session:

In[5]:=
ResourceFunction["ResourceFunctionInput"]["AddAlias", "rfinput"]

Insert a ResourceFunction input field by typing ImagerfinputImage into an input cell:

Image

Publisher

Lukas Lang

Version History

  • 3.0.0 – 21 December 2020
  • 2.0.0 – 02 December 2020
  • 1.0.0 – 20 November 2020

Source Metadata

Related Resources

Author Notes

Changes from version 1.1.0 to 1.2.0:

Fixed highlighting of currently selected function name not working in version 12.2.
The installed paclet now requires Mathematica 12.0 or newer.
Fixed "AddMenuItem" action not working as expected.

Changes from version 1.0.0 to 1.1.0:

Made changes to ensure that the menu item is more reliably added when restarting Mathematica.

License Information