with-temp-buffer as proposed by Brian