# Turning off or modifying the displayed Code Assist value for a specific input alias

Short Version: How do I turn off (or specify a simple replacement for) Code Assist predictive-interface for a specific input alias?

Longer Version: Using the Notation package I have put together a set of routines that let me, on the fly, specify very general notations and assign them to simple labels. These notations get tagged internally in ways that let them display in their full glory in both input cells and output cells. The trick is to be able to get these tagged-versions into the input cells easily. Based on some clever suggestions by Stack Exchange members, I have three approaches working. The first involves a custom palette. The second is an ActionMenu tied to an InputAlias. The third is a custom routine also tied to an InputAlias that generates a menu that responds to arrow keys for selection. Example usage is shown below:

My question applies to the third of these. The Code Assist predictive interface (turned off in the animation above) takes a good ten seconds or longer for the preview to pop up, hanging the window until it is complete. Is there any way to turn off this predictive interface for this specific Input Alias? Or perhaps even better, to assign text to what will display that summarizes what it does rather than trying to generate a preview?

Edited to Add: I have been able to combine the functionality of the last option with the middle option, so that the choices can be selected either with the keyboard arrow keys or the mouse. It involves the main code for the last original example I used as a base, so the answer to this question has now become even more important.

Some Specifics on Implementation: As @b3m2a1 suggested, some of this code is based on suggestions he made in this thread. I did end up modifying the code somewhat, though, in an effort to make it easier for my students to use this code. Specifically, instead of the final CurrentValue assignment for the input alias, I used the following function that I defined:

EscMenu[shortcut_,tag_,list_]:=
shortcut->
ParsedBoxWrapper[
DynamicBox[
chooserBox[tag,
Style[#1,"chemical"]:>ToBoxes[#2]&,
Transpose[list]],
tag]]]]


This lets me call:

EscMenu["examples","Example Symbols",exampleAssignments]


where exampleAssignments contains a the same list of label/symbol pairs that I used to define notations previously. This worked beautifully except for the aforementioned code assist issue.

When I try to implement @b3m2a1's code in his answer below, I tried this:

EscMenu[shortcut_,tag_,list_]:=
shortcut->
ParsedBoxWrapper[
DynamicBox[
FEPrivateIf[
FrontEndSameQ[FrontEndEvaluationCell[],$Failed], PanelBox["\Chem Templates\"", Appearance->{"Default"->FrontEndFileName[ {"Popups","CodeCompletion"},"top_left.9.png"]}], chooserBox[tag, MapThread[ Style[#1,"chemical"]:>ToBoxes[#2]&, Transpose[list]], tag]]]]]  The Code Assist bit works beautifully. But what is pasted in has an error: "An unknown box name (FEPrivateIf) was sent as the BoxForm for the expression. Check the format rules for the expression." Any thoughts? Final Solution: I am not sure where the error was, but I tried the following and it worked perfectly. Thank you! EscMenu[shortcut_, tag_, list_] := CurrentValue[EvaluationNotebook[], {InputAliases, shortcut}] = With[{baseBox = chooserBox[tag, MapThread[Style[#1, "chemical"] :> ToBoxes[#2] &, list\[Transpose]], tag]}, DynamicBox[ FEPrivateIf[FrontEndSameQ[FrontEndEvaluationCell[],$Failed],
PanelBox["\"Chem Templates\"",
Appearance -> {"Default" ->
FrontEndFileName[{"Popups", "CodeCompletion"},
"top_left.9.png"]}],
baseBox]]]


I'm assuming you're talking about the menu from my code here. If that's the case we can have the DynamicBox act differently if it's in the code assist popup (which is a special interface element that has no EvaluationCell[]) relative to a standard cell. That'll look like:

CurrentValue[EvaluationNotebook[], {InputAliases, "ch"}] =
With[{baseBox =
chooserBox[
"ChemTemplates", {RawBoxes@
SubscriptBox[ToBoxes@"C", ToBoxes@"6"] :> C6,
RawBoxes@
RowBox[{SubscriptBox[ToBoxes@"H", "2"],
BoxMargins -> {{-.5, 0}, {0, 0}}]}] :> WaterVapor},
"ChemTemplates"]},
DynamicBox[
FEPrivateIf[
FrontEndSameQ[FrontEndEvaluationCell[], \$Failed],
PanelBox["\"Chem Templates\"",
Appearance -> {"Default" ->
FrontEndFileName[{"Popups", "CodeCompletion"},
"top_left.9.png"]}
],
baseBox
]
]
];


where baseBox` is built from my code before.

This looks like:

• Thank you for the suggested code; it looks very promising! When I tried to implement it in my context (see edits I have added to the OP), the Code Assist issue has been fixed, but what is pasted in has an error. I am sure that my translation from a direct setting of an alias using CurrentValue into a function call that uses AddInputAlias is what is causing trouble, so I welcome any suggestions on how to do that better. Thank you! – Kevin Ausman Apr 25 '19 at 21:32
• Never mind. I'm not sure where the mistake was, but I tried cutting-and-pasting your version in, and then updating your version with my earlier modifications, and I got it to work. I will update the OP and mark your answer. Thank you for your help! – Kevin Ausman Apr 25 '19 at 22:01