如何清除在苹果酒模式的REPL? [英] How to clear the REPL in cider-mode?
问题描述
我不是意味着清理REPL的文本输出;我的意思是清除REPL中的所有已评估的结果。在开发期间,重复 Cc Cq
和 Cc Mj
效率低。
I am not meaning cleaning up the text output of REPL; I mean cleaning up all evaluated results in REPL. During developing, repeatedly C-c C-q
and C-c M-j
is low efficiency.
我的一些错误调试行为。我不知道其他人如何使用CIDER开发程序,但我真的需要上面提到的功能。我猜其他开发人员也会遇到和我一样的问题。
There may be some bad debug behaviour of mine. I am not sure how other people develop progs with CIDER, but I really need the functionality mentioned above. I guess other developers also encounter same problems as mine.
例如,在clojure prog单元的顶部,我使用 declare
声明一个函数 foo
,由另一个函数 bar
和 foo
在 bar
后实现。然后,I C-c C-k
等,并且prog进行顺利。后来,我偶尔删除了 foo
的向前声明。发生了什么? prog仍然很好。 真的?
For example, at the top of a clojure prog unit, I use declare
to declare a function foo
, which is used by another function bar
, and foo
is implemented after bar
. Then, I C-c C-k
, etc, and the prog goes well. Later, I removed the forward declaration of foo
occasionally. What does happen? The prog still goes well. REALLY? Then, I commit my whole job and terminate the CIDER REPL session happily.
早上的灾难:符号 foo
不是发现了!
Disaster on morning: Symbol foo
not found!
这是我的故事。
That's my story. So, nobody has ever encountered similar problems?
推荐答案
尝试(refresh)$ c $
clojure.tools.namespace.repl
命名空间中的
Try the (refresh)
function in the clojure.tools.namespace.repl
namespace:
刷新函数将扫描Clojure源文件的类路径上的所有目录,读取它们的ns声明,构建它们的依赖关系的图,并按照依赖顺序加载它们。
The refresh function will scan all the directories on the classpath for Clojure source files, read their ns declarations, build a graph of their dependencies, and load them in dependency order.
https://github.com/clojure/tools.namespace#reloading-code -usage
似乎不会删除用户
命名空间中声明的vars我输入了REPL,但它有:
It doesn't seem to remove the vars declared in the user
namespace, which I've typed into the REPL, but it does:
...卸载(删除)更改的命名空间以清除任何旧的
的定义。
...unload (remove) the namespaces that changed to clear out any old definitions.
我们通常添加一些其他有用的东西给 code>命名空间,因此在启动时加载到REPL中:
We generally add that plus a few other useful things to the user
namespace, so it's loaded into the REPL on startup:
(ns user
(:require [clojure.tools.namespace.repl :refer [refresh]]
[clojure.repl :refer [doc source]]
[clojure.pprint :refer [pprint pp]]
[midje.repl :as midje]
[clojure.stacktrace :as st]))
保持该代码与您的主要和测试源分开,将它放在< project root> /dev/user.clj
下的文件中,然后将以下内容添加到您的lein project.clj
文件:
To keep that code separate from your main and test sources, put that in a file at <project root>/dev/user.clj
, then add the following to your lein project.clj
file:
:profiles {:dev {:source-paths ["dev"]}}
虽然这不是你想要回答的问题,对于那些看到这个答案,并希望清除Cider REPL中的文本,它是 Cc Mo
(https://github.com/clojure-emacs/cider )
这篇关于如何清除在苹果酒模式的REPL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!