[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal: move write-contents-functions higher up in basic-save-buffer

From: Eric Abrahamsen
Subject: Proposal: move write-contents-functions higher up in basic-save-buffer
Date: Tue, 23 May 2017 15:19:11 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Most special-mode buffers aren't visiting a file, and thus they miss out
on all the `do-auto-save' and `save-some-buffers' mechanisms. I'd guess
a fair number of packages that use special-mode *do* have some concept
of saving, or persisting data in some other way.

I think the `write-contents-functions' hook would be an ideal way of
solving this problem, except that the way `basic-save-buffer' is
written, it won't let you get that far without having a file name.

My proposal is to declare `write-contents-functions' as *explicitly* a
hook for buffers that don't have any file associated with them at all
(this would be in contrast to `write-file-functions'). Then we'd move it
up higher in the process: either earlier in `basic-save-buffer', or all
the way up to `save-buffer' -- that way `basic-save-buffer' could only
be for buffers that have a file.

Then `save-some-buffers' could check for the buffer-local presence of
this variable, and do the save. `do-auto-save' would behave the same.
"s" could be bound to `save-buffer' by default in special-mode.

WDYT? I think the docstring of `write-contents-functions' already
supports this interpretation, it just needs a bit of tweaking to divorce
it from buffer-file-name altogether.


PS: My original idea was to introduce a buffer-local
`save-buffer-function' variable, but I think this makes more sense.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]