Subject: bug#70409: 30.0.50; `latexenc-find-file-coding-system` uses `TeX-master` before we know it's safe

From: Arash Esbati <[email-masked]>
Date: Tue, 16 Apr 2024 12:19:21 +0200

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> writes:

> diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
> index 02ee1242c72..e7b1522751f 100644
> --- a/lisp/textmodes/tex-mode.el
> +++ b/lisp/textmodes/tex-mode.el
> @@ -89,6 +89,7 @@ tex-main-file
>  if the variable is non-nil."
>    :type '(choice (const :tag "None" nil)
>                   file)
> +  :safe #'stringp
>    :group 'tex-file)
>  
>  ;;;###autoload
> @@ -2213,6 +2214,10 @@ tex-guess-main-file
>  			  header-re (+ (point) 10000) t))))
>  	    (throw 'found (expand-file-name buffer-file-name))))))))
>  
> +(unless (get 'TeX-master 'safe-local-variable) ;Don't override AUCTeX's setting.
> +  (put 'TeX-master 'safe-local-variable
> +       (lambda (x) (or (booleanp x) (stringp x)))))
> +

Is there a reason why leave out the values `dwim' and `shared'?  tex.el
defines `TeX-master' like this:

  (defcustom TeX-master t
    :safe (lambda (x)
            (or (stringp x)
                (member x (quote (t nil shared dwim))))))

Best, Arash