* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
[not found] <E1O6mXN-0006ds-3k@internal.in.savannah.gnu.org>
@ 2010-04-27 21:32 ` Glenn Morris
2010-04-27 21:46 ` Chong Yidong
2010-04-27 22:09 ` Sam Steingold
0 siblings, 2 replies; 10+ messages in thread
From: Glenn Morris @ 2010-04-27 21:32 UTC (permalink / raw)
To: Sam Steingold; +Cc: emacs-devel
Sam Steingold wrote:
> +2010-04-27 Sam Steingold <sds@gnu.org>
> +
> + * progmodes/bug-reference.el (bug-reference-url-format): Mark as
> + `safe-local-variable' if the value is a string or a function,
I'm probably being thick, but I don't see how an arbitrary function
can be assumed to be safe. Eg consider a ChangeLog file:
2010-04-27 A N Other <none@example.com>
* configure.in: Blah. (Bug#123)
;; Local Variables:
;; mode: bug-reference
;; bug-reference-url-format: (lambda () (shell-command "touch /tmp/foo"))
;; End:
Optionally, replace "touch /tmp/foo" with "rm -rf ~".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 21:32 ` /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value Glenn Morris
@ 2010-04-27 21:46 ` Chong Yidong
2010-04-27 22:09 ` Sam Steingold
1 sibling, 0 replies; 10+ messages in thread
From: Chong Yidong @ 2010-04-27 21:46 UTC (permalink / raw)
To: Glenn Morris; +Cc: Sam Steingold, emacs-devel
Glenn Morris <rgm@gnu.org> writes:
> 2010-04-27 A N Other <none@example.com>
>
> * configure.in: Blah. (Bug#123)
>
> ;; Local Variables:
> ;; mode: bug-reference
> ;; bug-reference-url-format: (lambda () (shell-command "touch /tmp/foo"))
> ;; End:
>
> Optionally, replace "touch /tmp/foo" with "rm -rf ~".
I think the canonical operation is "launch missiles".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 21:32 ` /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value Glenn Morris
2010-04-27 21:46 ` Chong Yidong
@ 2010-04-27 22:09 ` Sam Steingold
2010-04-27 22:39 ` Lennart Borgman
2010-04-27 22:42 ` Chong Yidong
1 sibling, 2 replies; 10+ messages in thread
From: Sam Steingold @ 2010-04-27 22:09 UTC (permalink / raw)
To: Glenn Morris; +Cc: emacs-devel
On 4/27/10, Glenn Morris <rgm@gnu.org> wrote:
> Sam Steingold wrote:
>
> > +2010-04-27 Sam Steingold <sds@gnu.org>
> > +
> > + * progmodes/bug-reference.el (bug-reference-url-format): Mark as
> > + `safe-local-variable' if the value is a string or a function,
>
> I'm probably being thick, but I don't see how an arbitrary function
> can be assumed to be safe
You are right.
this means that I cannot really set bug-reference-url-format in the
"Local Variables:"
section together with "mode: bug-reference" if I also set
enable-local-variables to :safe.
if I set it to "t", I get asked about local variable for _every_ file
operation (including diff!)
in the emacs tree and anything else ignores my local settings of
bug-reference-url-format.
For your reference, I set bug-reference-url-format to
clisp-bug-reference-url-format:
(defun clisp-bug-reference-url-format ()
(concat "http://sourceforge.net/tracker/index.php?func=detail&aid="
(match-string-no-properties 2)
"&group_id=1355&atid="
(let ((kind (match-string-no-properties 1)))
(cond ((string-match "[Bb]ug" kind) "101355")
((string-match "[Pp]atch" kind) "301355")
((string-match "RFE" kind) "351355")
(t (error "unknown bug kind [%s]" kind))))))
I expect this kind of setting to be fairly common unless one is using
the gnu bug tracker or something similar.
the bottom line is that there _must_ be a way to use something
reasonably flexible here and still not be asked "local variable"
question for each C-x v =
--
Sam Steingold <http://sds.podval.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 22:09 ` Sam Steingold
@ 2010-04-27 22:39 ` Lennart Borgman
2010-04-27 22:42 ` Chong Yidong
1 sibling, 0 replies; 10+ messages in thread
From: Lennart Borgman @ 2010-04-27 22:39 UTC (permalink / raw)
To: Sam Steingold; +Cc: emacs-devel
On Wed, Apr 28, 2010 at 12:09 AM, Sam Steingold <sds@gnu.org> wrote:
> On 4/27/10, Glenn Morris <rgm@gnu.org> wrote:
>> Sam Steingold wrote:
>>
>> > +2010-04-27 Sam Steingold <sds@gnu.org>
>> > +
>> > + * progmodes/bug-reference.el (bug-reference-url-format): Mark as
>> > + `safe-local-variable' if the value is a string or a function,
>>
>> I'm probably being thick, but I don't see how an arbitrary function
>> can be assumed to be safe
>
> You are right.
> this means that I cannot really set bug-reference-url-format in the
> "Local Variables:"
> section together with "mode: bug-reference" if I also set
> enable-local-variables to :safe.
...
> the bottom line is that there _must_ be a way to use something
> reasonably flexible here and still not be asked "local variable"
> question for each C-x v =
Maybe a safe value could be a (symbol) key to an association lists
with entries like '(my-key my-bug-reference-url-function)?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 22:09 ` Sam Steingold
2010-04-27 22:39 ` Lennart Borgman
@ 2010-04-27 22:42 ` Chong Yidong
2010-04-27 23:10 ` Sam Steingold
1 sibling, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2010-04-27 22:42 UTC (permalink / raw)
To: Sam Steingold; +Cc: emacs-devel
Sam Steingold <sds@gnu.org> writes:
> this means that I cannot really set bug-reference-url-format in the
> "Local Variables:"
> section together with "mode: bug-reference" if I also set
> enable-local-variables to :safe.
>
> For your reference, I set bug-reference-url-format to
> clisp-bug-reference-url-format:
>
> (defun clisp-bug-reference-url-format ()
> (concat "http://sourceforge.net/tracker/index.php?func=detail&aid="
> (match-string-no-properties 2)
> "&group_id=1355&atid="
> (let ((kind (match-string-no-properties 1)))
> (cond ((string-match "[Bb]ug" kind) "101355")
> ((string-match "[Pp]atch" kind) "301355")
> ((string-match "RFE" kind) "351355")
> (t (error "unknown bug kind [%s]" kind))))))
Where do you define clisp-bug-reference-url-format? In your init file?
If so, you could probably add
(put 'bug-reference-url-format 'safe-local-variable
(lambda (s) (or (stringp s)
(eq s 'clisp-bug-reference-url-format))))
at the same place.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 22:42 ` Chong Yidong
@ 2010-04-27 23:10 ` Sam Steingold
2010-04-28 15:32 ` Davis Herring
0 siblings, 1 reply; 10+ messages in thread
From: Sam Steingold @ 2010-04-27 23:10 UTC (permalink / raw)
To: Chong Yidong; +Cc: emacs-devel
On 4/27/10, Chong Yidong <cyd@stupidchicken.com> wrote:
> Sam Steingold <sds@gnu.org> writes:
>
> > this means that I cannot really set bug-reference-url-format in the
> > "Local Variables:"
> > section together with "mode: bug-reference" if I also set
> > enable-local-variables to :safe.
> >
>
> > For your reference, I set bug-reference-url-format to
> > clisp-bug-reference-url-format:
> >
> > (defun clisp-bug-reference-url-format ()
> > (concat "http://sourceforge.net/tracker/index.php?func=detail&aid="
> > (match-string-no-properties 2)
> > "&group_id=1355&atid="
> > (let ((kind (match-string-no-properties 1)))
> > (cond ((string-match "[Bb]ug" kind) "101355")
> > ((string-match "[Pp]atch" kind) "301355")
> > ((string-match "RFE" kind) "351355")
> > (t (error "unknown bug kind [%s]" kind))))))
>
>
> Where do you define clisp-bug-reference-url-format? In your init file?
no, it is a part of the clisp distribution (and cvs tree)
> If so, you could probably add
>
> (put 'bug-reference-url-format 'safe-local-variable
> (lambda (s) (or (stringp s)
> (eq s 'clisp-bug-reference-url-format))))
>
> at the same place.
>
brilliant!
actually, I think the right way is
(put 'bug-reference-url-format 'safe-local-variable
(let ((f (get 'bug-reference-url-format 'safe-local-variable)))
(lambda (s) (or (funcall f s) (eq s 'clisp-bug-reference-url-format)))))
so that if others do that too, I will not override them.
in fact, maybe the above should be a standard function
(add-safe-value variable symbol)
--
Sam Steingold <http://sds.podval.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-27 23:10 ` Sam Steingold
@ 2010-04-28 15:32 ` Davis Herring
2010-04-28 15:51 ` Chong Yidong
0 siblings, 1 reply; 10+ messages in thread
From: Davis Herring @ 2010-04-28 15:32 UTC (permalink / raw)
To: Sam Steingold; +Cc: Chong Yidong, emacs-devel
> (put 'bug-reference-url-format 'safe-local-variable
> (let ((f (get 'bug-reference-url-format 'safe-local-variable)))
> (lambda (s) (or (funcall f s) (eq s
> 'clisp-bug-reference-url-format)))))
That won't work if the existing value is not a function (e.g. if it is t
(which would be foolish, of course) or nil). Moreover, you need to use
backquotes: (let ((f ...)) `(lambda (s) (or (funcall ,f s) ...))) (this is
one of the reasons people want lexbind).
> so that if others do that too, I will not override them.
> in fact, maybe the above should be a standard function
> (add-safe-value variable symbol)
I don't know how often it is useful to be able to add many individual safe
values for a variable; perhaps instead there should be another variable
whose file-local value can be a string s from which
`bug-reference-url-format' is calculated as (intern (concat s
"-url-format")). Then only functions intended for the purpose could be
selected by the file.
Or, more generally, perhaps there should be a symbol property
`safe-file-function' placed on symbols whose values as functions were safe
to call regardless of context, so that we could then allow precisely those
symbols as the values of certain function-valued file locals:
(put 'clisp-bug-reference-url-format 'safe-file-function t)
(defun safe-file-function-p (f)
(and (symbolp f) (get f 'safe-file-function))
(put 'bug-reference-url-format 'safe-local-variable 'safe-file-function-p)
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-28 15:32 ` Davis Herring
@ 2010-04-28 15:51 ` Chong Yidong
2010-04-28 16:25 ` Davis Herring
0 siblings, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2010-04-28 15:51 UTC (permalink / raw)
To: herring; +Cc: Sam Steingold, emacs-devel
"Davis Herring" <herring@lanl.gov> writes:
>> (put 'bug-reference-url-format 'safe-local-variable
>> (let ((f (get 'bug-reference-url-format 'safe-local-variable)))
>> (lambda (s) (or (funcall f s) (eq s
>> 'clisp-bug-reference-url-format)))))
>
> That won't work if the existing value is not a function (e.g. if it is t
> (which would be foolish, of course) or nil).
A `safe-local-variable' property must be a function of one argument
(or nil).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-28 15:51 ` Chong Yidong
@ 2010-04-28 16:25 ` Davis Herring
2010-04-28 17:21 ` Chong Yidong
0 siblings, 1 reply; 10+ messages in thread
From: Davis Herring @ 2010-04-28 16:25 UTC (permalink / raw)
To: Chong Yidong; +Cc: Sam Steingold, emacs-devel
> A `safe-local-variable' property must be a function of one argument
> (or nil).
Ah, sorry; I don't know why I thought t was allowed. But the code I was
commenting on would fail with nil too, as I said, so the point remains.
While reading further I also see that we already have
`safe-local-variable-values' for the case where particular values need to
be marked as safe, which certainly satisfies the stated desire to allow
one additional value for a variable without the `lambda' trickery.
Perhaps the `safe-file-function' property would nonetheless be useful to
avoid having to add many different things to s-l-v-v.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value
2010-04-28 16:25 ` Davis Herring
@ 2010-04-28 17:21 ` Chong Yidong
0 siblings, 0 replies; 10+ messages in thread
From: Chong Yidong @ 2010-04-28 17:21 UTC (permalink / raw)
To: herring; +Cc: Sam Steingold, emacs-devel
"Davis Herring" <herring@lanl.gov> writes:
> While reading further I also see that we already have
> `safe-local-variable-values' for the case where particular values need to
> be marked as safe, which certainly satisfies the stated desire to allow
> one additional value for a variable without the `lambda' trickery.
> Perhaps the `safe-file-function' property would nonetheless be useful to
> avoid having to add many different things to s-l-v-v.
It's not practical for an external package to change
safe-local-variable-values, because that is a customizable user option.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-04-28 17:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1O6mXN-0006ds-3k@internal.in.savannah.gnu.org>
2010-04-27 21:32 ` /srv/bzr/emacs/trunk r100059: (bug-reference-url-format): Mark as `safe-local-variable' if the value Glenn Morris
2010-04-27 21:46 ` Chong Yidong
2010-04-27 22:09 ` Sam Steingold
2010-04-27 22:39 ` Lennart Borgman
2010-04-27 22:42 ` Chong Yidong
2010-04-27 23:10 ` Sam Steingold
2010-04-28 15:32 ` Davis Herring
2010-04-28 15:51 ` Chong Yidong
2010-04-28 16:25 ` Davis Herring
2010-04-28 17:21 ` Chong Yidong
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).