bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Eli Zaretskii
Subject: bug#68692: 29.1; File-local variable storage for strings with newlines
Date: Wed, 24 Jan 2024 19:31:54 +0200

> From: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
> Date: Wed, 24 Jan 2024 09:21:47 -0800
> 
> 
> Storing file-local variables whose values are strings that include
> newlines triggers an error when the file is opened.

That's because you violated the supported format.

> The buffer test.txt now looks like this:
> 
> --8<---------------cut here---------------start------------->8---
> Some text
> 
> ;; Local Variables:
> ;; testvar: "Data on
> two lines"
> ;; End:
> --8<---------------cut here---------------end--------------->8---
> 
> Saving and killing test.txt and repopening it causes the error:
> 
> --8<---------------cut here---------------start------------->8---
> File mode specification error: (user-error Local variables entry is missing 
> the prefix)
> --8<---------------cut here---------------end--------------->8---
> 
> Turning on toggle-debug-on-error does not produce a backtrace.
> 
> Is it not possible to store strings with newlines as the values of
> file-local variables? The elisp manual makes no mention of this
> limitation in the file-local vars section -- perhaps I missed something?

I think you missed this part in the Emacs user manual:

     A local variables list starts with a line containing the string
  ‘Local Variables:’, and ends with a line containing the string ‘End:’.
  In between come the variable names and values, one set per line, like
  this:

       /* Local Variables:  */
       /* mode: c           */
       /* comment-column: 0 */
       /* End:              */

  In this example, each line starts with the prefix ‘/*’ and ends with the
  suffix ‘*/’.

Note the last sentence.

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.





reply via email to

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