26
$\begingroup$

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

$\endgroup$
10
  • $\begingroup$ Apparently, I was a little heavy handed with the "remove all instances of v.9 tag." Reverting ... $\endgroup$
    – rcollyer
    Commented Nov 29, 2012 at 3:01
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jens
    Commented Nov 29, 2012 at 7:58
  • $\begingroup$ @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 $\endgroup$
    – acl
    Commented Nov 29, 2012 at 12:09
  • $\begingroup$ It doesn't work for me with version 9 on Win 7, 64-bit. $\endgroup$
    – david
    Commented Nov 29, 2012 at 16:31
  • 1
    $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Commented Dec 18, 2012 at 1:49

2 Answers 2

12
$\begingroup$

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: scerenshot of collapsed completion menu. 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.

$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$
    – murray
    Commented Dec 10, 2012 at 21:56
4
$\begingroup$

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.

$\endgroup$
8
  • 1
    $\begingroup$ 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?) $\endgroup$
    – acl
    Commented Nov 29, 2012 at 3:10
  • $\begingroup$ @acl After some hours of sleep I tried this again. On Linux-x86-64 this is exactly the way it works. $\endgroup$
    – halirutan
    Commented Nov 29, 2012 at 12:16
  • 1
    $\begingroup$ This doesn't work for me on OS X. $\endgroup$
    – Szabolcs
    Commented Nov 29, 2012 at 16:43
  • 1
    $\begingroup$ Me too, Win 7 x84. I filed a bug report. $\endgroup$ Commented Dec 3, 2012 at 22:57
  • 1
    $\begingroup$ 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. $\endgroup$
    – magma
    Commented Dec 6, 2012 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.