<div dir="ltr"><br><br><div class="gmail_quote">On Tue, Jul 29, 2008 at 9:02 PM, David Lutterkort <span dir="ltr"><<a href="mailto:dlutter@redhat.com">dlutter@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Tue, 2008-07-29 at 13:04 +0200, Raphaël Pinson wrote:<br>
> There's a few things to note here:<br>
> * mv works ! Thank you David :)<br>
<br>
</div>Cool .. then I'll commit it upstream.<br>
<div class="Ih2E3d"><br>
> * save works but is not happy :(<br>
<br>
</div>That seems to be related to something else .. I could not reproduce the<br>
problem you were having. Do you have any other lenses in the directory<br>
where CommentTest lives ?</blockquote><div><br>Yes, there are. I'll try to put CommentTest in a separate dir and test again. I'll let you know how it goes.<br> <br><br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">> * "field=toto" got moved from 1st place to 2nd placed when it got<br>

> commented. This is a side effect to this (un)commenting method I<br>
> hadn't considered.<br>
<br>
</div>Yeah, if you want to avoid that, you have to insert the new node<br>
beforehand, e.g.<br>
<br>
  ins .field after /files/commenttest/field[1]<br>
<div class="Ih2E3d">  mv /files/commenttest/field[1] /files/commenttest/.field<br>
<br>
</div>New nodes are always added at the end (the same is true for 'set')<br>
<div class="Ih2E3d"></div></blockquote><div class="Ih2E3d"><br><br>That's useful indeed. I think it would be even more useful if aug_insert returned the path of the newly inserted node. Let's say there's already a .field before the one I'm inserting. Then this would be useful:<br>
<br>$to_move = "/files/commenttest/field[1]";<br>$c_field = aug_ins(".field", "after", $to_move);<br>=> $c_field = "/files/commenttest/.field[2]"<br>aug_mv($to_move, $c_field);<br>
<br><br>This way I would be sure to not make a mistake :)<br><br><br>Is there a way to refer to the first child of a node in the public API by the way? Or does it have to be done in the program using the API?<br><br>Say there is a parameter I need to put as the first child or a 'record' node for it to work, how do I write the aug_insert command?<br>
<br><br><br>
> * dealing with key in the lens is quite tricky. While it's possible to<br>
> declare a c_key function, it will only take a string, since the<br>
> contents of Util.del_str kw cannot be assigned to label currently.<br>
<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Yeah, in its current form, Augeas only allows exactly one primitive that<br>
sets the label for a tree node (either key, label or seq) What's missing<br>
is forming tree labels from multiple such lenses so that you can say<br>
<br>
        [ del /#[ \t]*/ "#" . label "." . key /[a-z]+/ . ... ]<br>
<br>
to prepend a '.' to the key parsed from the file. Initially, I marked<br>
that as an error, simply to be on the safe side. I now think it should<br>
be made possible, but it would require a fair amount of surgery in the<br>
internals (mostly lens.c, get.c, and put.c)</blockquote><div><br><br>I guess it's not an easy change at all. <br></div><br><br>Raphael<br></div><br></div>