From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: Should write-contents-functions be permanent-local? Date: Mon, 14 Aug 2023 23:35:44 -0700 Message-ID: <87edk494z5.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33351"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 15 12:53:37 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qVrg8-0008SN-JW for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Aug 2023 12:53:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVrfR-0006ja-R6; Tue, 15 Aug 2023 06:52:53 -0400 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 1qVnqJ-0000ef-Qz for emacs-devel@gnu.org; Tue, 15 Aug 2023 02:47:52 -0400 Original-Received: from out-75.mta1.migadu.com ([95.215.58.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVnqG-0003w5-NE for emacs-devel@gnu.org; Tue, 15 Aug 2023 02:47:51 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1692082065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=hZor7IQGT2LLJkJu71qQFlTjPn09DR+Ow7jveWJ7NnU=; b=Xwav5JFQs3VRBPM3mSpTwoMkfbFUREgtUAefbn+sZXcNcFSbLjY+UwVWLQmKwWLTdBA3tM dj56CdKzo0xE4ssyx+lqzf9lI8jaYPVTB9U9RbWlPNMj8FpS4ac1f0A61f9+qHGvJh68xM CPfAQYdc6iQ84RSV9YHNk/Jpt0OcCog= X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.75; envelope-from=joseph@breatheoutbreathe.in; helo=out-75.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 15 Aug 2023 06:52:51 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308752 Archived-At: In hyperdrive.el, we set write-contents-functions in a local minor mode so that buffer contents can be written to a hyperdrive "file." In our use-case, we want write-contents-functions to stay the same even when the user manually changes the buffer's major mode. AFAIK, there's no way to make a variable permanent-local on a per-buffer basis, and we don't dare to make write-contents-functions permanent-local globally. The solution we came up with in hyperdrive.el is to hook into after-change-major-mode-hook with a function (with permanent-local-hook) that sets write-contents-functions after kill-all-local-variables: https://git.sr.ht/~ushin/hyperdrive.el/tree/master/item/hyperdrive.el#L320 Does anyone have a better solution? WDYT about making write-contents-functions permanent-local? Joseph