* check argument count in defcustom :safe?
@ 2015-04-11 15:42 Stephen Leake
2015-04-12 3:48 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Leake @ 2015-04-11 15:42 UTC (permalink / raw)
To: emacs-devel
I have changed the signature of a defcustom variable; it used to require
a function taking 2 args, now it takes 3. So I'd like to have the :safe
predicate check the argument count, not just `functionp'.
The argument count is only available for byte-compiled functions, so I'd
have to skip that check for non-compiled. But most of the time, the
check will be useful.
The low-level C code that executes byte code checks the argument count,
but I don't see any way to access the argument count from lisp. Am I
missing something?
To be specific, here's the defcustom:
(defcustom ada-case-identifier 'ada-mixed-case
"..."
:type '(choice (const ada-mixed-case)
(const ada-lower-case)
(const ada-upper-case))
:group 'ada
:safe 'functionp)
What can I add to the :safe expression to check the argument count?
--
-- Stephe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: check argument count in defcustom :safe?
2015-04-11 15:42 check argument count in defcustom :safe? Stephen Leake
@ 2015-04-12 3:48 ` Stefan Monnier
2015-04-12 6:45 ` Philipp Stephani
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-04-12 3:48 UTC (permalink / raw)
To: Stephen Leake; +Cc: emacs-devel
> :safe 'functionp)
FWIW, I think it makes absolutely no sense for :safe to be `functionp'.
This is just a gaping security hole. And checking the number of
arguments would make no difference in this respect.
> but I don't see any way to access the argument count from lisp. Am I
> missing something?
The number of arguments passed to a function is something that can be
easily checked by the function, but checking the number of arguments
accepted by a function is generally impossible (think of a function like
(lambda (&rest args)
(if (> (length args) (if (halting-p (car args)) 2 3))
(signal 'wrong-number-of-arguments 'foo (length args)))
...)
-- Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-12 11:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-11 15:42 check argument count in defcustom :safe? Stephen Leake
2015-04-12 3:48 ` Stefan Monnier
2015-04-12 6:45 ` Philipp Stephani
2015-04-12 10:00 ` Artur Malabarba
2015-04-12 11:59 ` Stefan Monnier
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.