Question: A better way to do this evalindent?

I need to find and remove any abs that shows up only inside ln anywhere in an expression.

I used to do this in multiple steps before, by using loop and subs. But I am now learning evalindet which is powerful command. I should use it more. 

I wanted to see if it is possible to do this in one call to evalindent. Both finding and replacing.

Here is an example. Given

expr:=sin(x)+ln(abs(x))+ln(x+abs(y)/sqrt(abs(x+3)))+ln(x^3)+cos(abs(x));

The goal is to change it to the following

This is what I ended up with

restart;
expr:=sin(x)+ln(abs(x))+ln(x+abs(y)/sqrt(abs(x+3)))+ln(x^3)+cos(abs(x));
expr:=evalindets(expr,
          'specfunc( satisfies(u->has(u,abs)),  ln)',
          f->evalindets(f,'specfunc(anything,abs)',f->op(1,f))
          )

My question is: Is there a more optimal or better way to do this? I had to use evalindets inside the transformer to remove the abs. At first I did not know if it will work, but it did work.

Any place for improvement?

Maple 2020.2

Please Wait...