From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Gustavo Barros Newsgroups: gmane.emacs.bugs Subject: bug#36830: 26.2; find-file-visit-truename is not honored as file local variable Date: Fri, 23 Aug 2019 18:38:40 -0300 Message-ID: <87y2zj1s0v.fsf@gmail.com> References: <87d0hufamm.fsf@gmail.com> <87ftlsfp3v.fsf@gnus.org> <87h8688233.fsf@gmail.com> <874l27btck.fsf@gnus.org> <83d0gvk5m0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="89476"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.2.0; emacs 26.2 Cc: Lars Ingebrigtsen , 36830@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 23 23:39:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1HHA-000NBI-1B for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 23:39:16 +0200 Original-Received: from localhost ([::1]:34328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1HH8-0003p3-2g for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Aug 2019 17:39:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36389) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1HGx-0003o6-9P for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 17:39:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1HGw-0000Se-84 for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 17:39:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1HGw-0000SZ-5I for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 17:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1HGv-0004C4-Ry for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2019 17:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gustavo Barros Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Aug 2019 21:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36830 X-GNU-PR-Package: emacs Original-Received: via spool by 36830-submit@debbugs.gnu.org id=B36830.156659633316106 (code B ref 36830); Fri, 23 Aug 2019 21:39:01 +0000 Original-Received: (at 36830) by debbugs.gnu.org; 23 Aug 2019 21:38:53 +0000 Original-Received: from localhost ([127.0.0.1]:41360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1HGm-0004Bh-SI for submit@debbugs.gnu.org; Fri, 23 Aug 2019 17:38:53 -0400 Original-Received: from mail-qt1-f193.google.com ([209.85.160.193]:45013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1HGk-0004BM-Js for 36830@debbugs.gnu.org; Fri, 23 Aug 2019 17:38:50 -0400 Original-Received: by mail-qt1-f193.google.com with SMTP id 44so12591300qtg.11 for <36830@debbugs.gnu.org>; Fri, 23 Aug 2019 14:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=HFnfli43wglQwn7laOd9NpQQRz5NQhWAbPKIiqiHgFE=; b=LB3iM76H0fyyPBs0nUDJvbHaegoNfvRa40tJ7Strzb6s1sO9EdRO3xNfIBk/JlM8qV wffOOn3UgPSYmPk2BaYx9y2ACUb9kGhjXArZ49N+uq07S6/1XSUpjtTexTvgsaFgY/WI 8HweZWdZggLl8dF3vRwpIvLsxI9OhPlawkdq0tToi5puh5bzwD3vw96kKwoNHpUdwJfz xEtyhjpHGwApSNKZt46YjIgozRNA5dW8kvoykJZbh8CHP82NFAAv6Mg+SwR6SPxAAj1w 2K/aFu1XhAAyMphBI8cfDnGGjoaDynIuILlxHjdl8mnNTXLyhS3k75cl8JXnB50+EkE4 UzLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=HFnfli43wglQwn7laOd9NpQQRz5NQhWAbPKIiqiHgFE=; b=aqjpKqQhJ5MZNvoNRaFCIDhhfFp3KsE+Zp9pDMnbMV93Y9nLdkUOTnlTnbKZ1No5y5 mO58EnvzPw386nmujKYEokFoG8bELz6R94aZO77IhL+muTDrJu9JY6ugoeuKl6ZwECDK 8QRdpRSnV4E7IVAkduetMYK2OJLRkaxquBO5hH77YnfBZnyLO30qBZFXPYPUEGj+wMSJ myoRBATqGnBWjA34PnHHlRnWwT3V6Ox0jlol7D2HKuo9zlIa2FWbzZOcjfmtGZGaEvmg 4xdyX3bb2oUqMmm25mxTcXpR2QUPhXyDO6JFADrPR8tVqLg8wSYIj9Zj+ok6YxTtNkJo 0gwQ== X-Gm-Message-State: APjAAAUR14eXQxGYgHx5am+xD+xHfV8eT6UT03MxUYuAfShjk8OcH9Sb sbqx6lqZsZ1ZqHxH654Tlak9Ax/NfG8= X-Google-Smtp-Source: APXvYqxiN8j4gpaTd6O77cMkvSUI6i2103x+VTUoMgTxizvqpKtKgQMmu89290Fm5rw8lKfLx5o9jg== X-Received: by 2002:ac8:4691:: with SMTP id g17mr6889012qto.104.1566596324795; Fri, 23 Aug 2019 14:38:44 -0700 (PDT) Original-Received: from gusbrs-laptop (ip-32-2-52-196.nyc.us.northamericancoax.com. [196.52.2.32]) by smtp.gmail.com with ESMTPSA id o27sm1996781qkm.37.2019.08.23.14.38.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Aug 2019 14:38:43 -0700 (PDT) In-reply-to: <83d0gvk5m0.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:165730 Archived-At: Hi Eli, Hi Lars, On Fri, Aug 23 2019, Eli Zaretskii wrote: >> From: Lars Ingebrigtsen >> Date: Fri, 23 Aug 2019 20:59:55 +0200 >> Cc: 36830@debbugs.gnu.org >>=20 >> (if find-file-visit-truename >> (setq buffer-file-name (expand-file-name=20 >> buffer-file-truename))) >>=20 >> [...] >>=20 >> (after-find-file error (not nowarn))) >>=20 >> `after-find-file' is the function that interprets the file local >> variables, so we're setting the buffer file name before we've set=20 >> that >> variable locally. >>=20 >> One option would be to re-check the variable after `after-find-file', >> but that seems a bit hacky. >>=20 >> Any opinions? > > I don't think this variable was designed to be set from file-local > variables block. Visiting a file and naming its buffer are two racy > actions, and where there's a race there will be chicken-and-egg type > of problems. > >> --- a/lisp/files.el >> +++ b/lisp/files.el >> @@ -2413,7 +2413,11 @@ find-file-noselect-1 >> (setq buffer-file-coding-system 'no-conversion) >> (set-buffer-major-mode buf) >> (setq-local find-file-literally t)) >> - (after-find-file error (not nowarn))) >> + (after-find-file error (not nowarn)) >> + ;; In case `find-file-visit-truename' is set as a file-local >> + ;; variable, recompute the buffer file name. >> + (when find-file-visit-truename >> + (setq buffer-file-name (expand-file-name=20 >> buffer-file-truename)))) > > I expect such renaming to cause future bugs, FWIW. Or maybe not, but > this is beyond hacky, IMO. > > Maybe we should just document that this variable cannot be file-local. I admittedly reported this from a user perspective, and do not fully=20 grasp what is going on in this case. But I think I can add something=20 here if I point that `vc-follow-symlinks` does work as a file local=20 variable. Maybe I=E2=80=99m wrong in comparing these two variables, but if= not,=20 this could both provide some approach that works for this purpose, and=20 could perhaps reduce the concerns raised by Eli. I may also add that I would hardly set `find-file-visit-truename`=20 globally, but I would find it useful locally (I don=E2=80=99t claim to be a= ny=20 reference in this respect though). Furthermore, if the race mentioned=20 by Eli does prove to be insurmountable, and if there is any difference=20 between setting this as "file-local" or as "dir-local", the latter could=20 prove useful even if the former could not be maintained. (I don=E2=80=99t = know=20 if dir-local variables are set before the file is actually visited, but=20 that is what I have in mind in mentioning this. If that is the case,=20 the race might be thus circumvented.) Best, Gustavo.