GNU bug report logs - #44698
27.1; dir-locals.el stay on file-local-variables-alist when using vc-mode

Previous Next

Package: emacs;

Reported by: Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>

Date: Mon, 16 Nov 2020 20:31:02 UTC

Severity: normal

Found in version 27.1

Done: Sean Whitton <spwhitton <at> spwhitton.name>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44698 in the body.
You can then email your comments to 44698 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Mon, 16 Nov 2020 20:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 16 Nov 2020 20:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>
Subject: 27.1; dir-locals.el stay on file-local-variables-alist when using
 vc-mode
Date: Mon, 16 Nov 2020 21:30:43 +0100
[Message part 1 (text/plain, inline)]
Hi,

While using vc-mode, the dir-locals.el variables under 'nil' mode are
accumulated on file-local-variables-alist and they still apply after
exiting the scope of the file.  The attached script can be used to
reproduce it (Emacs 27.1, on GNU Guix
f6e031ab36fd99ad3536caabfdaefcc2b5f606a1).

It generates a temporary folder with two example git repositories, an
offending dir-locals.el[1], launches an emacs with -Q and the shows
the steps to follow:

1. Open p1/file and accept the .dir-locals.el variables.
2. Call vc-print-log
3. Check the file-local-variables-alist
4. Open p2/file (this one doesn't have .dir-locals.el).
5. Call vc-print-log again, the message is shown again.

Best regards,
Miguel

[1] It contains: ((nil . ((eval (message "Eval called")))))

[reproducer.sh (application/x-sh, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Tue, 07 Jun 2022 11:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>, 44698 <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Tue, 07 Jun 2022 13:05:52 +0200
Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com> writes:

> While using vc-mode, the dir-locals.el variables under 'nil' mode are
> accumulated on file-local-variables-alist and they still apply after
> exiting the scope of the file.  The attached script can be used to
> reproduce it (Emacs 27.1, on GNU Guix
> f6e031ab36fd99ad3536caabfdaefcc2b5f606a1).
>
> It generates a temporary folder with two example git repositories, an
> offending dir-locals.el[1], launches an emacs with -Q and the shows
> the steps to follow:
>
> 1. Open p1/file and accept the .dir-locals.el variables.
> 2. Call vc-print-log
> 3. Check the file-local-variables-alist
> 4. Open p2/file (this one doesn't have .dir-locals.el).
> 5. Call vc-print-log again, the message is shown again.
>
> Best regards,
> Miguel
>
> [1] It contains: ((nil . ((eval (message "Eval called")))))

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I tried to reproduce this with both Emacs 27.1 and Emacs 29, and I was
unable to -- in step 5), there's no message, and p2/file does not have
anything in file-local-variables-alist.

Are you still seeing this problem in recent Emacs versions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 07 Jun 2022 11:07:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Tue, 05 Jul 2022 11:38:01 GMT) Full text and rfc822 format available.

Message #13 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>, 44698 <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Tue, 05 Jul 2022 13:36:59 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I tried to reproduce this with both Emacs 27.1 and Emacs 29, and I was
> unable to -- in step 5), there's no message, and p2/file does not have
> anything in file-local-variables-alist.
>
> Are you still seeing this problem in recent Emacs versions?

More information was requested, but no response was given within a
month, so I'm closing this bug report.  If the problem still exists,
please respond to this email and we'll reopen the bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 44698 <at> debbugs.gnu.org and Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 05 Jul 2022 11:38:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Mon, 11 Jul 2022 15:23:01 GMT) Full text and rfc822 format available.

Message #18 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>,
 GNU Debbugs <control <at> debbugs.gnu.org>,
 Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>,
 44698 <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Mon, 11 Jul 2022 11:22:33 -0400
unarchive 44698
thanks

Hi,

Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com> writes:
>
>> While using vc-mode, the dir-locals.el variables under 'nil' mode are
>> accumulated on file-local-variables-alist and they still apply after
>> exiting the scope of the file.  The attached script can be used to
>> reproduce it (Emacs 27.1, on GNU Guix
>> f6e031ab36fd99ad3536caabfdaefcc2b5f606a1).
>>
>> It generates a temporary folder with two example git repositories, an
>> offending dir-locals.el[1], launches an emacs with -Q and the shows
>> the steps to follow:
>>
>> 1. Open p1/file and accept the .dir-locals.el variables.
>> 2. Call vc-print-log
>> 3. Check the file-local-variables-alist
>> 4. Open p2/file (this one doesn't have .dir-locals.el).
>> 5. Call vc-print-log again, the message is shown again.
>>
>> Best regards,
>> Miguel
>>
>> [1] It contains: ((nil . ((eval (message "Eval called")))))
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> I tried to reproduce this with both Emacs 27.1 and Emacs 29, and I was
> unable to -- in step 5), there's no message, and p2/file does not have
> anything in file-local-variables-alist.
>
> Are you still seeing this problem in recent Emacs versions?

I tried the reproducer again on my side, and I can reproduce the issue
(that the file-local-variables-alist is leaked from p1/file to p2/file).

I'm thus reopening the ticket.

I used the current 'emacs' package from Guix to test, which is at
version 28.1.

Thanks!

Maxim




Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 Jul 2022 12:30:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Tue, 12 Jul 2022 12:32:01 GMT) Full text and rfc822 format available.

