[Top][All Lists]

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

Re: Local variables list

From: Pascal J. Bourguignon
Subject: Re: Local variables list
Date: Thu, 02 Oct 2014 14:25:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Dieter Britz <> writes:

> For some files, when I start emacs, I get a warning
> something like "The local variables list for <file>
> contains values that may not be safe..." (I was not able
> to copy/paste so am citing from memory). I then answer
> "yes" and I get in, but what does this mean? What can I
> do about it?

The file local variables are defined either on one of the first two
lines, between "-*-" and "-*-", or in the last 512 bytes, between
"\nLocal Variable:\n" and "\nEnd:\n".

Some local variables are "safe" and/or have "safe" values. For example:

     ;; -*- mode:lisp; coding:utf-8; -*- 

on the first line define two variables, mode and coding to be set to
lisp and utf-8 which are all safe.

Some other local variables or values are not safe.  For example:

    Local Variable:
    post-command-hook: ((lambda () (do-some-virus-propagation)))

wouldn't be safe, and neither would:

    Local Variable:
    post-command-hook: ((lambda () (shell "rm -rf /")))

It is to protect you from such files, that emacs warns you when it
detect something strange in file local variables.  You should not answer
yes blindly, you should check those variables, and convince yourself
that they are safe, before answering yes.

The "*Local Variables*"  buffer gives you the list of local variables,
indicating those that are unsafe:

    -----(*Local Variables*)------------------------------------------------
    The local variables list in test-file
    contains varibles that are risk (**).

    Do you want to apply it?  You can type
    y  -- to apply the local variable list.
    n  -- to ignore the local variables list.

        mode : text
     ** post-command-hook : ((lambda nil (message "hi")))

Here you can see that post-command-hook looks safe (but it will erase
the current post-command-hook, so you might still want to answer n (and
then remove it from the file).

__Pascal Bourguignon__       
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

reply via email to

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