[racket] programmatic file editing

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Thu Jun 7 01:14:10 EDT 2012

Rodolfo Carvalho wrote at 06/07/2012 01:05 AM:
>
>      #:insert
>      `(
>       ;; Add a missing #lang line to the top of the file:
>       (0 "#lang setup/infotab\n")
>
[...]
> Sorry if I just didn't get it right, but wouldn't it be useful to have 
> a conditional insert?
> For instance, it would make sense to insert a #lang line only when 
> there isn't one already.

That was toy example of a call to "progedit", like a test case, and not 
very clear.  In a real program, you'd programmatically build the list 
you pass to the "#:insert" keyword argument of "progedit".  So, you 
would only add the (0 "#lang setup/infotab\n") to that list if you found 
through other means that you needed to add a #lang line.  "progedit" 
itself only performs the inserts, deletes, and replaces.

Neil V.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120607/41d0a4d5/attachment.html>

Posted on the users mailing list.