Message #23 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>,
 Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>,
 44698 <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Tue, 12 Jul 2022 14:31:25 +0200
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> I tried the reproducer again on my side, and I can reproduce the issue
> (that the file-local-variables-alist is leaked from p1/file to p2/file).
>
> I'm thus reopening the ticket.
>
> I used the current 'emacs' package from Guix to test, which is at
> version 28.1.

Thanks -- it looks like you just unarchived the bug report, not reopened
it, so I've now done the latter.  (The debbugs interface is pretty
confusing.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 09 Aug 2022 15:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Sat, 08 Mar 2025 03:31:02 GMT) Full text and rfc822 format available.

Message #28 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: emacs-devel <at> gnu.org
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>,
 Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>,
 44698 <at> debbugs.gnu.org
Subject: Re: 27.1; dir-locals.el stay on file-local-variables-alist when
 using vc-mode
Date: Sat, 08 Mar 2025 11:30:20 +0800
Hello,

On Mon 16 Nov 2020 at 09:30pm +01, Miguel Ángel Arruga Vivas wrote:

> While using vc-mode, the dir-locals.el variables under 'nil' mode are
> accumulated on file-local-variables-alist and they still apply after
> exiting the scope of the file.  The attached script can be used to
> reproduce it (Emacs 27.1, on GNU Guix
> f6e031ab36fd99ad3536caabfdaefcc2b5f606a1).
>
> It generates a temporary folder with two example git repositories, an
> offending dir-locals.el[1], launches an emacs with -Q and the shows
> the steps to follow:
>
> 1. Open p1/file and accept the .dir-locals.el variables.
> 2. Call vc-print-log
> 3. Check the file-local-variables-alist
> 4. Open p2/file (this one doesn't have .dir-locals.el).
> 5. Call vc-print-log again, the message is shown again.

The problem here is that file-local-variables-alist is marked
permanent-local, and vc-log-internal-common re-uses the *vc-change-log*
buffer, so the variable sticks around.  Clearly that is wrong.

What's the idiomatic thing to do in this sort of situation?

Should vc-log-internal-common kill the buffer and re-create it?

That's the change I'll make if no-one has a better idea.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Sat, 08 Mar 2025 08:09:02 GMT) Full text and rfc822 format available.

Message #31 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Sean Whitton <spwhitton <at> spwhitton.name>, emacs-devel <at> gnu.org
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>,
 Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>,
 44698 <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on file-local-variables-alist
 when using vc-mode
Date: Sat, 8 Mar 2025 08:07:57 +0000
Sean Whitton <spwhitton <at> spwhitton.name> writes:

