From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props) Date: Thu, 30 Jan 2020 09:34:28 -0500 Message-ID: References: <875zh73dg8.fsf@betli.tmit.bme.hu> <8736c921s6.fsf@mail.linkov.net> <875zh13e5d.fsf@mail.linkov.net> <87imkwfnyv.fsf@mail.linkov.net> <83blqontlu.fsf@gnu.org> <837e1bo499.fsf@gnu.org> <83y2trmitb.fsf@gnu.org> <83tv4embit.fsf@gnu.org> <83imktm3jh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="88983"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39190@debbugs.gnu.org, felician.nemeth@gmail.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 30 15:38:03 2020 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 1ixAxH-000N4f-51 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Jan 2020 15:38:03 +0100 Original-Received: from localhost ([::1]:33510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixAxG-0006xl-4Q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Jan 2020 09:38:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37345) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixAuN-0004Xl-3A for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2020 09:35:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixAuL-0005J9-Si for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2020 09:35:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixAuL-0005Iv-PP for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2020 09:35:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ixAuL-0005qZ-Me for bug-gnu-emacs@gnu.org; Thu, 30 Jan 2020 09:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Jan 2020 14:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39190 X-GNU-PR-Package: emacs Original-Received: via spool by 39190-submit@debbugs.gnu.org id=B39190.158039489222455 (code B ref 39190); Thu, 30 Jan 2020 14:35:01 +0000 Original-Received: (at 39190) by debbugs.gnu.org; 30 Jan 2020 14:34:52 +0000 Original-Received: from localhost ([127.0.0.1]:35131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixAuB-0005q7-VF for submit@debbugs.gnu.org; Thu, 30 Jan 2020 09:34:52 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:65030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ixAuA-0005pv-Hp for 39190@debbugs.gnu.org; Thu, 30 Jan 2020 09:34:50 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2B93280EB9; Thu, 30 Jan 2020 09:34:45 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 60ECD80D8A; Thu, 30 Jan 2020 09:34:36 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1580394876; bh=oz0QPKo+HDsPRlD1snTdqZOq2zNgnBkiZF+69u8xnW0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=VErSxEihY8L4GWOEZuVppcuv2uRIzN1AtkAFgPoi2WHWbFAt5FfMU+Fo6W2L05Moe 3CKkDd9wgDpoRMqbXeaFbJq2UBhRF2d8YAFIqExSjkfovmq4ULHmvSXrOmskEMgg0X TOu6RFsy80YtYttLZnj9GhmNcK6VaDZ966fCnA/hSg8hvX9Wam1nmu4Oa9f2jS6k9E bI+OvwyZCp49UgzLtalJxQmrOovj0mmX/8rNElwEbwheq+mWCKFRXuLg1JIh0XBupN Gi0fq9wJZ/5pgnf0VPvOaU3shQHefGDN2Nj0q/dxbkV1kqv1R2JYDPzihHnZTYDdk7 YRkBz2R9yif4g== Original-Received: from pastel (unknown [45.72.213.248]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C466A1201F4; Thu, 30 Jan 2020 09:34:35 -0500 (EST) In-Reply-To: <83imktm3jh.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 30 Jan 2020 16:17:54 +0200") 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175440 Archived-At: >> > . change set-auto-mode to accept another optional argument, the file >> > name to use to look up the mode >> > >> > . perform look up of auto-mode-alist, then invoke the mode directly >> >> The issue is that we also want to obey dir-locals and both above options >> seem to become more invasive once we try and handle those (the first >> above option is the first one I proposed, since I prefer >> lexically-scoped args over dynamically-scoped vars ;-) > > What is the problem of the first alternative wrt dir-locals? I don't > think I understand that. As I wrote: it's more invasive because you have to pass that extra arg through various functions. >> > Also, setting the pseudo-filename is not guaranteed to turn on the >> > mode according to that file name. Not sure if this matters in these >> > cases. >> Not sure what you mean here. > set-auto-mode looks on other mode-determining stuff, before looking at > the file name. Ah, right. This is a side-issue, yes: in cases like `vc-revision-other-window` it does exactly what we want (i.e. it takes advantage of the buffer's content (file-local vars, magic strings, ...) to guess the mode), but in cases like diff-mode it can be detrimental (since we don't have the full file content in that case, but only a chunk of it, which means that things like file-local vars not only will usually not be found but can even be incorrectly found). I don't think it makes much difference to the current discussion, tho (it's largely orthogonal). >> > And finally, I cannot say that I like this part of the patch: >> > >> > @@ -3459,6 +3460,8 @@ hack-local-variables-confirm >> > (let ((name (cond (dir-name) >> > (buffer-file-name >> > (file-name-nondirectory buffer-file-name)) >> > + (buffer-file-name-for-mode >> > + (file-name-nondirectory buffer-file-name-for-mode)) >> > ((concat "buffer " (buffer-name))))) >> > (offer-save (and (eq enable-local-variables t) >> > unsafe-vars)) >> > >> > If buffer-file-name-for-mode is not really a file name, we shouldn't >> > call file-name-nondirectory on it. >> >> It is supposed to be a file name. It's only that the buffer is not >> supposed to be the buffer corresponding to that file. > > Yes, but having leading directories in it feels... unclean, Why so? The leading directories are crucial for dir-locals support, and they can also be important for auto-mode-alist. >> That code is predicated on `buffer-file-name-for-mode` being >> non-nil, AFAICT, so I think we're OK in this regard. > Non-nil doesn't mean it's a string. If someone sets it to non-nil and not a string, they'll get what they deserve. Same holds already for `buffer-file-name`, so it's not a new problem introduced with this change. Stefan