How do you change the $ContextPath of a cell without using Prepend
:
$ContextPath = Prepend[$ContextPath, "PackageName`"]
I was looking around at the Documentation for $ContextPath
and I decided to evaluate the first input cell in there.
Before Evaluation:
After Evaluation:
I'm guessing that the difference here is that when this documentation was being written WebServices
was not enabled for the person writing it. We can see that Global
is in the context of that cell because this has been explicitly mentioned. Look at the expression by going to Cell > Show Expression
.
The option CellContext
is set to Global. Now, lets make a new cell and evaluate $Context
.
This means that inside that cell I cannot use any of the global objects that I have created in other notebooks. We can maybe add Global by changing the CellContext option of the cell. We do this by showing the expression and editing. When you evaluate you will see that the context has changed to global. Now, just for the heck of it lets try this in the cell in which we just changed the context to global.
Print["Outside Module = ", $ContextPath]
Module[{},
Print["Inside Module = ", $ContextPath];
Manipulate[
Print["Inside Manipulate = ", $ContextPath];
Row[{
Plot[x, {x, -3, 3}, PlotRange -> {{-3, 3}, {-3, 3}}]
}],
{{p1, {-1, 2}}, Locator, Appearance -> "L1"}
]
]
Do you get something like this:
Why does the context change inside Manipulate? Inside other notebooks this doesn't happen. I'm guessing it has to do with the settings of the reference stylesheet but I just can't figure it out. How can we change the settings of the documenation notebook temporarly so that we can use the global context everywhere throughout the notebook?