bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-


From: Eli Zaretskii
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@iro.umontreal.ca>
> Cc: juri@linkov.net,  39190@debbugs.gnu.org,  felician.nemeth@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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]