问题描述
在Emacs Lisp中,是否有一个函数来获取由 defvar
启动的符号的初始值?像 some-function
如下所示:
(defvar varinitial值)
(setq varchanged value)
(some-function'var)
=> inital value
Emacs不记得初始值。
pre $ (defvar varinitial value)
(setq varchanged value)$ b $在 * scratch *
缓冲区中,$ $ c $
c>初始值不再可用,全部停止。
如果 defvar
在加载的文件中执行,Emacs会记住它的加载位置; (symbol-file var'defvar)
返回文件名,您可以获取变量初始化的原始表达式(而不是原始值),假设档案还在。这也可以通过命令。
In Emacs Lisp, is there a function to get the initial value of a symbol initilized by defvar
? Like the some-function
shown below:
(defvar var "initial value")
(setq var "changed value")
(some-function 'var)
=> "inital value"
Emacs doesn't remember the initial value. If you evaluate
(defvar var "initial value")
(setq var "changed value")
in the *scratch*
buffer, "initial value"
is no longer available, full stop.
If the defvar
was performed in a loaded file, Emacs remembers where it's loaded from; (symbol-file var 'defvar)
returns the file name, and you can get an the original expression that the variable was initialized with (but not the original value), assuming the file is still around. This is also available via the command .
这篇关于如何在Elisp中获取变量的初始值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!