From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Why does saving a buffer to a new file clear local variables? Date: Thu, 12 Dec 2024 13:50:14 +0100 Message-ID: <875xnp83qx.fsf@web.de> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: help-gnu-emacs@gnu.org To: Patrick Nicodemus Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 12 13:50:01 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tLidl-0009By-Er for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 12 Dec 2024 13:50:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLidB-0001tD-NC; Thu, 12 Dec 2024 07:49:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLid1-0001sc-Mo for help-gnu-emacs@gnu.org; Thu, 12 Dec 2024 07:49:15 -0500 Original-Received: from mout.web.de ([212.227.15.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLicz-0001Xg-5c for help-gnu-emacs@gnu.org; Thu, 12 Dec 2024 07:49:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1734007749; x=1734612549; i=michael_heerdegen@web.de; bh=dV4h5jkLpNB393wuQeU3AJLjsqMv1Y57i6RZoqudHkA=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=jrqMyx6yTb8hygLHdXkO9fUt2AGbuR27PV7uN8QWjdBfVZNctgV11y7Jv16r8uLl HDHPLVSYPYJVsPpBxlvlH9mgglxEW6lEZpl+0lkndiOgINRLhPBFBB3LihaFSm3/r WAGOXbWYAqlKiict9i0sEAPYdqqKx3WLLdNNddmDrgvFBauHVt+5FMo7IdYhjQLH7 rufqWfrDPA8Lmn0Bik48LuFzRT5/mxbkRDuBtFPNGfZYAYjLR/5Gfntn7424OdIz4 BILSMHYK1EuXWWjxSU+9neqTgzb8cq5GBLtVcDXVh40CEAiF1chTb7FXdYxVlK9W0 UNCo7K1RnkZ6cliDww== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M6YNJ-1tFMqK0htR-005QkW; Thu, 12 Dec 2024 13:49:09 +0100 In-Reply-To: (Patrick Nicodemus's message of "Tue, 10 Dec 2024 23:05:00 -0500") X-Provags-ID: V03:K1:CgpAl/9ZW+Ci32qZdRUAKY+prMUanvkKT0XBcBivyk4VponssHu NsKLKcLIxrg7dvuK8B6j0R0cYi6hldw9h6L2c+nZ5Lzg9KzcKpolQgY2kRL/1/6J+0llw5U 8sc5lB95eQr+tOXhofFIgyrbOKZt71CaqWqmn/jBFSdnBSbM/RcLQeHtL6SP4fcXM3avo2K q/ymzOXvIpi93yVRZRmeQ== UI-OutboundReport: notjunk:1;M01:P0:OHCsTnw/zes=;5QB8f6XeqqAmPnA+uNBHhpcrgg2 OQLpbyGkvULz9XAUt+mZ0LCaypoxGvDXdJwlMdkgLf5xaxeBf6i2KrQ84kTpjSRfUsVBxYc2N Kuj9pjhFDbz2cpqtnAErCLS70kXkLLqsPfN2Xbhd7Agc2XxVTBRv7NC8R7cBE7zWvQBTWMELt eR53DSehrdG2rai5EQknCgqE45vte5kdMiMu05RHyY1d617MMt+whUXIFOC705kZQzDKczymC h8eYxQTp0bw5BdD4p8Pb7T981YO/5AAKJx8IDotSsHV4uNcVgQpgvbueCAYxGubZ5AVVroAaZ vZE4XmXtOww0cX2fihKUOsXeQ5T72gQH6BGIe4emc9I/8b7YfgtJzM/rgVuhQs4CP9IoaBHeb fw4nQxAm1wBExIL0L3zBunodeepZk0ssI3jPud7iV+DyA7+OsH9KyGZx4V8X08NOWu5QR4KyE Vnjo3mGkQdWTRjKtQO6BJBfgF92BJPnxArF6PczUFNINavLtb06Fp/64xTxWG9XMl/cvsVkNN T8/AdQgBwu1GVxl9nr9ZtF6jiX9ge2Xy6ptjVI9KfcLnHEKH+uxhVPUDh9rnKAc6H2tNgLFAu sXdWX+3kUjKz1IsKLo+XfDUp1NkE0iuqvc2JAnwpSWRkOQVg1x8zoo41ys/LqdFO+vRx1H8L6 7PheZMMEXTxiIUy3OJnY8GlyCBOhTp3a3Y1lFhr1+Qz3U8qSjwFaG/fNSkFOGFn9ObpiCuLZp g+coka8/Kur+R4vaVMemExw0pHTtGWzkuM2yHIENdMkUCrw+MqXTryto5XBahcFPiwyWxsew Received-SPF: pass client-ip=212.227.15.14; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148777 Archived-At: Patrick Nicodemus writes: > If I create a new buffer like (get-buffer-create "tmpbuf"), > switch to the buffer, and execute the commands > (make-variable-buffer-local "abc") > (setq abc 3) > and then save the buffer to, say, "tmpbuf", then abc becomes nil. > Why is this the case? > Is this behavior documented anywhere? > I checked that it doesn't change the major mode. It is "Fundamental" before > and after saving. I recall we had a very similar question not long ago. I think Eli gave an answer, and it was like that this situation counts as visiting a file, and visiting a file by default clears all local bindings via `normal-mode'. There are ways to modify this behavior - in your scenario, turning `change-major-mode-with-file-name' off prevents losing your local binding. Giving a variable a non-nil `permanent-local' property also would have this effect - see `kill-all-local-variables's docstring. But the details depend on the use case. Michael.