all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 70409@debbugs.gnu.org, monnier@iro.umontreal.ca
Subject: bug#70409: 30.0.50; `latexenc-find-file-coding-system` uses `TeX-master` before we know it's safe
Date: Tue, 16 Apr 2024 14:49:02 +0300	[thread overview]
Message-ID: <86jzkxjzo1.fsf@gnu.org> (raw)
In-Reply-To: <jwvr0f6s29r.fsf-monnier+@gnu.org> (bug-gnu-emacs@gnu.org)

> Cc: monnier@iro.umontreal.ca
> Date: Mon, 15 Apr 2024 18:42:36 -0400
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> If I open a file `foo.tex` with a local variable setting of
> `TeX-master: "paper.tex"` and that `paper.tex` file has a local
> variable setting of `TeX-master: t`, I get the funny behavior that
> Emacs first asks me whether to obey the `TeX-master: t` setting of
> `paper.tex` before asking me whether to obey the `TeX-master:
> "paper.tex"` setting of `foo.tex`, even though it obviously had to use
> the `TeX-master: "paper.tex"` setting in order to decide to open the
> `paper.tex` file (and ask me about its `TeX-master: t`).
> 
> The corresponding backtrace looks as below:
> 
>     Debugger entered--Lisp error: (minibuffer-quit)
>       #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_57>()
>       read-char-from-minibuffer("Please type y, n, ! or i, or C-v/M-v to scroll: " (33 105 121 110 32))
>       read-char-choice("Please type y, n, ! or i, or C-v/M-v to scroll: " (33 105 121 110 32))
>       hack-local-variables-confirm(((TeX-master . t)) ((TeX-master . t)) nil nil)
>       hack-local-variables-filter(((TeX-master . t)) nil)
>       hack-local-variables(no-mode)
>       run-mode-hooks(latex-mode-hook)
>       latex-mode()
>       set-auto-mode-0(latex-mode nil)
>       set-auto-mode()
>       normal-mode(t)
>       after-find-file(nil nil)
>       find-file-noselect-1(#<buffer paper.tex> ".../paper.tex" t nil ".../paper.tex" (3064599 65026))
>       find-file-noselect("paper.tex" t)
>       latexenc-find-file-coding-system((insert-file-contents ".../foo.tex" t nil nil nil))
>       insert-file-contents(".../foo.tex" t)
>       find-file-noselect-1(#<buffer foo.tex> ".../foo.tex" nil nil ".../foo.tex" (3064581 65026))
>       find-file-noselect(".../foo.tex")
>       command-line-1((".../foo.tex"))
>       command-line()
>       normal-top-level()
> 
> showing that the problem is that `latexenc-find-file-coding-system`
> is the function that opens `paper.tex` before the users had a chance to
> confirm that they think this is safe.

Is it correct for latexenc-find-file-coding-system to use
find-file-noselect for this purpose?  Why does it call
insert-file-contents with 2nd arg non-nil, if all it needs is to find
and process the encoding spec there?

Alternatively, we could disable local-variable processing when calling
latexenc-find-file-coding-system.  WDYT?

> I suggest the patch below which makes `latexenc-find-file-coding-system`
> use `safe-local-variable-p` before using a file-local setting, and also
> adds corresponding `safe-local-variable` settings for `TeX-master` and
> `tex-main-file`.

Is it really guaranteed that safe local variables will never cause
similar problems?  That they are safe doesn't mean they must be
processed at this point.





  parent reply	other threads:[~2024-04-16 11:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 22:42 bug#70409: 30.0.50; `latexenc-find-file-coding-system` uses `TeX-master` before we know it's safe Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 10:19 ` Arash Esbati
2024-04-16 12:54   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 20:46     ` Arash Esbati
2024-04-16 11:49 ` Eli Zaretskii [this message]
2024-04-16 12:53   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 13:35     ` Eli Zaretskii
2024-04-17 17:52       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86jzkxjzo1.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=70409@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.