本文介绍了paredit卷曲大括号匹配在swank-clojure repl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7上使用emacs 24,并已经安装了以及paredit 23 beta。我从我的leiningen项目加载源文件,并使用clojure-jack-in获取一个副本。问题是,尽管在Clojure模式和repl中都启用了paredit,但是curl大括号在源文件中只能在repl中匹配。



我如何得到它在复制中匹配大括号?

解决方案

我将以下内容添加到我的.emacs文件中,我没有发明自己,这是我在网路上找到的一段代码片段,但是我记不起来了):

 (defun setup-slime-repl-paredit()
(define-key slime-repl-mode-map
(kbdDEL)'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?='))

(add-hook'复制模式挂钩'setup-slime-repl-paredit)

(add-hook'slime-repl-mode-hook'enable-paredit-mode)


I am using emacs 24 on Windows 7 and have installed technomancy's clojure-mode along with paredit 23 beta. I load the source file from my leiningen project and get a repl using clojure-jack-in. The problem is that while paredit is enabled in both Clojure mode and the repl, curly braces are not matched in the repl only in source files.

How can I get it to match braces in the repl as well?

解决方案

I added the following to my .emacs file, that does the trick for me (I did not invent this myself, it's a snippet I found somewhere online - but I can't remember where):

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

这篇关于paredit卷曲大括号匹配在swank-clojure repl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:07