Subject: Re: bug#62260: 30.0.50; [PATCH] Restrict auto-save file mode

From: Michael Albinus <[email-masked]>
Date: Mon, 20 Mar 2023 12:41:34 +0100

Manuel Giraud <[email-masked]> writes:

> Hi Michael,

Hi Manuel,

> Thanks for your inputs.  I have tried with
> 'auto-save-file-name-transforms' like this:
>
> (add-to-list 'auto-save-file-name-transforms
>     '("\\`/\\(?:doas\\|ksu\\|su\\(?:do\\)?\\):.*\\'" "/dev/null" nil))
>
> But now, auto-save tries to create "/dev/#null#".  How can I fix it to
> "/dev/null"?

auto-save-file-name-transforms does not know the meaning of "/dev/null",
it handles it like an ordinary file name. The following code snippet
shall do what you want instead (untested):

--8<---------------cut here---------------start------------->8---
(defun my-find-file-hook ()
  (and buffer-file-name
       (member (file-remote-p buffer-file-name 'method) '("doas" "ksu" "su" "sudo"))
       (auto-save-mode 0)))
(add-hook 'find-file-hook 'my-find-file-hook)
--8<---------------cut here---------------end--------------->8---

@Eli: We have already remote-file-name-inhibit-auto-save-visited. Shall
we define another user option remote-file-name-inhibit-auto-save, which
could be used similarly?

Best regards, Michael.