This is about letting `save-some-buffers' check `write-contents-functions' before insisting on a buffer having a file to write to. There was a conversations about this on emacs.devel: https://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00653.html The patch I ended up with is attached. I'm reporting this just so the patch (and the idea) doesn't get lost. I still think it's worth doing.