8
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.

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • You want the notebook context when the notebook does not have CellContext -> Notebook set in its preferences? – Edmund Feb 02 '19 at 13:01
  • @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 – Kuba Feb 02 '19 at 13:58
  • @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. – b3m2a1 Feb 03 '19 at 05:36
  • 1
    @Kuba, the FE does not provide a mechanism to query for what that value might be. – ihojnicki Feb 04 '19 at 14:14
  • @ihojnicki Thanks for feedback. Somehow I was not notified about your comment. – Kuba Feb 11 '19 at 07:39

0 Answers0