If using a mapDirectory influence closure, you must do the following to override the current mapping's alias:
binder.getCurrentMapping().setAlias( 'foo' );
Give the binder a direct passthrough method to do this for consistency and brevity.
binder.setAlias( 'foo' );
but in order to do that, you must be already in a mapping sequence. If not, there is no context. Is this what you mean/?
Yes, that's point-- this closure is called during execution of a mapDirectory() command, which means there will always be a current mapping context.
Looking at this ticket again-- i think the fix is even simpler. We just need to pass the current mapping to the closure as an argument! Then there will be no need to try and get it from the binder.
In fact, the hint for the "influence" argument says this:
The influence closure or UDF that will receive the currently working mapping so you can influence it during the iterations
That's not even a true statement since the influence closure only receives the binder and the targetpath right now, but I think it shows that this is how the closure was originally intended to be implemented.
Basically, edit this code in the binder's mapDirectory method:
Now the influence closure will receive a reference to the current mapping.