这很奇怪。如果在交互式 session 中将变量命名为“s”,我无法为变量设置任何值:
(setq s 'foo)
=> foo
s
=> nil
为什么?
更新 1:
这是 s 上 describe-variable 的输出:
s is void as a variable.
Documentation:
Not documented as a variable.
为什么 s 在 emacs lisp 中作为全局变量保持为空?
更新 2:
事实证明,它不会发生在 vanilla emacs 上(这意味着我在 .emacs 中加载的模块之一或 .emacs 中的某些代码导致了这种情况)。 所以现在的问题是:
当描述变量产生“<var>
is void as a variable”时,原始源会是什么样子?
我用 setq
试过了, defconst
, defvar
, 和 defcustom
,但这些都没有产生我正在显示的消息。
更新 3:
上面显示的消息是在变量未绑定(bind)时产生的(尽管它可以是 fbound
)。
(describe-variable 'non-existent)
=> "non-existent is void as a variable.
Documentation:
Not documented as a variable."
所以最新的问题是:有什么办法可以防止某个变量名 从被绑定(bind)?
最佳答案
修改后的问题的答案:
(defvar s)
唯一的问题是,这不会让您以交互方式对其使用 describe-variable
。
(然后您可以执行类似 (setplist 's '(variable-documentation "Meh"))
的操作来为其设置描述,而无需通过 defvar
。
关于Emacs 口齿不清 : Can't set any value to variable named 's' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3851863/