emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Should write-contents-functions be permanent-local?


From: Joseph Turner
Subject: Should write-contents-functions be permanent-local?
Date: Mon, 14 Aug 2023 23:35:44 -0700

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]