Thank you for the responses Vincent and Neil. <br><br>Neil, thanks for the information here-I will meditate on this and how to utilize it. <br><br>-Patrick<br><br><div class="gmail_quote">On 4 November 2012 22:34, Neil Van Dyke <span dir="ltr">&lt;<a href="mailto:neil@neilvandyke.org" target="_blank">neil@neilvandyke.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So you would like to be able to do things like rename an identifier, change &quot;(if X Y)&quot; to &quot;(and X Y)&quot;, change &quot;(if (not X) Y Z)&quot; to &quot;(if X Z Y)&quot;, etc.?<br>

<br>
If so, I would probably start by letting user specify transformation rules like for &quot;syntax-case&quot; or &quot;syntax-parse&quot;, do &quot;read-syntax&quot;, do some simple tree traversal of the syntax objects that tries the rules at each step, have a matching rule add to a list of &quot;progedit&quot; &quot;replace&quot; operations, and then finally feed those operations through &quot;progedit&quot;.<br>

<br>
And alternative would be to use parse info from Check Syntax, perhaps with the user&#39;s transformation rules in effect.  I haven&#39;t thought that through, so it might be overkill.  If you go that direction, you might think of a different rules language, rather than &quot;syntax-case&quot; or &quot;syntax-parse&quot;.<br>

<br>
One gotcha with &quot;progedit&quot; with syntax objects, depending on how you use it: comments are not usually in the syntax objects, and can get deleted if you are not careful, or left in the wrong place if you don&#39;t do additional work.  For example of changing &quot;if&quot; forms to &quot;and&quot; forms, you want to replace only the &quot;if&quot; keyword, not the entire form, so that:<br>

<br>
    (if X<br>
        ;; hi<br>
        Y)<br>
<br>
ends up looking like this:<br>
<br>
    (and X<br>
        ;; hi<br>
        Y)<br>
<br>
If the replace operation is for the entire &quot;if&quot; form, you will lose the comment:<br>
<br>
    (and X Y)<br>
<br>
For example of comments in wrong place, let&#39;s say you are getting rid of &quot;not&quot; around the condition of an &quot;if&quot; form by swapping the order of the arms.  Like in previous example, to preserve comments, you want your progedit replace operations to focus on small pieces that don&#39;t have important comments within them, so if you do that, then this:<br>

<br>
    (if (not X)<br>
        ;; X is false, so Y<br>
        Y<br>
        ;; X is true, so Z<br>
        Z)<br>
<br>
becomes:<br>
<br>
    (if X<br>
        ;; X is false, so Y<br>
        Z<br>
        ;; X is true, so Z<br>
        Y)<br>
<br>
The problem is that the comments are in the wrong places.  The current version of progedit doesn&#39;t have any magic for moving comments around -- you&#39;ll have to figure out how you want comments moved, and then probably move the comments using progedit delete and insert operations, in addition to the syntax changes you are making.  An alternative way would be to have the syntax reader include syntax objects for comments, and then deal with it in pattern-matching and transformation that way.<br>

<br>
(I plan to add these notes about comments to the progedit documentation.  No promises on building in smarter handling of comments into progedit itself anytime soon, unless a get a chance to think more about a good approach for it.)<br>

<br>
Neil V.<br>
<br>
</blockquote></div><br>