Without having tested it myself would you like to try this snippet instead?

proc AddZoomStack {g} {
  set cmd {}
  foreach margin { xaxis yaxis x2axis y2axis } {
    foreach axis [$g $margin use] {
      set min [$g axis cget $axis -min]
      set max [$g axis cget $axis -max]
      set c [list $g axis configure $axis -min $min -max $max]
      append cmd "$c\n"
    }
  }
  set ::blt::zoomInfo($g,stack) [linsert $::blt::zoomInfo($g,stack) 0 $cmd]
}