all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Local variables list
@ 2014-10-02 12:01 Dieter Britz
  2014-10-02 12:25 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 5+ messages in thread
From: Dieter Britz @ 2014-10-02 12:01 UTC (permalink / raw)
  To: help-gnu-emacs

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?
-- 
Dieter Britz


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local variables list
  2014-10-02 12:01 Local variables list Dieter Britz
@ 2014-10-02 12:25 ` Pascal J. Bourguignon
  2014-10-02 12:58   ` Dieter Britz
  2014-10-02 13:16   ` Dieter Britz
  0 siblings, 2 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2014-10-02 12:25 UTC (permalink / raw)
  To: help-gnu-emacs

Dieter Britz <dieterhansbritz@gmail.com> 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)))
    End:

wouldn't be safe, and neither would:

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

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__                 http://www.informatimago.com/
“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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local variables list
  2014-10-02 12:25 ` Pascal J. Bourguignon
@ 2014-10-02 12:58   ` Dieter Britz
  2014-10-02 20:33     ` Pascal J. Bourguignon
  2014-10-02 13:16   ` Dieter Britz
  1 sibling, 1 reply; 5+ messages in thread
From: Dieter Britz @ 2014-10-02 12:58 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu, 02 Oct 2014 14:25:54 +0200, Pascal J. Bourguignon wrote:

> Dieter Britz <dieterhansbritz@gmail.com> 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)))
>     End:
> 
> wouldn't be safe, and neither would:
> 
>     Local Variable:
>     post-command-hook: ((lambda () (shell "rm -rf /")))
>     End:
> 
> 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).

Thanks - I don't fully understand but will watch out for this.
These must get into the file without my doing. I find in one of
these, at the end, the lines

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

How did they get there? What are local variables? I suppose
they are connected with the settings my emacs has (?) - these
must be default because I have never set anything.

-- 
Dieter Britz


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local variables list
  2014-10-02 12:25 ` Pascal J. Bourguignon
  2014-10-02 12:58   ` Dieter Britz
@ 2014-10-02 13:16   ` Dieter Britz
  1 sibling, 0 replies; 5+ messages in thread
From: Dieter Britz @ 2014-10-02 13:16 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu, 02 Oct 2014 14:25:54 +0200, Pascal J. Bourguignon wrote:

> Dieter Britz <dieterhansbritz@gmail.com> 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)))
>     End:
> 
> wouldn't be safe, and neither would:
> 
>     Local Variable:
>     post-command-hook: ((lambda () (shell "rm -rf /")))
>     End:
> 
> 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).

I just saw this:

    mode: latex
  * TeX-master: t

what does this mean? And in what way can these variables
be unsafe? What can happen? Sorry to belabour this.

-- 
Dieter Britz


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local variables list
  2014-10-02 12:58   ` Dieter Britz
@ 2014-10-02 20:33     ` Pascal J. Bourguignon
  0 siblings, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2014-10-02 20:33 UTC (permalink / raw)
  To: help-gnu-emacs

Dieter Britz <dieterhansbritz@gmail.com> writes:

> On Thu, 02 Oct 2014 14:25:54 +0200, Pascal J. Bourguignon wrote:
>
>> Dieter Britz <dieterhansbritz@gmail.com> 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)))
>>     End:
>> 
>> wouldn't be safe, and neither would:
>> 
>>     Local Variable:
>>     post-command-hook: ((lambda () (shell "rm -rf /")))
>>     End:
>> 
>> 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).
>
> Thanks - I don't fully understand but will watch out for this.
> These must get into the file without my doing. I find in one of
> these, at the end, the lines
>
> %%% Local Variables: 
> %%% mode: latex
> %%% TeX-master: t
> %%% End: 
>
> How did they get there? 

Somebody wrote them in that file.


> What are local variables? 

File Local Variables are buffer local variables that are set in the
buffer where the file is loaded.

See: (info "(emacs) File Variables") ; type C-x C-e before this comment.


> I suppose they are connected with the settings my emacs has (?) -
> these must be default because I have never set anything.

No, there are the opposite of default settings.  They are the most
specific settings you can get with emacs, specifically for buffers
visiting this specific file.

emacs consider unsafe all the variables it doesn't know to be safe.

TeX-master is unknown to be safe, so it's marked with one star.

Since the value is a simple symbol (t), it looks rather safe to set this
variable (and let whatever code you already loaded use it when
processing your buffer).

To be compared with post-command-hook, which is known to be unsafe, and
which emacs marked with two stars.



If you want to know what the variable is used for, you can type 
C-h v TeX-master RET
and see if it's documented.

Otherwise, you could check the source of any package that use the TeX-
prefix for their stuff.

Otherwise, it's possible no code uses it.




-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-02 20:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-02 12:01 Local variables list Dieter Britz
2014-10-02 12:25 ` Pascal J. Bourguignon
2014-10-02 12:58   ` Dieter Britz
2014-10-02 20:33     ` Pascal J. Bourguignon
2014-10-02 13:16   ` Dieter Britz

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.