我对Emacs和Clojure都是全新的,并希望设置提示和语法高亮显示,类似于视频here。我安装了:
...然后在Emacs内并通过Marmalade安装以下软件包:
我最关心的问题是这些主要/次要模式如何相互作用,是否有“正确”的方式来设置这些东西?
我的小想法问题是如何获得漂亮的语法突出显示和代码提示?
谢谢!
答案 0 :(得分:3)
查看Emacs Live,这是Sam Aaron创建的完整emacs配置。他对Clojure进行了编码,所以这包括电池和#34;设置非常适合Clojure编码。
https://github.com/overtone/emacs-live
克隆了这个并按照说明启动并运行 Clojure,nrepl,git等等。
答案 1 :(得分:1)
我列出了我的设置。有些东西是多余的,因为我没有 用Clojure写了一段时间,但我检查了它仍然有效。
clojure
启动nrepl。
您可能在project.clj
位于相应目录中时遇到问题,
但是你应该弄清楚这一点。foo.clj
。nrepl-load-file
顺便说一句,这是将文件加载到劣质流程的规范快捷方式。
它适用于Common Lisp,Python等。以下是设置代码:
(require 'clojure-mode)
(defun set-syntax-parens ()
"highlight []{} etc."
(interactive)
(modify-syntax-entry ?[ "(]")
(modify-syntax-entry ?] ")[")
(modify-syntax-entry ?{ "(}")
(modify-syntax-entry ?} "){"))
(defvar clojure.jars '("clojure-1.3.0.jar"
"swank-clojure-1.4.2.jar"
"clojure-contrib-1.2.0.jar"))
(defvar clojure.jars.d (concat dropbox.d "source/clojure/lib/"))
(defvar clojure.classpath
(apply #'concat
(mapcar (lambda (jar) (concat clojure.jars.d jar path-separator))
clojure.jars)))
(setq clojure.classpath
(concat clojure.classpath
dropbox.d "source/clojure/include/"
path-separator))
;;;###autoload
(defun clojure ()
(interactive)
(nrepl-jack-in))
(defvar clojure-server-cmd
(concat "java -Xss4096k -cp " clojure.classpath " clojure.main &"))
(add-hook 'clojure-mode-hook
(lambda()
(set-syntax-parens)))
(require 'nrepl)
(add-hook 'nrepl-mode-hook
(lambda()
(define-key nrepl-mode-map (kbd "C-l") 'nrepl-clear-buffer)))
答案 2 :(得分:1)
这是my favorite emacs config的执行部分:
(when (not package-archive-contents)
(package-refresh-contents))
;; Add in your own as you wish:
(defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings clojure-mode
nrepl auto-complete ac-nrepl org rainbow-delimiters)
"A list of packages to ensure are installed at launch.")
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(require 'ac-nrepl)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'nrepl-mode))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'nrepl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'nrepl-interaction-mode-hook 'set-auto-complete-as-completion-at-point-function)
(define-key nrepl-interaction-mode-map (kbd "C-c C-d") 'ac-nrepl-popup-doc)
(add-hook 'prog-mode-hook 'auto-complete-mode)
(add-hook 'nrepl-interaction-mode-hook
'nrepl-turn-on-eldoc-mode)
(add-hook 'nrepl-mode-hook 'paredit-mode)
这在任何地方都会打开paredit-mode,这需要一些时间来习惯,尽管它完全值得,因为 paredit并使得使用Clojure更有趣。至少一旦你掌握了啜饮和扒手的话