unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Cc: 68692@debbugs.gnu.org
Subject: bug#68692: 29.1; File-local variable storage for strings with newlines
Date: Wed, 24 Jan 2024 19:31:54 +0200	[thread overview]
Message-ID: <86y1ced4dx.fsf@gnu.org> (raw)
In-Reply-To: <87il3ir6j8.fsf@gmail.com> (message from Karthik Chikmagalur on Wed, 24 Jan 2024 09:21:47 -0800)

> 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	other threads:[~2024-01-24 17:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 17:21 bug#68692: 29.1; File-local variable storage for strings with newlines Karthik Chikmagalur
2024-01-24 17:31 ` Eli Zaretskii [this message]
     [not found]   ` <877cjw3hwc.fsf@gmail.com>
2024-01-26  8:03     ` Eli Zaretskii
2024-01-26 19:49       ` Karthik Chikmagalur
2024-01-26 20:16         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86y1ced4dx.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=68692@debbugs.gnu.org \
    --cc=karthikchikmagalur@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).