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: Re: Should write-contents-functions be permanent-local? Date: Tue, 15 Aug 2023 18:48:51 -0700 Message-ID: <87a5urda5e.fsf@breatheoutbreathe.in> References: <87edk494z5.fsf@breatheoutbreathe.in> <83pm3oa5f5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33312"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 16 04:21:52 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 1qW6AS-0008TT-2J for ged-emacs-devel@m.gmane-mx.org; Wed, 16 Aug 2023 04:21:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW69Y-0007Hl-4e; Tue, 15 Aug 2023 22:20:56 -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 1qW5kD-0003ZY-Bx for emacs-devel@gnu.org; Tue, 15 Aug 2023 21:54:45 -0400 Original-Received: from out-46.mta0.migadu.com ([2001:41d0:1004:224b::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qW5kA-0003HN-GF for emacs-devel@gnu.org; Tue, 15 Aug 2023 21:54:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1692150880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=guQarOxwPC1gXHnRq46g8dR8E51bKUyEZoBFK9dX3HU=; b=ezIMh3G77ZZZQob2NjM53aVZlkuQQrI2v+zXsu1l+rSsKj18z4fVSpgSRCyiQ+xwPQiKiI PtFUvzx7gK6ebVLRhvPuHsd0PYU+YhMqTVLVA7CPWrJw30o91eajZ64IWAqtQKaGuT7mYm EvhDa67JlFPMoL+pMm6PoLE/jGn8rcE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: <83pm3oa5f5.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::2e; envelope-from=joseph@breatheoutbreathe.in; helo=out-46.mta0.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=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 15 Aug 2023 22:20:53 -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:308782 Archived-At: Eli Zaretskii writes: >> From: Joseph Turner >> Date: Mon, 14 Aug 2023 23:35:44 -0700 >> >> WDYT about making write-contents-functions permanent-local? > > That cannot be done, sorry. Some modes set this to mode-specific > values, you can find this even in the Emacs source tree. But even > without those examples, a variable that were not permanent-local for > so long cannot be suddenly made permanent-local, because it will > almost certainly break something somewhere. Thank you for the explanation! > In any case, if you are okay with making the variable permanent-local, > then why not just > > (put 'write-contents-functions 'permanent-local t) > > in your package, and be done with it? The effect of the above is the > same global effect as if we would do that by default in Emacs, right? I was concerned that would break things. (whereas I thought if we made the change in Emacs, we'd have a chance to ensure that it did not.) Probably best not to change things - our current solution seems to work: (defun hyperdrive--hack-write-contents-functions () (cl-pushnew #'hyperdrive--write-contents write-contents-functions)) (put 'hyperdrive--hack-write-contents-functions 'permanent-local-hook t) (define-minor-mode hyperdrive-mode "Minor mode for buffers opened from hyperdrives." (if hyperdrive-mode (progn (cl-pushnew #'hyperdrive--write-contents write-contents-functions) (add-hook 'after-change-major-mode-hook #'hyperdrive--hack-write-contents-functions nil 'local)) (setq-local write-contents-functions (remove #'hyperdrive--write-contents write-contents-functions)) (remove-hook 'after-change-major-mode-hook #'hyperdrive--hack-write-contents-functions 'local)))