tags:

views:

155

answers:

2

This is rather queer. I can't set any value to a variable if it is named 's' in an interactive session:

(setq s 'foo)
=> foo

s
=> nil

Why?

Update 1:

Here is the output from describe-variable on s:

s is void as a variable.

Documentation:
Not documented as a variable.

Why is it that s is kept void in emacs lisp as a global variable?

Update 2:

Turned out, it doesn't happen on a vanilla emacs (meaning one of the modules I load in .emacs or some code in .emacs is causing this). So the question now is:

What would the original source look like when describe-variable yields "<var> is void as a variable"?

I tried it with setq, defconst, defvar, and defcustom, but none of those produced the message I'm showing.

Update 3:

The message shown above is produced when the variable is literally not bound (though it can be fbound).

(describe-variable 'non-existent)
=> "non-existent is void as a variable.

Documentation:
Not documented as a variable."

So latest question is: Is there any way to prevent a certain variable name from being bound?

A: 

An answer to your revised question:

(defvar s)

The only thing is that this won't let you use describe-variable on it interactively.

(You could then do something like (setplist 's '(variable-documentation "Meh")) to set a description for it without going through defvar.

Eli Barzilay
Is it really? `(defvar qq)` => qq. `(setq qq 'foo)` => foo. `qq` => foo
OTZ
Well, that was an answer to your second update...
Eli Barzilay
A: 

With Emacs 23.1, running the following code makes C-h v s RET show “s is void as a variable.”, but I can't reproduce the inconsistency between setq and retrieving the value of the variable (which I agree is weird).

(setq s t)
(make-local-variable 's)
(makunbound 's)

I suspect an Emacs 24-specific feature or bug.

Gilles