From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Write a file with backups? Date: Sun, 28 Jan 2018 22:42:42 +0100 Organization: Programmerer Ingebrigtsen Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1517175672 12335 195.159.176.226 (28 Jan 2018 21:41:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Jan 2018 21:41:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 28 22:41:08 2018 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 1efuhG-0002o0-6n for ged-emacs-devel@m.gmane.org; Sun, 28 Jan 2018 22:41:06 +0100 Original-Received: from localhost ([::1]:39139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efujH-00041R-3N for ged-emacs-devel@m.gmane.org; Sun, 28 Jan 2018 16:43:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efujA-00040U-5H for emacs-devel@gnu.org; Sun, 28 Jan 2018 16:43:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efuj7-0006Yb-2L for emacs-devel@gnu.org; Sun, 28 Jan 2018 16:43:04 -0500 Original-Received: from [195.159.176.226] (port=60763 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efuj6-0006YC-RV for emacs-devel@gnu.org; Sun, 28 Jan 2018 16:43:00 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1efugv-0001VY-So for emacs-devel@gnu.org; Sun, 28 Jan 2018 22:40:45 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 42 Original-X-Complaints-To: usenet@blaine.gmane.org Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAADFBMVEVVR1OUgok6MDogGCC9 5m/gAAACPElEQVQokR3SsUsbcRQH8C+XpMiJNG29Ip1UIugFTO1aaA5bxV6guYT7ZejWTXTwHxB6 nrWEWLqonS8KJfwiOXVKM+QcYjsU7NCxyzVdwnWIFQvnJeT17Ns+7/HgfeHBgixU6Sxbv044CCzR 7DqtlP/3rQMaiCWnNiaXWx9C0KnoHC/JH7/HGyHc2eQfBF/e5XmIX0RX+a87x8NVUKk4yWNqaa3F D3Gdi0k5tlw8kg9nsMcWWEy3Em+avgg2tqBJLztTeXKXwJaeKXeqnYnCZwVg40phRLx+rokQwGx3 cUStxJO+cR/spD9XlPmtbhsM0/anuaEV2+2fKxL629EpIH3x83TcgI8daSGRatd+TJZxJosSq9uB k3gxgT2QpPFaMxVNu2jdowdCcXldS11eQilQZo8xpievnkDJ/FZvoGlpGXL6W14KB45JAYT3cRbi NTXoEbRX7KbUp/1sB4r0H+ugzSFwIRZuTwfO9gEAvqXrZv1242EvzKNKstUdDHu7j0tojs5TQF6y MTqbRwDX6QXSiqfzAjyz7QgVtuqxIQUuN+rxGEt1tEoGnh+tq5LOtxaNPHoX2lFlfnR/Kx0AA1c9 1NdMQ7U9A5YhILrqWXF7UA5PsGkj04dQa5QhBD0KbHJncpO7iFCP3Brf38hNKxg2u3RZq5fcu1Pj iFRpYNm2IXvnFXi8MouIfwKxKYK8YoSneCOMWQH51kHY1UsDuxO+S5uLETLAnTaQdTltmxzcFSBl r2Ty0DNTfPMfCCQazDVoamEAAAAASUVORK5CYII= Mail-Copies-To: never Cancel-Lock: sha1:e5I0SExIVq90cP7zb2b1bhQWbVM= 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:222280 Archived-At: tl;dr: I find myself often writing code that saves data to a file without visiting that file. In those cases, Emacs doesn't seem to offer any mechanism to create backup files easily. It would be nice if that existed. Longer version: When Emacs normally handles files, the user gets presented with a buffer that visits a file, and when the user saves the buffer (for the first time in the session), a backup file is created according to the user's preference (~ files or ~2~ files or whatever). If, however, you have a mode that maintains data in a structure on a file (or a lot of files), the user is usually presented with a buffer that visits no files, and when data is saved (using `write-region' normally), you get no backup files. Some special modes create backup files "manually" if they deem that helpful, and have special variables to customise the names and backup schemes etc. That's both wasteful (to have each mode reimplement backuping (usually badly)) and confusing to the user. So I think it would be really nice to have a function like `write-region-with-backups' (or yet another parameter to `write-region') that would make Emacs go through most of the normal file-backey-upness stuff. You'd need to tweak the code, though, to keep the necessary data to avoid excessive backup file creation: Perhaps some kind of file name assoc that says when we last backed up the file to emulate how visited files are backed up (i.e., once per "session"). I think this would be very handy. If this already exists somewhere, that would be even better. :-) The other way for these modes to get proper backup action is to just visit the data file in question, but that can get rather unwieldy if you have a lot of them. You don't want to pollute the buffer list with useless data files... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no