> Hello,
>
> On Mon 16 Nov 2020 at 09:30pm +01, Miguel Ángel Arruga Vivas wrote:
>
>> While using vc-mode, the dir-locals.el variables under 'nil' mode are
>> accumulated on file-local-variables-alist and they still apply after
>> exiting the scope of the file.  The attached script can be used to
>> reproduce it (Emacs 27.1, on GNU Guix
>> f6e031ab36fd99ad3536caabfdaefcc2b5f606a1).
>>
>> It generates a temporary folder with two example git repositories, an
>> offending dir-locals.el[1], launches an emacs with -Q and the shows
>> the steps to follow:
>>
>> 1. Open p1/file and accept the .dir-locals.el variables.
>> 2. Call vc-print-log
>> 3. Check the file-local-variables-alist
>> 4. Open p2/file (this one doesn't have .dir-locals.el).
>> 5. Call vc-print-log again, the message is shown again.
>
> The problem here is that file-local-variables-alist is marked
> permanent-local, and vc-log-internal-common re-uses the *vc-change-log*
> buffer, so the variable sticks around.  Clearly that is wrong.
>
> What's the idiomatic thing to do in this sort of situation?
>
> Should vc-log-internal-common kill the buffer and re-create it?
>
> That's the change I'll make if no-one has a better idea.

I think you can use `kill-all-local-variables` for this:

    (kill-all-local-variables 'kill-permanent)




Reply sent to Sean Whitton <spwhitton <at> spwhitton.name>:
You have taken responsibility. (Sat, 08 Mar 2025 09:12:01 GMT) Full text and rfc822 format available.

Notification sent to Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>:
bug acknowledged by developer. (Sat, 08 Mar 2025 09:12:01 GMT) Full text and rfc822 format available.

Message #36 received at 44698-done <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Christopher Lemmer Webber <cwebber <at> dustycloud.org>,
 Miguel Ángel Arruga Vivas <rosen644835 <at> gmail.com>,
 44698-done <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Sat, 08 Mar 2025 17:11:26 +0800
Hello,

On Sat 08 Mar 2025 at 08:07am GMT, Stefan Kangas wrote:

> I think you can use `kill-all-local-variables` for this:
>
>     (kill-all-local-variables 'kill-permanent)

Oh, thanks, I never knew it could take an argument.
I think the thing to do here then is add that to vc-log-internal-common.
We're a long way from releasing Emacs 31 so if this does break something
else, we'll find out.

Installed the change and closing the bug.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44698; Package emacs. (Mon, 10 Mar 2025 09:19:02 GMT) Full text and rfc822 format available.

Message #39 received at 44698 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: 44698 <at> debbugs.gnu.org, 59457-done <at> debbugs.gnu.org
Subject: Re: bug#44698: 27.1; dir-locals.el stay on
 file-local-variables-alist when using vc-mode
Date: Mon, 10 Mar 2025 17:18:11 +0800
Hello,

On Sat 08 Mar 2025 at 05:11pm +08, Sean Whitton wrote:

> Hello,
>
> On Sat 08 Mar 2025 at 08:07am GMT, Stefan Kangas wrote:
>
>> I think you can use `kill-all-local-variables` for this:
>>
>>     (kill-all-local-variables 'kill-permanent)
>
> Oh, thanks, I never knew it could take an argument.
> I think the thing to do here then is add that to vc-log-internal-common.
> We're a long way from releasing Emacs 31 so if this does break something
> else, we'll find out.
>
> Installed the change and closing the bug.

While preparing a fix for #59457 I discovered that invoking vc-print-log
already makes a call to kill-all-local-variables, in vc-setup-buffer.
So calling it in vc-log-internal-common too isn't right.

In other words, the place to fix this is in vc-setup-buffer, which
already has special handling for default-directory.

I've replaced the fix with one in vc-setup-buffer, and also fixed #59457.

-- 
Sean Whitton




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 07 Apr 2025 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 33 days ago.

Previous Next


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