简体   繁体   English

在emacs中运行苹果酒

[英]Running cider-jack-in in emacs

I would like to learn some Clojure, and I'm trying to run REPL from Emacs, but I cannot get it to work. 我想学习一些Clojure,并且试图从Emacs运行REPL,但是我无法使其正常工作。

I have created a basic project with lein . 我已经与lein创建了一个基础项目。 I open the generated file core.clj in Emacs, and when I try to run the REPL from it (by running the cider-jack-in ), I just get the message: 我在Emacs中打开生成的文件core.clj ,当我尝试从中运行REPL时(通过运行cider-jack-in ),我得到的消息是:

Symbol's function definition is void: nil

I have toggled the debug-on-error, and the backtrace (several last lines) is: 我已经切换了错误调试,回溯(最后几行)是:

 Debugger entered--Lisp error: (void-function nil)
   nil(#<buffer core.clj>)
   #[257 "  !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"](#<buffer core.clj>)
   seq-map(#[257 "  !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"] (#<buffer core.clj> #<buffer  *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer  *Minibuf-0*> #<buffer *Messages*> #<buffer  *code-conversion-work*> #<buffer  *Echo Area 0*> #<buffer  *Echo Area 1*>))
   seq-filter(#[257 "r\211q\210\300\301!)\207" [derived-mode-p cider-repl-mode] 3 "\n\n(fn BUFFER)"] (#<buffer core.clj> #<buffer  *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer  *Minibuf-0*> #<buffer *Messages*> #<buffer  *code-conversion-work*> #<buffer  *Echo Area 0*> #<buffer  *Echo Area 1*>))
   cider-repl-buffers()
   cider-find-reusable-repl-buffer(nil "~/Development/languages/clojure/playground/test1/")
   cider-jack-in(nil)

When I run lein run in the terminal, the code runs properly. 当我在终端上运行lein run时,代码正常运行。
Also, when I run lein repl in the terminal, the REPL runs properly with the following info: 另外,当我在终端中运行lein repl时,REPL会使用以下信息正常运行:

nREPL server started on port 62741 on host 127.0.0.1 - nrepl://127.0.0.1:62741
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14

Lein has Cider version 0.14.0, while Emacs has downloaded version 0.15.0. Lein的Cider版本为0.14.0,而Emacs的版本为0.15.0。

Could anyone help me figure out which part of the setup I'm missing, or what I'm doing wrong? 谁能帮我弄清楚我缺少哪一部分设置,或者我做错了什么?

Thanks for the help! 谢谢您的帮助!

EDIT: Bellow is the contents of Emacs init file, with comments removed: 编辑:波纹管是Emacs初始化文件的内容,删除了注释:

(require 'package)
(add-to-list 'package-archives
           '("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
           '("tromey" . "http://tromey.com/elpa/") t)
(add-to-list 'package-archives
           '("melpa" . "http://melpa.milkbox.net/packages/") t)

(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar ido-cur-item nil)
(defvar ido-default-item nil)
(defvar ido-cur-list nil)
(defvar predicate nil)
(defvar inherit-input-method nil)

(defvar my-packages
  '(paredit
    clojure-mode
    clojure-mode-extra-font-locking
    cider
    ido-ubiquitous
    smex
    projectile
    rainbow-delimiters
    tagedit
    magit))

(if (eq system-type 'darwin)
    (add-to-list 'my-packages 'exec-path-from-shell))

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

(add-to-list 'load-path "~/.emacs.d/vendor")
(add-to-list 'load-path "~/.emacs.d/customizations")

(load "shell-integration.el")
(load "navigation.el")
(load "ui.el")
(load "editing.el")
(load "misc.el")
(load "elisp-editing.el")
(load "setup-clojure.el")
(load "setup-js.el")

here's my lein debugging checklist: 这是我的lein调试清单:

  • remove any meniton of cider-nrepl from ~/.lein/profiles.clj ~/.lein/profiles.clj删除任何苹果酒-nrepl的~/.lein/profiles.clj
  • run lein repl from a terminal, then cider-connect to localhost from emacs 从终端运行lein repl ,然后从emacs cider-connectlocalhost
  • run lein upgrade 运行lein升级
  • upgrade to the latest version of the cider emacs package 升级到苹果酒emacs软件包的最新版本
  • ask in the cider channel on clojure slack before submitting bug reports. 在提交错误报告之前,在苹果酒频道中询问Clojure松弛情况。

It used to be required to add cider's nrepl middleware to your lein profile to get it included on the classpath when lein start up. 以前需要将苹果酒的nrepl中间件添加到您的lein配置文件中,以便在lein启动时将其包含在类路径中。 Now cider does this automatically and chooses the matching version on it's own. 现在,苹果酒会自动执行此操作,并自行选择匹配的版本。 Many people are following instructions from when this was a manual process and run into problems like this, so check that first. 许多人都遵循这是手动过程的说明,却遇到类似问题,因此请先检查一下。

Remove your ~/.emacs.d directory and install spacemacs instead 删除~/.emacs.d目录并安装spacemacs

git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

Once you run Emacs with the new spacemacs ~/.emacs.d directory, you can simply open up a Clojure file and spacemacs will load in the Clojure layer for you. 使用新的spacemacs〜 ~/.emacs.d目录运行Emacs之后,只需打开一个Clojure文件,spacemacs就会为您加载Clojure层。

More details can be found at spacemacs.org and in this tutorial on clojure development with spacemacs https://practicalli.github.io/spacemacs/ 可以在spacemacs.org以及本教程中使用spacemacs https://practicalli.github.io/spacemacs/进行的Clojure开发中找到更多详细信息。

So the error appears to be in cider-client.el at line 102 https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L99 . 因此错误似乎是在cider-client.el中的第102行https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L99中 I've got the whole defun posted below: 我已经在下面发布了整个defun:

(defun cider-repl-buffers ()
  "Return the list of REPL buffers."
  (seq-filter
   (lambda (buffer)
     (with-current-buffer buffer (derived-mode-p 'cider-repl-mode)))
   (buffer-list)))

Can you visit this file in your CIDER copy and ensure that this definition looks like this. 您可以在CIDER副本中访问此文件,并确保该定义如下所示吗? This code is just looking for repl buffers and is filtering the buffers that emacs knows about. 这段代码只是在寻找repl缓冲区,并且正在过滤emacs知道的缓冲区。

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

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