Subject: Re: bug#48030: 28.0.50; syntax evaluation in strings

From: Gregory Heytings <[email-masked]>
Date: Mon, 26 Apr 2021 09:20:09 +0000

> 
> defining a function:
> (defun xxx-insert()
> "anything"
> (interactive)
> (insert "# Local Variables:\n")
> (insert "# mode: org\n")
> (insert "# End:\n")
> )

> will cause Emacs to disregard the Emacs-lisp-mode after re-opening the 
> file, hence no syntax evaluation anymore Changing (insert "# Local 
> Variables:\n") to (insert "# Local Bariables:\n") will 'solve' the 
> problem.
>

Thanks for your bug report.  As far as I can see, this is not a bug, when 
enable-local-variables is t (the default), Emacs searches for the the 
string "Local Variables" string near the end of the buffer, and interprets 
what follows as file-local variable settings.

This is not what you want if "Local Variables" is inside a literal string, 
but detecting that specific case would be cumbersome I think.  I would 
suggest that you replace (insert "# Local Variables:\n") by (insert "# 
Local " "Variables:\n"), with two additional quotation marks between Local 
and Variables.