8
$\begingroup$
nb = CreateDocument[{Dynamic@$Context}, CellContext -> Notebook]

It will show Notebook$$22$93500` or something similar. How to get this context value without interfering with nb too much? You should also assume we do not control nb generation.

Unfortunately

AbsoluteCurrentValue[nb, CellContext]

Notebook

FrontEnd knows it: How does the Kernel know the $Context in a localized notebook, the question is if user can access it.

$\endgroup$
  • $\begingroup$ You want the notebook context when the notebook does not have CellContext -> Notebook set in its preferences? $\endgroup$ – Edmund Feb 2 '19 at 13:01
  • $\begingroup$ @Edmund for any case except CellGroup/Cell because then it does not make sense. But we can say: "what is the context in First@Cells[nb]. Then this makes sense for every scenario $\endgroup$ – Kuba Feb 2 '19 at 13:58
  • $\begingroup$ @Kuba this is something I’ve tried to figure out many times and I still have no idea how. The “switch context” functions in the "FE`" context get called when you evaluate anything in the notebook but I don’t know where the context gets pulled from. $\endgroup$ – b3m2a1 Feb 3 '19 at 5:36
  • 1
    $\begingroup$ @Kuba, the FE does not provide a mechanism to query for what that value might be. $\endgroup$ – ihojnicki Feb 4 '19 at 14:14
  • $\begingroup$ @ihojnicki Thanks for feedback. Somehow I was not notified about your comment. $\endgroup$ – Kuba Feb 11 '19 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.