10

我在 Windows 7 上使用 emacs 24 并安装了 technomancy的 clojure-mode以及 paredit 23 beta。我从我的 leiningen 项目中加载源文件并使用 clojure-jack-in 获得一个 repl。问题是,虽然在 Clojure 模式和 repl 中都启用了 paredit,但大括号在 repl 中仅在源文件中不匹配。

我怎样才能让它也匹配 repl 中的大括号?

4

2 回答 2

6

我在我的 .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)
于 2011-12-22T11:06:35.423 回答
1

获取 Phil Hagelberg 的durendal 包,它提供了一些特定于 clojure 的 slime 增强功能,然后试试这个片段:

(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)

将来,Phil 可能会在 swank-clojure 本身中包含 durendal 的功能,作为额外的 lisp 有效负载,此时上述内容将变得不必要。

于 2011-12-22T16:54:30.113 回答