I've accidentally run the following:
(unintern variable)
where variable
's value was nil
.
How do I get nil
back without restarting Emacs?
I've accidentally run the following:
(unintern variable)
where variable
's value was nil
.
How do I get nil
back without restarting Emacs?
(defconst nil ())
seems to have the right effect; note that nil
and an empty list are indistinguishable in Emacs Lisp.
I looked at lread.c:4034
to see how nil
is created in an obarray
.
Note the comment at line 3896 in lread.c
:
/* There are plenty of other symbols which will screw up the Emacs
session if we unintern them, as well as even more ways to use
`setq' or `fset' or whatnot to make the Emacs session
unusable. Let's not go down this silly road. --Stef */
/* if (EQ (tem, Qnil) || EQ (tem, Qt))
error ("Attempt to unintern t or nil"); */
This explains why Emacs does not protect against (unintern nil)
and (unintern t)
.
Stef
on this one, actually :) Down that road lies madness.
Commented
Oct 31, 2014 at 23:37
nil
is a common error that's easy to protect against. Why put a handrail on a staircase when people could jump over it?
Commented
Oct 31, 2014 at 23:55
unintern
is not used frequently, really. Using it on the main obarray
is pretty much always a bad idea (which is why the byte-compiler complains when you fail to pass the second argument, and C-h f unintern
doesn't tell you that the second arg is actually still optional).