这必须是一个愚蠢的简单问题,但我无法找到答案,尽管多次搜索Google多次,并挖掘Calc文档.
通过Calc运行GIVEN Emacs实例,并执行多个计算,包括存储变量和方程式,其中一些可能来自"〜/ .emacs.d/calc.el"文件,
如何在不重新启动Emacs的情况下将Calc返回到原始状态?
原始:堆栈上没有任何东西.没有任何东西在路上.没有存储的变量或方程式.等等.
M-x calc-reset,也是必然的C-x * 0,是你需要的.从信息手册:
的
C-x * 0' command ('calc-reset'; that's 'C-x *' followed by a zero) resets the Calculator to its initial state. This clears the stack, resets all the modes to their initial values (the values that were saved with毫米"(calc-save-modes')), clears the caches (*note Caches::), and so on. (It does _not_ erase the values of any variables.) With an argument of 0, Calc will be reset to its default state; namely, the modes will be given their default values. With a positive prefix argument,CX*0'保留堆栈的内容,但复位一切到其初始状态;具有负prefix参数,`CX*0'保留堆栈的内容,但复位一切到其默认状态.
编辑:哎呀.即使这样也不能清楚变数.我不确定是否有一种简单的方法可以让我一直回到原始状态:(
编辑2:看起来Calc将所有变量(包括像pi和e的'内置函数)存储为带有前缀'var-'的全局变量.据我所知,它没有跟踪模式设置的变量(如pi),以及用户设置的变量.此外,默认用户变量存储为var-q0,var-q1等.因此,为了清除所有变量,您需要编译启动时存在的变量和状态列表,擦除不在该列表中的所有内容,然后恢复该列表中变量的原始值.这当然是可能的,但有点乏味.
编辑3:这是我的尝试.我再看一下calc-mode,在启动时它定义了我在下面的my-calc-builtin-vars中添加的变量.第二行将删除Emacs中以前缀'var-'开头并且不在此列表中的所有变量.这将包括您或其他包中定义的任何变量.所以,我们希望没有人使用前缀'var-'.并且它不会重置内置变量的值,因此如果您将pi重新定义为3,它将保持为3.
(setq my-calc-builtin-vars
'("var-nan" "var-uinf" "var-sym" "var-lines" "var-Modes"
"var-EvalRules" "var-inf" "var-phi" "var-pi" "var-gamma" "var-?"
"var-?" "var-?" "var-spec" "var-e" "var-i"))
(defun really-reset-calc ()
(interactive)
(calc-reset nil)
(mapc #'(lambda (el) (unintern el))
(remove nil (mapcar
#'(lambda (el) (unless (member el my-calc-builtin-vars) el))
(all-completions "var-" obarray)))))
Run Code Online (Sandbox Code Playgroud)
目前内置的vars列表:
(setq my-calc-builtin-vars
'("var-CommuteRules" "var-Decls" "var-DistribRules" "var-EvalRules"
"var-FactorRules" "var-FitRules" "var-Holidays" "var-IntegAfterRules"
"var-IntegLimit" "var-InvertRules" "var-JumpRules" "var-MergeRules"
"var-Modes" "var-NegateRules" "var-e" "var-gamma" "var-i" "var-phi"
"var-pi" "var-?" "var-?" "var-?"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1039 次 |
| 最近记录: |