我在Windows 7上使用emacs 24,並且安裝了technomancy's clojure-mode以及paredit 23測試版。我從我的leiningen項目加載源文件並使用clojure-jack-in獲取repl。問題是雖然在Clojure模式和repl中都啓用了paredit,但只有在源文件中,花括號纔會在repl中匹配。在swank-clojure repl中匹配的paredit大括號
我怎樣才能讓它匹配repl中的大括號呢?
我在Windows 7上使用emacs 24,並且安裝了technomancy's clojure-mode以及paredit 23測試版。我從我的leiningen項目加載源文件並使用clojure-jack-in獲取repl。問題是雖然在Clojure模式和repl中都啓用了paredit,但只有在源文件中,花括號纔會在repl中匹配。在swank-clojure repl中匹配的paredit大括號
我怎樣才能讓它匹配repl中的大括號呢?
添加以下到我.emacs文件,但這招對我來說(我沒有這個發明我自己,這是一個片段我在網上找到的地方 - 但我不記得在哪裏):
(defun setup-slime-repl-paredit()
(define-key slime-repl-mode-map
(kbd "DEL") 'paredit-backward-delete)
(define-key slime-repl-mode-map
(kbd "{") 'paredit-open-curly)
(define-key slime-repl-mode-map
(kbd "}") 'paredit-close-curly)
(modify-syntax-entry ?\{ "(}")
(modify-syntax-entry ?\} "){")
(modify-syntax-entry ?\[ "(]")
(modify-syntax-entry ?\] ")[")
(modify-syntax-entry ?~ "' ")
(modify-syntax-entry ?, " ")
(modify-syntax-entry ?^ "'")
(modify-syntax-entry ?= "'"))
(add-hook 'slime-repl-mode-hook 'setup-slime-repl-paredit)
(add-hook 'slime-repl-mode-hook 'enable-paredit-mode)
搶菲爾Hagelberg的durendal package,其中 提供一些具體的Clojure,增強粘液,那就試試這個片斷:
(require 'durendal)
(durendal-enable t)
(defun slime-clojure-repl-setup()
(when (string-equal (slime-lisp-implementation-name) "clojure")
(set-syntax-table clojure-mode-syntax-table)
(setq lisp-indent-function 'clojure-indent-function)))
(add-hook 'slime-repl-mode-hook 'slime-clojure-repl-setup)
今後,菲爾可包括在自吹,Clojure的本身迪朗達爾的功能作爲額外的口齒不清的淨荷,此時上述將變得不必要。
我嘗試安裝durendal,然後需要我安裝煤泥和煤泥複製。即使安裝完所有的代碼並添加了上面的代碼,它仍然沒有進行大括號的匹配。 – pventura 2011-12-23 04:30:11
奇數。我假設你重新啓動了你的Emacs? Durendal提供了與上面提供的@gertalot完全相同的鉤子函數。但既然你已經有了這個解決方案,你就一切都準備好了。爲了記錄,我的emacs配置Clojure特定的塊在這裏:https://github.com/purcell/emacs.d/blob/master/init-clojure.el – sanityinc 2011-12-23 08:41:36
@sanityinc - 是我的片段其實*從*迪朗達爾?我不知道我在哪裏找到它,但如果是這樣,我會編輯並添加信用。 – Gert 2011-12-23 09:52:36
工作,謝謝! – pventura 2011-12-23 04:29:20