emacs-devel
[Top][All Lists]
Advanced

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

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


From: Eric Abrahamsen
Subject: Re: Proposal: move write-contents-functions higher up in basic-save-buffer
Date: Sun, 28 May 2017 18:12:42 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Eric Abrahamsen <address@hidden> writes:

> Eli Zaretskii <address@hidden> writes:
>
>>> From: Eric Abrahamsen <address@hidden>
>>> Date: Tue, 23 May 2017 15:19:11 +0800
>>>
>>> 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.

Okay, I've poked at this in all the ways I can think of, and it seems to
work okay. Basic recap:

The goal is to re-interpret `write-contents-functions' as a mechanism
for allowing buffers that are not visiting a file to specify a custom
save mechanism. The original idea was to let special-mode buffers
install their own save routines, which would run on `save-buffer', and
also as a part of the `save-some-buffers' routine.

If the buffer-local value of `write-contents-functions' is non-nil for
buffer BUF, then `save-some-buffers' will accept BUF as a potentially
saveable buffer.

`basic-save-buffer' has been rearranged so that the
`write-contents-functions' hook is run a little earlier on. Only if the
functions in that hook fail will `basic-save-buffer' go on to prompt the
user for a file to save the buffer in.

I'm leaving `do-auto-save' as a problem for another day.

I've done a proper commit, with manual edits and everything. I'm a bit
leery of just committing this, as it theoretically touches every buffer
in an Emacs session. If anyone wants to take a hard stare at it, that
would be very welcome.

Eric

Attachment: 0001-Allow-write-contents-functions-to-short-circuit-buff.patch
Description: Text Data


reply via email to

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