From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: Proposal: move write-contents-functions higher up in basic-save-buffer Date: Tue, 23 May 2017 15:25:01 +0800 Message-ID: <87vaosyr02.fsf@ericabrahamsen.net> References: <87zie4yr9s.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1495524370 25598 195.159.176.226 (23 May 2017 07:26:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 23 May 2017 07:26:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 23 09:26:03 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dD4Cg-0006Tx-TE for ged-emacs-devel@m.gmane.org; Tue, 23 May 2017 09:26:03 +0200 Original-Received: from localhost ([::1]:46515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD4Cm-0005pu-5H for ged-emacs-devel@m.gmane.org; Tue, 23 May 2017 03:26:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD4CZ-0005oi-AQ for emacs-devel@gnu.org; Tue, 23 May 2017 03:25:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD4CU-0006sN-0f for emacs-devel@gnu.org; Tue, 23 May 2017 03:25:55 -0400 Original-Received: from [195.159.176.226] (port=48242 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD4CT-0006rp-QW for emacs-devel@gnu.org; Tue, 23 May 2017 03:25:49 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dD4CL-00060I-8a for emacs-devel@gnu.org; Tue, 23 May 2017 09:25:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 25 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:SpGA9VQRDFbWM0ScXcgEPjsXMjw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215121 Archived-At: Eric Abrahamsen writes: > 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. I forgot to say, auto-save would obviously be more difficult, since you'd have to handle the file name and location for the auto save file. I think it would be worth coming up with a solution, though.