Use of with_stdout inside function fails



I am experimenting with a way to surpress messages
from integrate, using with_stdout inside another
function.

Here is a simple example which does not succeed in
getting with_stdout to work inside another function.

quiet_mode (file,expr) is designed to emulate the
classical black hole effect of using "/dev/null" as the
destination file in a unix system.

In this example, I want to surpress the 
    'Principal Value'
message from integrate.

(%i1) load("quiet-mode.mac");
(%o1) "quiet-mode.mac"

(%i2) file_search("zzz123");
(%o2) false

/* use of with_stdout inside quiet_mode does nothing */

(%i3) quiet_mode("zzz123",
           integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf));

Principal Value

(%o3) 'integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf)

(%i4) fundef(quiet_mode);
(%o4) quiet_mode(ffile,e):=block([rr],rr:apply('with_stdout,[ffile,e]),
                 ?delete\-file(ffile),rr)

(%i5) file_search("zzz123");
(%o5) false

/* interactive use of with_stdout surpresses the message */

(%i6) with_stdout ("zzz123",
            integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf));

(%o6) 'integrate(sin(x)*(sin(x^2)*(sin(x^3)+1/x)+1/x),x,0,inf)

(%i7) file_search("zzz123");
(%o7) "zzz123"

(%i8) printfile("zzz123")$
Principal Value
---------------------------------

Ted Woollett
p.s.  file quiet-mode.mac
-----------------------------
/* quiet-mode.mac */

  quiet_mode (ffile,e) :=
    block ([rr],
      rr: apply ('with_stdout, [ffile,e]),
      ?delete\-file (ffile),
      rr)$
      
      
 display2d:false$