[darcs-users] Re: A couple of pre-newbie questions

Tommy Pettersson ptp at lysator.liu.se
Sun Mar 6 08:36:45 UTC 2005

On Sun, Mar 06, 2005 at 08:26:18AM +0100, Thomas Zander wrote:
>                                                             [...] It would 
> be a whole lot better if I could mark a section of a file where I wanted to 
> do the replace (one method for example).

Hm, yes, a "condition" for the replace would not have to be
reversible, would it?  Only the substitution must be, e.i., you
can't s/foo*/bar/ since it can't be reversed to s/bar/foo*/.

But something like a sam expression:

  , x/\n{/ .,/\n}/s/foo/bar/g


  , x/\/\*/ .,/\*\//s/bar/foo/g

(or a similar sed expression) could be reversed (just reversing
the substitution).

I'll explain how it works in general.  It picks out pieces
of the text with regexp matching and performs commands
(substitution in this case) in these pieces (function bodies
and comments in the two examples).

It would be an interesting task to design a pattern language
like sam's or sed's that is confined to only reversible

Tommy Pettersson <ptp at lysator.liu.se>

More information about the darcs-users mailing list