GNU bug report logs - #24452
25.1.50; add/delete-file-local-variable does not work as expected

Previous Next

Package: emacs;

Reported by: John Kitchin <jkitchin <at> andrew.cmu.edu>

Date: Fri, 16 Sep 2016 21:17:02 UTC

Severity: minor

Found in version 25.1.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


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

From: Glenn Morris <rgm <at> gnu.org>
To: John Kitchin <jkitchin <at> andrew.cmu.edu>
Cc: 24452 <at> debbugs.gnu.org
Subject: Re: bug#24452: 25.1.50;
 add/delete-file-local-variable does not work as expected
Date: Sat, 17 Sep 2016 12:48:53 -0400
John Kitchin wrote:

> In the add-file-local-variable and related functions, the local
> variables are found with code like:
>
> (search-forward "Local Variables:" nil t)

It uses the same logic as the function that actually applies file local
variables (hack-local-variables).

> This is too open I think, and leads to errors in files that contain that
> phrase in places near the end of the file that aren't related to Local
> Variables. For example, in code that is searching for that string, or in
> text files that talk about Local Variables.

Then you would already have had a more obvious issue when visiting the
file in the first place. The format of Local Variables is too
long-established to be changed now, and there's no point
add-file-local-variable being stricter than hack-local-variables.

The standard solution is eg to add a ^L, or obfuscate the "Local
Variables", so it's not picked up.

> I think the search should be done with a regexp that considers the start
> of a line and comment-start:
>
> (format "^%s+ Local Variables:" comment-start)

Some files have no comment syntax. In some that do, there's no need for
the LV section to use it (eg it could be after the "end{document}" in a
latex file, or inside #if 0 in C). And then there's the case where
comment-start is itself specified in the LV section.




This bug report was last modified 4 years and 336 days ago.

Previous Next


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