开发者

How to make ensime work in windows?

I'm new to emacs and I want to use ensime in Windows. I had a try but it doesn't work. It seems that it doesn't work because there is a *nix format file named "\ensime\bin\server.sh" . Very appreciate if someone give me some tips.

EDIT: I follow VonC's suggestion but it doesn't work perfect. I'm sure I have missed something.

How to make ensime work in windows?

I have installed emacs23.1 in dir D:\Dev\emacs-23.1 ,scala-mode in D:\Dev\emacs-23.1\scala-mode and ensime in D:\Dev\emacs-23.1\ensime.

Here is my .emacs file content:

;;禁用工具栏
(tool-bar-mode nil)

;;显示行号
(global-linum-mode t)

;;使用scala mode
(add-to-list 'load-path "D:/Dev/emacs-23.1/scala-mode/")
(require 'scala-mode)

(add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode))
(add-to-list 'load-path "D:/Dev/emacs-23.1/ensime/src/elisp/")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)

and here is my D:\Dev\emacs-23.1\ensime.ensime file content:

(
:server-root "D:/Dev/emacs-23.1/ensime/"
:server-cmd  "D:/Dev/emacs-23.1/ensime/bin/server.bat"
:server-host "localhost"
:server-env ()

:project-package "com.ensime"
:source ("src")
:exclude-source ()
:classpath ("lib/jnotify/jnotify-0.93.jar"
        "lib/scala/scala-library.jar"
        "lib/scala/scala-compiler.jar")
)

and here is my D:\Dev\emacs-23.1\ensime\bin\server.bat file content:

@echo off
set PORT_FILE=%1
set CLASSPATH=D:\Dev\emacs-23.1\e开发者_StackOverflow中文版nsime\lib\jnotify\jnotify-0.93.jar;D:\Dev\emacs-23.1\ensime\lib\scala\scala-library.jar;D:\Dev\emacs-23.1\ensime\lib\scala\scala-compiler.jar;D:\Dev\emacs-23.1\ensime\dist\ensime.jar
java -classpath %CLASSPATH% -Djava.library.path=D:\Dev\emacs-23.1\ensime\lib\jnotify com.ensime.server.Server %PORT_FILE%

alt text http://www.turboimagehost.com/p/3350328/3769883.PNG.html


We've recently merged a few changes that help with supporting windows. ENSIME now includes a bin/server.bat file. Also, classpath construction is now using the platform-appropriate path separator.


It should be a simple matter of porting the shell script in DOS in a server.bat:

@echo off
set PORT_FILE=%1
set CLASSPATH=lib\scala\scala-library.jar;lib\scala\scala-compiler.jar;dist\ensime.jar
java -classpath %CLASSPATH% -Djava.library.path=lib\jnotify com.ensime.server.Server %PORT_FILE%

to be executed from the ensime directory.

a more independent version (executable from any directory) would be:

@echo off
set t=%~dp0
set adp0=%t::\=:\"%"
cd %adp0%..
set CLASSPATH=lib\scala\scala-library.jar;lib\scala\scala-compiler.jar;dist\ensime.jar
java -classpath %CLASSPATH% -Djava.library.path=lib\jnotify com.ensime.server.Server %PORT_FILE%

Even if ensime is in a path with spaces in it, it should work.

  • %~dp0 is the full path of the server.bat (path with potential spaces in it)
  • set adp0=%t::\=:\"%" will add double quotes around that path
  • %adp0%.. will refer to the ensime directory


Note that if you build from git clone on windows, you need modify server.bat and remove .\dist\ before every jar file. Also, you will get an error when the dist directory is being tarred. This can be ignored. ensime is an active project and Aemon Cannon pushes updates almost daily. The latest version has improved a lot when compared to a month ago. So, it is a good idea to install from git clone. See instructions in http://aemon.com/file_dump/ensime_manual.html To build call

sbt update

sbt dist

Ignore tar errors. Fix server.bat as mentioned above Though there are some serious bugs, it is a godsend for people who like emacs and scala. You don't need eclipse. And Aemon fixes bugs quickly. It works fine for android projects. All I had to do was to add :compile-jars ("d:/software/android-sdk-windows/platforms/android-4/android.jar") to .ensime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