How about this?: format[l_List] := ToBoxes@# /. {"set", "[", RowBox[{a_, ",", b_}], "]"} :> {a, "=", b, ";", "\n"} & /@ l // RowBox // BoxData // Cell[#, "Code"] & // CellPrint; format@{set[a, 1], set[b, 2], set[c, 2]}


You could try the following approach, with a secondary kernel (K2) and using CellInformation to check if a cell or notebook is currently in the "Evaluating" state: Get the current evaluator names: evaluators = EvaluatorNames /. Options[$FrontEnd, EvaluatorNames]; Add a "K2" kernel if there isn't one: SetOptions[$FrontEnd, Union[Join[...


An example of evaluating the expression outside the notebook and then write the result in the notebook. exampleNB = CreateDocument[]; NotebookWrite[exampleNB, Cell["example of evaluating input programmatically", "Text"]]; NotebookWrite[exampleNB, Cell["D[Sin[ RandomReal[] x],x]", "Input", CellTags -> 1]]; ...

Only top voted, non community-wiki answers of a minimum length are eligible