Mike on the MATLAB Desktop
October 20th, 2008
Function Hints
In MATLAB R2008b, your command line just got a heck of a lot smarter. We now have autocompletion for function parameters, which we call Function Hints. It’s simple to explain, and easy to use. If you typed “plot(” at the command line and waited a short time, you’d see the following:
Function Hints will show you which parameter you are currently editing in bold. The list of function signatures narrows as you type to exclude non-matching signatures.
This feature works with all our supplied functions as well as any you write. You get this feature automatically when your function is on the MATLAB path. The picture below is from myfun.m that has the following signature:
function myfun(x,y)
Function Hints is available in both the Command Window and the Editor, and can be turned off in the Preferences (File > Preferences > Keyboard).
This has been an oft-requested feature, and we’re really proud that we can finally share it with you.
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
11:51 UTC |
Posted in Command Window, Editor |
Permalink |
17 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
I’m noticing this only is working for functions that have the function signature as the first line of the file. I guess I’ve been wrongly putting the function help text first? Would be very nice to know how to put hints for alternate syntax into my functions.
Hi Mike,
These features are very helpul. It would be great to have the same functionnality in the Interactive Parrallel Command Window ;-)
PS: I understand better why it was difficult to reach MATLAB Central this morning. The new design of the webpage is really good!
Aurélien
@Ryan,
So it is. I will let the developer know about the first line thing. As for the alternate syntax, I will create an enhancement request for that.
@Aurélien,
I will create an enhancment request for those developers. Thanks.
Now that I have been using Amtlab with function hints for a few months, I have to say that they have proven to be much less usefull than I had hoped.
I find them far too slow to pop up and far to fragile once they have popped up.
It would be nice to have a button one could press to force the function hints to appear, similar to the way pressing tab makes the tab completion popup appear.
Daniel,
Thanks for the suggestion, it certainly would be handy.
Hi, two questions:
1. How can I create a custom list of function hints?
2. How can I get some function hints to list when there is a varargin input?
for example, if I have a function:
function output = myfun(varargin)
…
end
function hints will not list when myfun is typed on the command line, but i would like to list some.
Thanks!
Jon,
We currently don’t have a way to specify custom (or even more than one) hint for a user function.
I have reported the varargin issue to the developers.
Thanks!
I’ve been paying more attention to this feature in the past couple of weeks & I’ve decided that I don’t like the “suggestion” to appear front & center, right where I’m typing. Besides covering up the adjacent code, it is a big distraction to have this box pop up as I’m typing a obscure variable name. I’ve noticed that I’m ready to type something like:
rejectedvars = cell(1, length(rejectedindx));
I’m looking at the nearby code to remember the variable name of rejectedindx, and your box pops up to distract me.
Maybe you guys can figure out how users can specify a standard location for the suggestion box that is away from the action.
I showed this to a co-worker & he pointed out that this feature is just like the Microsoft “Clippy,” Office Assistance. Wikipedia points out that, “The feature evoked a strong negative response from many users.” And, I was one of them.
@OysterEngineer,
The Function Hints should appear below the line you are currently typing. There’s an importantance to spatial association. If we put the hints far away from where the user is typing then the user might not see it or associate it with the “(” action. We balance that against if it might cover up code or how distracting it might be. It’s impossible to get the balance right for every user. That is why you can disable them in either the Editor or the Command Window.
I have to disagree with your comparison to Clippy (of which I am also not a fan). Clippy was cutesy and animated. The function hints are all business. Secondly, the clippy would come up with help that was at best general, and at worst had nothing to do with your workflow. We are showing here information about the specific function you are using. A more apt comparison would be if we brought up FDATool whenever you typed “butter.”
The opinions of you and your coworker are noted and we do take them seriously. Potentially for annoyance is one of the many factors we deal with when designing new UI features. If you’re interested in participating in a usability study I can have one of our experts contact you.
I have to agree with Mike and disagree with Oyster – function hints has by now become a de-facto standard in many code development environments. They are an immeasurably useful development feature. I (and others that I know) have been waiting years for this feature to become available in Matlab. In my experience, after a short while you can’t understand how you could have worked without this feature previously. Comparison to Clippy is really an injustice.
@Yair,
I guess I have a different workflow. I can’t rely on hints for writing my code, I need to know for certain what the proper syntax is. The hint isn’t a legitimate substitute for the FRP. Frankly, I’m concerned that using hints will promote the “Hack & Hope” style of code writing.
But, I agree that the MatLab hints aren’t as annoying as Clippy. I was just reporting the observation of this particular co-worker. Who by the way, is more senior to me both in experience & responsibility.
What I don’t understand is why The MathWorks would spend time developing a feature like hints when there are so many much more pressing needs in the world of MatLab. Like: Ensuring that all the FRPs are of a consistent high standard. Or, making it easier to make document quality plots.
@OysterEngineer – I don’t want to step into official shoes, but as a fellow developer you must realize that a large engineering company like TMW has many different teams and people doing different things concurrently. The programmer who did the function hints would in any case not be assigned the task of updating documentation, which is a task for a technical writer. And being a Java-based Desktop developer, he/she would probably not be assigned the task of fixing C/C++-based Handle-Graphics code which is done in a different team. These tasks are simply not competing for the same resources.
Actually, TMW is pretty open to user feedback – if you would be willing to email them (isupport at mathworks.com) with specific problems in the FRP, “document quality plots” or any other issue, you would probably find a receptive ear. I know I did.
Then again, you must understand that TMW priorities may be different from yours, which is entirely legitimate.
Yair
Is it possible to get these hints for functions supplied as mex files?
we have a toolbox consisting of mex files, there are also .m files, but they just have comments (for help…) ctrl-f1 and related commands don’t appear to be able to pick up the parameter lists either from the mex file itself or from the .m if I add a dummy function declaration at the start if the .m file (which is further down the path than the mex)
It would be nice to have a button to force the function hints to appear, similar to the way pressing tab makes the tab completion popup appear.
I was just wondering about the status of the enhancement request for alternate syntax (posts 1 and 3)? It would be a really great feature!!!
@Thomas,
Thanks for your continued interest. At this time, there is nothing further that I can say about those requests, other than we are considering them.