Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

In many of the inbuilt mathematica function, variables appear aqua like in:

enter image description here

However, when creating your own function, variables no longer have that green coloring and are instead colored like an undefined variable

enter image description here

Is there any way to define functions so that variables used in arguments like in the manner above can get the aqua syntax coloring?

share|improve this question

marked as duplicate by Mike Honeychurch, acl, Mr.Wizard Jul 16 at 1:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
you can set this via the preferences panel, the options inspector or a stylesheet. All of these methods have been discussed on this site. –  Mike Honeychurch Jul 15 at 23:53
    
@MikeHoneychurch That has to due with changing the syntax highlight coloring itself. I am asking how to get variables used in arguments of user-defined functions to exhibit that syntax coloring. –  1110101001 Jul 16 at 0:08
    
ok. misunderstood. @acl has your answer –  Mike Honeychurch Jul 16 at 0:18
    
@MikeHoneychurch looks like a duplicate –  acl Jul 16 at 0:22

1 Answer 1

up vote 3 down vote accepted

You can use SyntaxInformation. In this case,

SyntaxInformation[Lim] = {"ArgumentsPattern" -> {_, _, OptionsPattern[]}, 
   "LocalVariables" -> {"Limit", {2}}}

does what you want.

share|improve this answer
    
I also have another function ImplicitPlot[p_, q_, r_] := ContourPlot[p, q, r] and I tried doing something similar: SyntaxInformation[ImplicitPlot] := {"ArgumentsPattern" -> {_, _, _, OptionsPattern[]}, "LocalVariables" -> {"Plot", {2, 3}}} but it's not working for this one... any idea why? –  1110101001 Jul 16 at 1:01
1  
I'll take a look in a few hours if nobody else does so by then. Away from mathematica right now. –  acl Jul 16 at 1:02
    
Do SyntaxInformation[implicitPlot] ={"ArgumentsPattern" -> {_, _, _, OptionsPattern[]}, "LocalVariables" -> {"Plot", {2, 3}}} and does work. Make sure you use Set (=) and not SetDelayed := ! I searched for an explanation of the difference and found this which, to my surprise, I wrote myself. –  acl Jul 16 at 9:58

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