From: Tassilo Horn <tsdh@gnu.org>
To: Thomas Koch <thomas@koch.ro>
Cc: Emacs discussions <emacs-devel@gnu.org>
Subject: Re: how accept all values for a specific var in safe-local-variable-values?
Date: Mon, 26 Aug 2013 13:06:54 +0200 [thread overview]
Message-ID: <87li3oiucx.fsf@thinkpad.tsdh.org> (raw)
In-Reply-To: <201308261225.22566.thomas@koch.ro> (Thomas Koch's message of "Mon, 26 Aug 2013 12:25:22 +0200")
Thomas Koch <thomas@koch.ro> writes:
Hi Thomas,
> I use the variable epa-file-encrypt-to as a file local variable with all
> possible permutations and subsets of my coworkers gpg keys. It's rather
> annoying to have all this different values as acceptable values in epa-file-
> encrypt-to and to be queried each time a new key is added.
>
> Is it possible to somehow tell emacs that it should accept values for
> epa-file-encrypt-to in general, indifferent of the value?
You can setup a predicate that determines if a value is considered
safe. See:
,----[ (info "(elisp)File Local Variables") ]
| You can specify safe values for a variable with a
| ‘safe-local-variable’ property. The property has to be a function of
| one argument; any value is safe if the function returns non-‘nil’ given
| that value. Many commonly-encountered file variables have
| ‘safe-local-variable’ properties; these include ‘fill-column’,
| ‘fill-prefix’, and ‘indent-tabs-mode’. For boolean-valued variables
| that are safe, use ‘booleanp’ as the property value. Lambda expressions
| should be quoted so that ‘describe-variable’ can display the predicate.
`----
So you could say
(put 'epa-file-encrypt-to 'safe-local-variable
#'my-isa-subset-of-coworkers-gpg-keys)
or even
(put 'epa-file-encrypt-to 'safe-local-variable
#'(lambda (val) t))
to accept any value.
Hm, right now it already has this safe-local-variable predicate (in
epa-hooks.el):
--8<---------------cut here---------------start------------->8---
(put 'epa-file-encrypt-to 'safe-local-variable
(lambda (val)
(or (stringp val)
(and (listp val)
(catch 'safe
(mapc (lambda (elt)
(unless (stringp elt)
(throw 'safe nil)))
val)
t)))))
--8<---------------cut here---------------end--------------->8---
That says that values are considered safe if they are a string or a list
of strings. Do you set it to something different than a string or list
of strings locally? Or maybe you are using an emacs version that
doesn't have that property for `epa-file-encrypt-to' yet?
BTW, as the docs above suggest, that lambda should be quoted in order
for `describe-variable' to display the predicate. I just did that on
the emacs trunk.
Bye,
Tassilo
prev parent reply other threads:[~2013-08-26 11:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 10:25 how accept all values for a specific var in safe-local-variable-values? Thomas Koch
2013-08-26 11:06 ` Tassilo Horn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87li3oiucx.fsf@thinkpad.tsdh.org \
--to=tsdh@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=thomas@koch.ro \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.