chickadee » augeas » aug-insert!

aug-insert! a path label #!optional before?procedure

Creates a new sibling LABEL for PATH by inserting into the tree just before PATH if before? is #t, or just after PATH if before? is #f (the default). The new node's value is null.

PATH must match exactly one existing node in the tree, and LABEL must be a label, i.e. not contain a /, * or end with a bracketed index [N].

Returns an unspecified value on success; raises an error if the insertion fails.

Unfortunately, there is no way to set the value at the same time, nor to capture the inserted node into a variable.

Example:

(aug-print a "/files/etc/hosts/1/alias")
 ;; /files/etc/hosts/1/alias[1] = "localhost"
 ;; /files/etc/hosts/1/alias[2] = "galia.watzmann.net"
 ;; /files/etc/hosts/1/alias[3] = "galia"
(aug-insert! a "/files/etc/hosts/1/alias[2]" "alias" #t)
(aug-insert! a "/files/etc/hosts/1/alias[3]" "alias")
(aug-print a "/files/etc/hosts/1/alias")
 ;; /files/etc/hosts/1/alias[1] = "localhost"
 ;; /files/etc/hosts/1/alias[2]
 ;; /files/etc/hosts/1/alias[3] = "galia.watzmann.net"
 ;; /files/etc/hosts/1/alias[4]
 ;; /files/etc/hosts/1/alias[5] = "galia"