1
$\begingroup$

I put the following code using the Xcode application into an init.m file that is auto-loaded at startup. I can now turn on WholeCellGroupOpeners using a shortcut. Works great.

FrontEndExecute[
 AddMenuCommands[
  "DuplicatePreviousOutput", {Delimiter, 
   MenuItem["OffWholeCellGroupOpener", 
    FrontEndExecute[
     SetOptions[SelectedNotebook[], "WholeCellGroupOpener" -> True]],
     MenuKey["w", Modifiers -> {"Control"}], 
    System`MenuEvaluator -> Automatic]}]]

I would like to make the control more usable by making the same Control+w toggle between True and False states.

I tried substituting in

 "WholeCellGroupOpener" -> !CurrentValue@Options[SelectedNotebook[], "WholeCellGroupOpener"]

For some reason this code works as expected inside a regular .nb file but fails to work in the init.m file where I need it. Any ideas? Does it have something to do with global namespaces?

$\endgroup$

1 Answer 1

0
$\begingroup$

This seems to work. Not sure why the other way doesn't. I'll leave this solution up for reference.

"WholeCellGroupOpener" ->If[SameQ[CurrentValue[SelectedNotebook[],"WholeCellGroupOpener"],False],True,False]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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