GNU bug report logs - #39190
28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)

Previous Next

Package: emacs;

Reported by: Felician Nemeth <felician.nemeth <at> gmail.com>

Date: Sun, 19 Jan 2020 11:15:02 UTC

Severity: normal

Found in version 28.0.50

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 39190 <at> debbugs.gnu.org, felician.nemeth <at> gmail.com, juri <at> linkov.net
Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)
Date: Tue, 28 Jan 2020 19:54:58 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: juri <at> linkov.net,  39190 <at> debbugs.gnu.org,  felician.nemeth <at> gmail.com
> Date: Tue, 28 Jan 2020 08:58:32 -0500
> 
> Some packages set `buffer-file-name` in temp-buffers in order to
> activate the major mode of the corresponding file.  As you can see in
> the patch it's used in various circumstances.
> 
> Most of the time this is harmless because it's transient, but it is
> fundamentally a lie (it more or less claims that this temp buffer holds
> the content of that file, even though it's not the case (not only
> because the content doesn't match, but the buffer is usually not fully
> set up as a proper file buffer, it can lead to get-file-buffer returning
> the wrong buffer, ...) and even though it's transient it can cause
> problems because hooks are run during this time (e.g. major mode hooks)
> which may take action under the mistaken assumption that this buffer
> really correspond to the file.
> 
> In the original bug report the problem was that the major mode activated
> `eglot-mode` in this temp buffer.  There are many ways for this to
> create problems.  The immediate error can be avoided in eglot of course,
> but I think the problem goes deeper and we should fix it by making it
> possible to set the major mode without having to lie about
> `buffer-file-name`.

Thanks.

So this is because those modes set buffer-file-name instead of
activating the major mode directly?  And by setting buffer-file-name
they by side effect tell unrelated features that this buffer is
associated with a file?

If so, then I'm not sure I understand the solution.  The offending
modes will have to be modified to use this new variable instead of
buffer-file-name, no?  And if we have to modify them, then why not do
TRT while at that, i.e. call the major mode directly instead of
setting some variable?  Or what am I missing?




This bug report was last modified 5 years and 83 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.