[Top][All Lists]

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

Re: running lisp code like file variables

From: Tim X
Subject: Re: running lisp code like file variables
Date: Thu, 24 Jul 2008 22:48:35 +1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Xah <address@hidden> writes:

> is there a way to attache a simple lisp code to a file like file
> variables?
> for example, i want this line at the top of a file,
> -*- (highlight-regexp "\([^"]+\)" hi-yellow) -*-
> when the file is opened, the expr is evaluated so that all double
> quoted text are highlighted.

Yes, you can do this. However, by default, this is either disabled or
you have to interactively agree to it. the reason is of course obvious -
if emacs blindly just evaluated any bit of emacs lisp put into a local
variable (file variable) you would get the sort of mess you get with
other "modern" user friendly non-tech geeking software solutions that
do this and which have provided a convenient way to embed malicious code
or a virus in a file just waiting to be opened!

Of course, as emacs knows that some will be smart enough to know how to
use this feature safely, you can enable it so that it does execute the
code automatically. 

Note that I'm not sure you can do it in the top line - you may need to
have the local variables section at the end of the file - of course, not
a big issue for anyone who knows emacs and how to handle that in pretty
much an invisible way.


tcross (at) rapttech dot com dot au

reply via email to

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