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

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

Re: longish Local Variables in Files


From: Kevin Rodgers
Subject: Re: longish Local Variables in Files
Date: Mon, 30 Aug 2004 12:21:43 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Dan Jacobson wrote:
> K> Then you are out of luck: file local variables must be specified on a
> K> single line.
>
> Make sure this is documented. Wait, I demonstrated that it could be
> done on two lines.

OK, I see now why that works: hack-local-variables reads the value as
a Lisp expression, not as a line.  So Lisp objects whose readable
syntax can span multiple lines (strings, lists, and vectors -- are
there any others?) can be specified with embedded newlines as values
for file local variables.

The key thing to remember is that the newlines, local variable prefix,
and local variable suffix are not ignored or discarded by the (read
(current-buffer)) function call when the occur within "...".  So in
your compile-command example, they are all present in the variable's
value.

Within a list or vector value, though, the prefix and suffix may be
significant.

> K> What's wrong with having a really long compile-command
> K> line in your script?
>
> I don't want lines to wrap etc. on my terminal or printer. Call me old
> fashioned.

I agree readability is a good thing, I just wanted to make sure it
wasn't a functional requirement.

> rms> # compile-command: "invoke-rc.d chrony restart && sleep 2`\
> rms> #` && grep chrony /var/log/syslog|tail -19"
>
> Indeed that works, no need for /bin/sh's ":", and one can even remove
> the backslash.

That's because the backslash occurs within "..." and is interpreted
the same as within any string: the following newline is ignored.

>  One can go on and on:
>
> # Local Variables:
> # compile-command: "p=$PWD && cd /tmp && procmail -m LOGABSTRACT=all `
> #` VERBOSE=on $p/.procmailrc.local.post </dev/null `
> #` bla bla"
> # End:

We can't recommend the use of backquote-newline-backquote in a shell
command.  RMS' example above (backquote-backslash-newline-pound
sign-backquote) is even worse.

> OK, remember to document this `#` hack.  As this always is sent to sh,
> this should always work.  And document simpler ways for those who
> don't need to hide local variables in comments, e.g.,
>
> rms> # compile-command: "invoke-rc.d chrony restart && sleep 2 \
> rms> && grep chrony /var/log/syslog|tail -19"

The # hack is unnecessary and potentially confusing.  RMS' example
clearly demonstrates the right way to do this.  I think it might be
worthwhile explaining that string etc. values for file local variables
may span multiple lines and that the local variable prefix can
interfere with the intended value; but that should be explained in the
Emacs Lisp manual, not the Emacs manual.

--
Kevin Rodgers





reply via email to

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