Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

running lisp code like file variables

0 views
Skip to first unread message

Xah

unread,
Jul 23, 2008, 6:23:57 PM7/23/08
to
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.

Thanks.

Xah
http://xahlee.org/


Lennart Borgman (gmail)

unread,
Jul 23, 2008, 6:47:12 PM7/23/08
to Xah, help-gn...@gnu.org
Xah wrote:
> 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.


See

(info "(emacs) File Variables")


Tim X

unread,
Jul 24, 2008, 8:48:35 AM7/24/08
to
Xah <xah...@gmail.com> 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.

Tim


--
tcross (at) rapttech dot com dot au

0 new messages