[Top][All Lists]

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

bug#24452: 25.1.50; add/delete-file-local-variable does not work as expe

From: Glenn Morris
Subject: bug#24452: 25.1.50; add/delete-file-local-variable does not work as expected
Date: Sat, 17 Sep 2016 12:48:53 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

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.

reply via email to

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