From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Rolf Ade Newsgroups: gmane.emacs.help Subject: Re: Persistence of variables Date: Thu, 22 Mar 2018 02:36:56 +0100 Organization: Me Message-ID: <87605ovqkn.fsf@pointsman.de> References: <87a7v20xlf.fsf@mbork.pl> <83a7v1lxxz.fsf@gnu.org> <87605p28ma.fsf@mbork.pl> <874ll94uvs.fsf@ericabrahamsen.net> <86bmfhqpez.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521682723 18825 195.159.176.226 (22 Mar 2018 01:38:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 22 Mar 2018 01:38:43 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) 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 02:38:39 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 1eypBd-0004nA-Ia for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Mar 2018 02:38:37 +0100 Original-Received: from localhost ([::1]:58389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eypDg-0004u3-Ja for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Mar 2018 21:40:44 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 21 Original-X-Trace: individual.net +x6jMDE5+oFrLnDKRwKACAud23VpGcJKvAXfrZKCTl6gjhhCg= Cancel-Lock: sha1:tpPOT2D2wxG4eSW01tsEd8D/Re8= sha1:uyp3RjbU/SXSzcFfzrwbJ1/Gqwo= Original-Xref: usenet.stanford.edu gnu.emacs.help:222138 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:116256 Archived-At: Eli Zaretskii writes: >> From: Emanuel Berg >> Date: Wed, 21 Mar 2018 19:00:52 +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. That makes write-string-to-file are more useful building block in the context of the question of the OP, IMHO. But it's musing anyway.