mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-29 11:02:01 +00:00
(unsafep): Don't treat &rest or &optional as variables at all.
(unsafep-variable): Rename arg; doc fix.
This commit is contained in:
parent
7e5f578875
commit
fe541a2743
@ -148,10 +148,10 @@ of symbols with local bindings."
|
|||||||
((eq fun 'lambda)
|
((eq fun 'lambda)
|
||||||
;;First arg is temporary bindings
|
;;First arg is temporary bindings
|
||||||
(mapc #'(lambda (x)
|
(mapc #'(lambda (x)
|
||||||
(let ((y (unsafep-variable x t)))
|
|
||||||
(if y (throw 'unsafep y)))
|
|
||||||
(or (memq x '(&optional &rest))
|
(or (memq x '(&optional &rest))
|
||||||
(push x unsafep-vars)))
|
(let ((y (unsafep-variable x t)))
|
||||||
|
(if y (throw 'unsafep y))
|
||||||
|
(push x unsafep-vars))))
|
||||||
(cadr form))
|
(cadr form))
|
||||||
(unsafep-progn (cddr form)))
|
(unsafep-progn (cddr form)))
|
||||||
((eq fun 'let)
|
((eq fun 'let)
|
||||||
@ -247,17 +247,16 @@ and throws a reason to `unsafep' if unsafe. Returns SYM."
|
|||||||
(if reason (throw 'unsafep reason))
|
(if reason (throw 'unsafep reason))
|
||||||
sym))
|
sym))
|
||||||
|
|
||||||
(defun unsafep-variable (sym global-okay)
|
(defun unsafep-variable (sym to-bind)
|
||||||
"Return nil if SYM is safe as a let-binding sym
|
"Return nil if SYM is safe to set or bind, or a reason why not.
|
||||||
\(because it already has a temporary binding or is a non-risky buffer-local
|
If TO-BIND is nil, check whether SYM is safe to set.
|
||||||
variable), otherwise a reason why it is unsafe. Failing to be locally bound
|
If TO-BIND is t, check whether SYM is safe to bind."
|
||||||
is okay if GLOBAL-OKAY is non-nil."
|
|
||||||
(cond
|
(cond
|
||||||
((not (symbolp sym))
|
((not (symbolp sym))
|
||||||
`(variable ,sym))
|
`(variable ,sym))
|
||||||
((risky-local-variable-p sym nil)
|
((risky-local-variable-p sym nil)
|
||||||
`(risky-local-variable ,sym))
|
`(risky-local-variable ,sym))
|
||||||
((not (or global-okay
|
((not (or to-bind
|
||||||
(memq sym unsafep-vars)
|
(memq sym unsafep-vars)
|
||||||
(local-variable-p sym)))
|
(local-variable-p sym)))
|
||||||
`(global-variable ,sym))))
|
`(global-variable ,sym))))
|
||||||
|
Loading…
Reference in New Issue
Block a user