[英]nrepl.el and leiningen 2 default namespace?
Getting an Emacs / Clojure environment up and running, I'm now running into behavior that I'm not sure is normal. 让Emacs / Clojure环境启动并运行,我现在遇到了我不确定是正常的行为。 In particular, when I start an nREPL and compile (Cc Ck) my buffer, I get dropped into something other than the namespace defined at the top of my core.clj file.
特别是,当我启动一个nREPL并编译(Cc Ck)我的缓冲区时,我会被放到我的core.clj文件顶部定义的命名空间之外。 I should add the disclaimer that I'm a bit new to Clojure and namespaces, and so my understanding of all this might be murky.
我应该添加免责声明,我对Clojure和名称空间有点新,所以我对这一切的理解可能是模糊的。 I'm open to opinionated answers that show me a Better Way™.
我愿意接受那些能够让我看到Better Way™的自以为是的答案。
First, about my setup: 首先,关于我的设置:
My emacs environment is Cocoa Emacs 24, set up mostly with the emacs starter kit from the Melpa repository, with the clojure and nrepl packages added via the package manager. 我的emacs环境是Cocoa Emacs 24,主要使用Melpa存储库中的emacs入门工具包进行设置,并通过包管理器添加了clojure和nrepl包。
My leiningen 2 project was set up using lein new test-clj
. 我的leiningen 2项目是使用
lein new test-clj
。
My project.clj : 我的project.clj :
(defproject test-clj "0.1.0-SNAPSHOT"
:description "A geospatial test app example mostly ripped off from http://datamangling.com/blog/2010/05/26/geotools-quickstart-in-clojure/"
:repositories {"osgeo-geotools" "http://download.osgeo.org/webdav/geotools"}
:url "FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]
[org.geotools/gt-main "8.2"]
[org.geotools/gt-shapefile "8.2"]
[org.geotools/gt-epsg-hsql "8.2"]
[org.geotools/gt-swing "8.2"]])
My core.clj : 我的core.clj :
(ns test-clj.core
(:import [org.geotools.data CachingFeatureSource FeatureSource FileDataStore FileDataStoreFinder])
(:import [org.geotools.map DefaultMapContext MapContext])
(:import [org.geotools.swing JMapFrame])
(:import [org.geotools.swing.data JFileDataStoreChooser]))
(defn show-shapefile
"Prompts the user for a shapefile and displays its content"
[]
(if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
(let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))]
(doto (DefaultMapContext.)
(.setTitle "Quickstart")
(.addLayer fs nil)
(JMapFrame/showMap)))))
I think I should be able to 我想我应该能够
Mx nrepl-jack-in
) Mx nrepl-jack-in
) Cc Ck
to load the buffer into the REPL Cc Ck
将缓冲区加载到REPL中 In actuality, I get an error that looks like clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: show-shapefile in this context, compiling:(NO_SOURCE_PATH:1)
实际上,我得到的错误看起来像
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: show-shapefile in this context, compiling:(NO_SOURCE_PATH:1)
If, from the REPL I first type (in-ns `test-clj.core), I'm golden. 如果,从REPL我第一次输入(in-ns`test-clj.core),我就是金色的。 Also, if I type (test-clj.core/show-shapefile) I'm set.
另外,如果我输入(test-clj.core / show-shapefile)我就设置了。
When I load a REPL in Counterclockwise, I automagically get dropped into the test-clj.core namespace, which seems mighty convenient. 当我在逆时针加载REPL时,我会自动进入test-clj.core命名空间,这似乎很方便。
My question then is two-fold: 我的问题是双重的:
just a couple changes to your workflow: 只需对您的工作流程进行一些更改:
step 2 compiles the file, which creates the namespace 第2步编译文件,创建命名空间
step 3 is just shorter than switching to the repl and running in-ns
步骤3比切换到repl并运行
in-ns
短
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.