[英]nrepl.el and leiningen 2 default namespace?
让Emacs / Clojure环境启动并运行,我现在遇到了我不确定是正常的行为。 特别是,当我启动一个nREPL并编译(Cc Ck)我的缓冲区时,我会被放到我的core.clj文件顶部定义的命名空间之外。 我应该添加免责声明,我对Clojure和名称空间有点新,所以我对这一切的理解可能是模糊的。 我愿意接受那些能够让我看到Better Way™的自以为是的答案。
首先,关于我的设置:
我的emacs环境是Cocoa Emacs 24,主要使用Melpa存储库中的emacs入门工具包进行设置,并通过包管理器添加了clojure和nrepl包。
我的leiningen 2项目是使用lein new test-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"]])
我的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)))))
我想我应该能够
Mx nrepl-jack-in
) Cc Ck
将缓冲区加载到REPL中 实际上,我得到的错误看起来像clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: show-shapefile in this context, compiling:(NO_SOURCE_PATH:1)
如果,从REPL我第一次输入(in-ns`test-clj.core),我就是金色的。 另外,如果我输入(test-clj.core / show-shapefile)我就设置了。
当我在逆时针加载REPL时,我会自动进入test-clj.core命名空间,这似乎很方便。
我的问题是双重的:
只需对您的工作流程进行一些更改:
第2步编译文件,创建命名空间
步骤3比切换到repl并运行in-ns
短
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.