From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <86jzkxjzo1.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15423"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70409@debbugs.gnu.org, monnier@iro.umontreal.ca To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 16 13:50:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rwhKD-0003ig-8A for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Apr 2024 13:50:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwhJz-0005wh-C7; Tue, 16 Apr 2024 07:49:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwhJy-0005wO-1I for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 07:49:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwhJx-0002Iy-GQ for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 07:49:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwhK9-0002bm-Br for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2024 07:50:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Apr 2024 11:50:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70409 X-GNU-PR-Package: emacs Original-Received: via spool by 70409-submit@debbugs.gnu.org id=B70409.17132681679634 (code B ref 70409); Tue, 16 Apr 2024 11:50:05 +0000 Original-Received: (at 70409) by debbugs.gnu.org; 16 Apr 2024 11:49:27 +0000 Original-Received: from localhost ([127.0.0.1]:43438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwhJV-0002V6-Gn for submit@debbugs.gnu.org; Tue, 16 Apr 2024 07:49:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwhJT-0002Tp-3O for 70409@debbugs.gnu.org; Tue, 16 Apr 2024 07:49:24 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwhJA-0002FR-UA; Tue, 16 Apr 2024 07:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=n+PBZ9bai918Dt29TwVysA11hZle3hsr/Udq+5fgdzE=; b=B+J2jF5C3JyA Y+3dXV0M0tzYU3cL0yRoLlIUMZeioajNncXqeGfj5FJrHsxWAo/XOq2kdqhEiRYGblZFthVJHxs7A XWuA5wzwafW+eVinulExgOcm8Yic4l+yL/2s4vFx6WGuZpdK0r0A/ike1LozxytwkQPUE3UYCKjHt 8P2F7b4FUTmpf8P3ZaELHhdDln9MDJU4dRwST6Lb4533+6kf+3t9lNlRrCoA1XQne7Yl95A3/sOEO v4u9gXD5i4bVjZ5AvwSWlrVmAfh7ouen1mFBzK4UDVeOEysHyfmlVYTGSUtzp8XoRt3MPOFMAZ2ae WCH76AfCZW1UY1Japb/bpg==; In-Reply-To: (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283416 Archived-At: > 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" > > 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) > #() > 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(# ".../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(# ".../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.