# Template completion

In version 8, if one evaluates

test::usage="test[x,y]";


then types test, then shift-cmd-k (or shift-ctrl-k), a template appears with placeholders for x and y.

In version 9, this does not work: if I evaluate the same thing, when I type te, I am offered the choice to select test from the dropdown menu, just like for the built-in functions. If I select test and then press shift-cmd, however, I do not get the template (whereas I do get a template for built-in functions if I do this).

How do I get the frontend to show a template?

# Note: This has been fixed as of 9.0.1

-
Apparently, I was a little heavy handed with the "remove all instances of v.9 tag." Reverting ... – rcollyer Nov 29 '12 at 3:01
I haven't downloaded version 9, but my suspicion would be that they now draw their template information from somewhere else, not test::usage. Maybe you can poke around to see if there is something like test::template? That's only a wild guess - it's what might make sense if this is actually an enhancement and not a bug. – Jens Nov 29 '12 at 7:58
@Jens that's a good idea. I can't see anything other than the usual usage messages, but maybe I am missing something. Let's see if someone else can find something – acl Nov 29 '12 at 12:09
It doesn't work for me with version 9 on Win 7, 64-bit. – david Nov 29 '12 at 16:31
I think the completion information is stored here: FileNameJoin[{\$InstallationDirectory, "SystemFiles/Kernel/TextResources/English/FunctionInformation2.m"}]. You will need to Uncompress the file after importing it as String. The actual usage messages are also in that directory, stored in Usage.m. If you look at most packages, the ::usage messages are plain text only, but when you load the package, and ? the symbol, you'll get a nicely formatted usage message with italicized arguments. This comes from Usage.m, not from the package file. – Szabolcs Dec 18 '12 at 1:49

To clarify the situation: In Version 9 on Windows and OS X, there is a new Make Template system which supports multiple templates for built-in functions. As part of the new system, unfortunately a bug was introduced which makes it ignore the usage statement for user-defined functions. This bug has been confirmed and we hope to fix it in a future release, though I cannot make any prediction as to when. The Linux front-end does not yet feature this new make-template system due to certain technical obstacles, which means it also does not suffer from the new bug.

There also seems to be some confusion as to how to invoke make template in version 9. Here is how it works: the new code assist offers possible completions as you type instead of forcing you to hit Ctrl/Cmd-k. Now, if you select a completion from the code assist using Enter, Tab, or left click, you will notice that a small down arrow appears, like so: . This down arrow is the collapsed template list. And this point, you can activate Make Template either using Ctrl/Cmd-Shift-k, or by hitting DownEnter to expand the arrow. Alternatively, if you've typed in a complete symbol, then Ctrl/Cmd-Shift-k will activate make template even if you haven't selected something from the code assist. Unlike previous version, Make Template does not currently attempt to complete a symbol before opening the template menu.

-
It's worth noting that you may specify a popup delay for autocompletion -- so you don't get the popups when you know what function you want but do get them when you're uncertain. Set this on the Mathematica 9 Preferences dialog, Interface tab. – murray Dec 10 '12 at 21:56

## Partial solution for Linux (Ubuntu 12.04, GNOME 3.4.2)

In version 8 I can expand it into a template the same way that normal expansion works. In version 9 this seems to work differently. You have to expand (or type) the full function name first and press then Ctrl+Shift+K

xxyyzz::usage = "xxyyzz[x,y]";


Now I type

xx


press Ctrl+K and then Enter and I get

xxyyzz


then I can use Ctrl+Shift+K to do the template expansion. This is still a bug to me though.

-
I can get up to he xxyyzz part, but after that if I press shift-cmd-k, nothing happens. do you get the xxyyzz[x, y] thing? what do you press, the same as in earlier versions? (shift-ctrl-k?) – acl Nov 29 '12 at 3:10
@acl After some hours of sleep I tried this again. On Linux-x86-64 this is exactly the way it works. – halirutan Nov 29 '12 at 12:16
This doesn't work for me on OS X. – Szabolcs Nov 29 '12 at 16:43
Me too, Win 7 x84. I filed a bug report. – Andrew Moylan Dec 3 '12 at 22:57
if this bug is confirmed on MMA9, it would be very annoying for me. I get the template working well for my/standard functions in MMA8. I will get MMA9 later today and we will see. – magma Dec 6 '12 at 1:12