The autocompletion is very convient in Mathematica
,but it will make one annoying sometimes when you have a ton variables.I give a scene I encounter.I usually make many custom functions in my init.m
,for example
System`testFunction[variablea_]:=Module[{variableb=variablea},variableb+1]
http://o8aucf9ny.bkt.clouddn.com/2016-06-25-01-06-52.png
But when I launch my Mathematica
as soon as there are many variables prompt to auto-autocomplete.like this
So my question is how to make the variables in init.m
not impact the autocompletion
Answer
Don't put symbols you don't want to show up in auto-completion into the Global`
context. Use the same mechanism you would for a package.
myfun; (* create in Global` *)
Begin["MyPrivateInitContext`"]
myfun[x_] := Module[{y=x^2}, y^2]
End[]
I noticed you are putting your function into the System`
context. This seems like a bad idea. The System`
context is for builtins.
What I do personally is that I create a complete package and load it with Needs
in init.m
. This way the package lives in its own separate context, i.e. neither in System or Global.
If the package is very simple, it can also be inlines in init.m
: just put the same code that would go in the package file into init.m
If these definitions need to be accessible from subkernels (when parallelizing), then use the Autoload directory instead of init.m
.
Comments
Post a Comment