7
$\begingroup$

I would like all new Input and Output cells, in fact all new cells including section headers and such, to have a specific stylistic property (CellBracketOptions -> {"Color" -> MyFavoriteColor}).

This is easy enough to do with CurrentValue[$FrontEnd,...]=.... However, I want this behavior to be exhibited only by new cells created in a specific *Mathematica** installation. I.e. a notebook generated elsewhere should look like it would in a default Mathematica FrontEnd, and only new cells created in this Mathematica installation should have the new property.

My use case here is that I have a notebook that I would like to use for collaborations, where each person would be assigned a color, and when they use their copy of Mathematica the cells they enter would automatically have a distinctly colored cell bracket. When exchanging this notebook, the cells authored by each user would be readily identifiable by their cell bracket color.

$\endgroup$
2
$\begingroup$

This is how you can customize given notebook. Needs some testing but seems to work.

It distinguishes users based on $UserName but you can use $MachineID or whatever.

CurrentValue[ EvaluationNotebook[], {TaggingRules, "Collaborators"}] = {
   "Kuba" -> Orange, "Friend" -> Red};

SetOptions[
  EvaluationNotebook[], 
  CellDynamicExpression :> Refresh[
    With[{col = CurrentValue[EvaluationNotebook[], {TaggingRules, "Collaborators"}]}
      ,
      If[
        MemberQ[First /@ col, $UserName]
        ,
        RunScheduledTask[
          SetOptions[#, CellDynamicExpression -> None];
          CurrentValue[#, {CellBracketOptions, "Color"}] = ($UserName /. col)
              , 
              {.2}
        ] &@EvaluationCell[]
 ]], None]]

enter image description here

$\endgroup$

Your Answer

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

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