Stefan Monnier writes: > I haven't looked at basic-save-buffer recently, but in the worst case we > could keep the current code and add a > > (if (null buffer-file-name) > (run-hook-... 'write-contents-functions) > ...) > > but admittedly, it's better if we can move the single call to > write-contents-functions so it's shared by the file and the > non-file cases. Eli Zaretskii writes: >> From: Eric Abrahamsen >> Date: Wed, 24 May 2017 12:55:53 +0800 >> I can try to produce a patch, if this is acceptable in principle. > > Yes, please. Richard Stallman writes: > Please try using write-contents-functions for this, and you'll see if it > does the job. If not, you'll see what more change is needed. Okay, here's a first stab at it. I think it should work correctly: all the short-circuit hooks get a chance to run in all cases, but the function only insists on the presence of a file if `write-contents-functions' are not present, or if they fail with a nil value. I'd like to specify in the docs that those functions should fail with an error. If this looks okay I'll spend a bit more time testing it, then make docstring and manual edits. Eric