Subject: Re: bug#68692: 29.1; File-local variable storage for strings with newlines

From: Eli Zaretskii <[email-masked]>
Date: Fri, 26 Jan 2024 10:03:34 +0200

[Please use Reply All when replying, to have the bug tracker CC'ed.]

> From: Karthik Chikmagalur <[email-masked]>
> Date: Thu, 25 Jan 2024 19:14:43 -0800
> 
> Hello Eli,
> 
> Please close this bug, I read the local variables section of the elisp
> manual but missed the Emacs one.

I'm therefore closing this bug.

> However, I have a question now.
> 
> > The manual says a little after the above:
> >
> >                                                 If you want to split a
> >   long string value across multiple lines of the file, you can use
> >   backslash-newline, which is ignored in Lisp string constants; you should
> >   put the prefix and suffix on each line, even lines that start or end
> >   within the string, as they will be stripped off when processing the
> >   list.  Here is an example:
> >
> >        # Local Variables:
> >        # compile-command: "cc foo.c -Dfoo=bar -Dhack=whatever \
> >        #   -Dmumble=blaah"
> >        # End:
> >
> > Which I believe is what you are looking for.
> >
> > I don't think there's a bug in Emacs here.
> 
> Is there a programmatic way (using elisp) to insert a local variable
> value that is a string that extends over multiple lines, as in my
> original example?  I can write a helper function to replace newlines
> with backslash-newlines, but determining the right suffix to add at the
> end of each line is tricky.

We have add-file-local-variable and modify-file-local-variable -- did
you try any of them?  If they don't handle this case, we need to fix
them so they do.

> I am addressing this right now by let-binding `print-escape-newlines' to
> t around calls to `add-file-local-variable', but perhaps there is a
> better way.