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

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

Re: how to reference the current *.el file in elisp


From: Barry Margolin
Subject: Re: how to reference the current *.el file in elisp
Date: Mon, 29 Jun 2009 23:30:49 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <address@hidden>, address@hidden wrote:

> > How do I do things like
> > # Local Variables:
> > # compile-command: (concat "blarfowitz --nizbotize" buffer-file-name)
> > # End:
> > without being asked about risky variables, or hard wiring buffer-file-name?
> 
> BM> if you want to customize risky local variables, see the
> BM> safe-local-variables-p function.
> 
> OK, I read that, and (info "(emacs) Safe File Variables")
> but I still don't get why buffer-file-name is so unsafe... OK, maybe one

The warning isn't about buffer-file-name, it's about compile-command.  
It warns if you try to set it to something other than a string.  In your 
case, you're trying to set it to a list.

> can set it to /etc/passwd and cause one to zap that file... Anyway, in
> perl or sh there is the handy
>        $PROGRAM_NAME
>        $0      Contains the name of the program being executed.
> So why in "Local Variables" stanzas is there no way to refer to the
> current file being edited, without setting off all kinds of fire alarms,
> or being forced to whitelist something because it is dangerous, thus
> exposing myself to danger elsewhere. See also
> http://groups.google.com/groups/search?as_umsgid=mailman.597.1244940108.2239.h
> address@hidden

Values in the local variables stanza aren't evaluated, they're treated 
as literals.  So there's no referring possible.

This is why hooks are usually more appropriate for complex things like 
this.  If you really do need a special compile-command just for one 
specific file, you'll have to hard-code the file's name into it, e.g.

# compile-command: blarfowitz --nizbotize myscript.sh

-- 
Barry Margolin, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

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