From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Persistence of variables Date: Thu, 22 Mar 2018 09:02:07 +0200 Message-ID: <83a7v0k2z4.fsf@gnu.org> References: <87a7v20xlf.fsf@mbork.pl> <83a7v1lxxz.fsf@gnu.org> <87605p28ma.fsf@mbork.pl> <874ll94uvs.fsf@ericabrahamsen.net> <86bmfhqpez.fsf@zoho.com> <87605ovqkn.fsf@pointsman.de> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1521702045 32737 195.159.176.226 (22 Mar 2018 07:00:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Mar 2018 07:00:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 22 08:00:41 2018 Return-path: Envelope-to: geh-help-gnu-emacs@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 1eyuDH-0008PV-IP for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Mar 2018 08:00:39 +0100 Original-Received: from localhost ([::1]:59138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyuFK-0003JF-Oy for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Mar 2018 03:02:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyuEn-0003J3-CU for help-gnu-emacs@gnu.org; Thu, 22 Mar 2018 03:02:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyuEj-00074v-Gg for help-gnu-emacs@gnu.org; Thu, 22 Mar 2018 03:02:13 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyuEj-00074o-Cs for help-gnu-emacs@gnu.org; Thu, 22 Mar 2018 03:02:09 -0400 Original-Received: from [176.228.60.248] (port=3856 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eyuEi-0007k8-PW for help-gnu-emacs@gnu.org; Thu, 22 Mar 2018 03:02:09 -0400 In-reply-to: <87605ovqkn.fsf@pointsman.de> (message from Rolf Ade on Thu, 22 Mar 2018 02:36:56 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116258 Archived-At: > From: Rolf Ade > Date: Thu, 22 Mar 2018 02:36:56 +0100 > > >> (defun write-string-to-file (string file) > >> "Write STRING to FILE. > >> Create nonexistent FILE otherwise overwrite." > >> (interactive "sstring: \nFfile: ") > >> (with-temp-file file > >> (insert string "\n") )) > > > > We have append-to-file, which can do this out of the box. > > I'm sorry to nit, but Emanuels write-string-to-file differs from > append-to-file in that it ensures the file includes (only) string while > append-to-file, well, appends string to the file at the end, if it > exists. And I'm sorry to nit back, but creating an empty file is trivial, in which case append-to-file will do the same job. More to the point, I think this feature of append-to-file is largely unknown, which is why I made a point of mentioning it. (Btw, write-region supports a very similar feature.)