title: code manipulation via interactive tree for Mathematica
body: <p><a href="https://stackoverflow.com/questions/6137716/mathematica-editor-removing-the-right-matching-automatically-when-the-left">This question</a> caused me to ponder an interactive method for editing code.  I wonder if it is possible to implement something like this given the dynamic capabilities of Mathematica.</p>
  
  <p>Consider an expression:</p>
  
  <pre><code>Text[Row[{PaddedForm[currentTime, {6, 3}, NumberSigns -&gt; {"", ""}, NumberPadding -&gt; {"0", "0"}]}]]
  </code></pre>
  
  <p>And its <code>TreeForm</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/t4V1U.gif" alt="enter image description here"></p>
  
  <p>I would like to be able to edit that tree directly, and then have the result translated back into Mathematica code.  One should at least be able to:</p>
  
  <ul>
  <li>rename nodes, replacing symbols</li>
  <li>delete nodes, reverting their leaves to the node above</li>
  <li>reorder nodes and leaves (the order of arguments)</li>
  </ul>
  
  <p>I believe that there are languages or environments which specialize in this kind of manipulation, and I do not find that attractive, but I am interested in having this kind of interactive tree editing for special purposes.</p>