简体   繁体   English

在 Leiningen 项目中使用 Emacs 中的 Java

[英]Working with Java from Emacs within Leiningen project

There's plenty of closely related questions on SO, just to name some of them:关于 SO 有很多密切相关的问题,仅举出其中一些:

The difference of my questions is that I want to know how to make working with Java as easy as with Clojure right from Emacs within mixed Clojure/Java Leiningen project.我的问题的不同之处在于,我想知道如何在混合 Clojure/Java Leiningen 项目中直接从Emacs使用 Java 像使用 Clojure 一样简单

What I mean is possibility to (in order of priority):我的意思是有可能(按优先顺序):

  • compile Java code right from Emacs (note: it is possible to compile it from the shell with lein javac )直接从 Emacs编译Java 代码(注意:可以使用lein javac从 shell 编译它)
  • use code completion for Java (tools like JDEE provide this feature, but it is separate tool that doesn't concern Leiningen project setup)使用 Java 的代码完成JDEE 等工具提供此功能,但它是独立的工具,与 Leiningen 项目设置无关)
  • debug Java code调试Java 代码

Check out the Emacs LSP project .查看Emacs LSP 项目 It provides support for Java.它提供对 Java 的支持。

Probably not what you wanted exactly, but this should handle bullet 1 for ya:可能不是你想要的,但这应该为你处理子弹 1:

(defun lein-javac (&optional PROJECT-DIR)
  (interactive)
  (let ((output-buffer (progn
                         (with-output-to-temp-buffer "*lein-javac*" nil )
                         (select-window (get-buffer-window "*lein-javac*"))
                         (read-only-mode 'toggle)
                         (window-buffer)) ))
   (shell-command (concat "cd " (or PROJECT-DIR default-directory) 
                         " && lein javac &") "*lein-javac*")))

I want to try auto complete but I haven't gotten to it yet.我想尝试自动完成,但我还没有做到。

Given the way leiningen/Clojure work anyway, I'm not sure how easy you could make compilation.考虑到 leiningen/Clojure 的工作方式,我不确定您可以轻松进行编译。 When you compile Java code, don't you have to restart the repl/application for the JVM to reload it anyway?编译Java代码的时候,难道不用重启repl/application让JVM重新加载吗?

Malabar-mode is abandonware but I think it's shooting for the level of functionality that you want. Malabar-mode是一种废弃软件,但我认为它正在为您想要的功能水平而努力。 It seems to me that a coprocess-based autocompletion engine should be feasible with CEDET, leiningen, and swank-clojure, but I have a day job and side work...在我看来,基于协进程的自动完成引擎对于 CEDET、leiningen 和 swank-clojure 应该是可行的,但我有一份日常工作和副业......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM