Emacs nrepl.el和leiningen 2默认名称空间?
在启动并运行Emacs/Clojure环境时,我现在遇到了我不确定是否正常的行为。特别是,当我启动一个nREPL并编译(C-C-k)我的缓冲区时,我会被放到core.clj文件顶部定义的名称空间之外的其他地方。我应该加上免责声明,我对Clojure和名称空间有点陌生,因此我对这一切的理解可能是模糊的。我愿意接受那些给我提供更好方法的固执己见的答案™. 首先,关于我的设置: 我的emacs环境是Cocoa emacs 24,主要使用Melpa存储库中的emacs初学者工具包进行设置,并通过package manager添加clojure和nrepl包 我的leiningen 2项目是使用Emacs nrepl.el和leiningen 2默认名称空间?,emacs,clojure,leiningen,Emacs,Clojure,Leiningen,在启动并运行Emacs/Clojure环境时,我现在遇到了我不确定是否正常的行为。特别是,当我启动一个nREPL并编译(C-C-k)我的缓冲区时,我会被放到core.clj文件顶部定义的名称空间之外的其他地方。我应该加上免责声明,我对Clojure和名称空间有点陌生,因此我对这一切的理解可能是模糊的。我愿意接受那些给我提供更好方法的固执己见的答案™. 首先,关于我的设置: 我的emacs环境是Cocoa emacs 24,主要使用Melpa存储库中的emacs初学者工具包进行设置,并通过pack
lein new test clj
建立的
我的项目。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"]])
(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)))))
我的核心.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"]])
(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)))))
我想我应该可以
M-x nrepl插入
)C-C-k
将缓冲区加载到REPLclojure.lang.Compiler$CompilerException:java.lang.RuntimeException:无法解析符号:在此上下文中显示shapefile,编译:(无源代码\u路径:1)
如果,从REPL I第一个类型(在ns`test clj.core中),我是golden。另外,如果我键入(test clj.core/show shapefile),我就设置好了
当我逆时针加载REPL时,我自动地被放入test-clj.core名称空间,这看起来非常方便
那么,我的问题有两个:
只需对您的工作流程进行几处更改:
步骤3比切换到repl并在ns中运行
要短,太棒了!看起来我还可以继续用C-C-k
加载当前缓冲区。C-cmn
似乎是一种魔力。旁白:如何在StackOverflow注释中获得格式良好的emacs键盘快捷键?Ctrlaltdel看起来这可能与教程中的一个错误有关,该错误指出命名空间切换受C-C
C-n
影响,而不是正确的C-C
M-n