在 Leiningen 项目中通过 Emacs 使用 Java

发布于 2025-01-07 18:40:14 字数 836 浏览 1 评论 0原文

关于 SO 有很多密切相关的问题,仅举其中一些:

我的问题的不同之处在于,我想知道如何在混合 Clojure/Java Leiningen 项目中直接从 Emacs 使使用 Java 与使用 Clojure 一样简单。

我的意思是可以(按优先级顺序):

  • lein javac 从 shell 编译它)
  • 直接从 Emacs 编译 Java 代码(注意:可以使用 Java 的代码完成JDEE 等工具提供此功能,但它是独立的不关心的工具Leiningen 项目设置)
  • 调试 Java 代码

There's plenty of closely related questions on SO, just to name some of them:

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.

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)
  • use code completion for Java (tools like JDEE provide this feature, but it is separate tool that doesn't concern Leiningen project setup)
  • debug Java code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪意 2025-01-14 18:40:14

查看 Emacs LSP 项目。它提供对 Java 的支持。

Check out the Emacs LSP project. It provides support for Java.

恍梦境° 2025-01-14 18:40:14

我想尝试自动完成,但我还没有做到。

考虑到 leiningen/Clojure 的工作方式,我不确定编译有多容易。当你编译Java代码时,你是否必须重新启动repl/应用程序才能让JVM重新加载它?

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. When you compile Java code, don't you have to restart the repl/application for the JVM to reload it anyway?

初见终念 2025-01-14 18:40:14

Malabar-mode 是废弃软件,但我认为它正在达到您想要的功能级别。在我看来,基于协进程的自动完成引擎应该可以通过 CEDET、leiningen 和 swank-clojure 实现,但我有一份日常工作和副业......

Malabar-mode is abandonware but I think it's shooting for the level of functionality that you want. 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...

幸福%小乖 2025-01-14 18:40:14

可能不是您想要的,但这应该可以为您处理第 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*")))

Probably not what you wanted exactly, but this should handle bullet 1 for ya:

(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*")))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文