Subject: Re: bug#71080: 30.0.50; UTF-8 used unconditionally when saving GPG file

From: Stefan Monnier <[email-masked]>
Date: Thu, 23 May 2024 11:44:02 -0400

> AFAICT, this is due to an (unsolicited? at least the log message is
> silent about this particular part) change as part of commit
> e78c15acf679, 4 years ago.  Reverting that part makes your recipe work
> as expected.  Please try the patch below:

Ha!  Thanks for tracking it down!
It does fix the problem for me, and it makes a lot of sense, indeed.
Jonas, do you remember what that hunk was about?

        Stefan

> diff --git a/lisp/epa-file.el b/lisp/epa-file.el
> index a4942e7..90cc91e 100644
> --- a/lisp/epa-file.el
> +++ b/lisp/epa-file.el
> @@ -267,7 +267,14 @@ epa-file-write-region
>    (setq file (expand-file-name file))
>    (let* ((coding-system (or coding-system-for-write
>  			    (if (fboundp 'select-safe-coding-system)
> -			        (let ((buffer-file-name file))
> +                                ;; This is needed because
> +                                ;; `auto-coding-alist' has
> +                                ;; `no-conversion' for *.gpg files,
> +                                ;; which would otherwise force
> +                                ;; `select-safe-coding-system' return
> +                                ;; `no-conversion'.
> +			        (let ((buffer-file-name
> +                                       (file-name-sans-extension file)))
>  				  (select-safe-coding-system
>  				   (point-min) (point-max)))
>  			      buffer-file-coding-system)))