Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paredit curly brace matching in swank-clojure repl

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?

like image 634
pventura Avatar asked Dec 22 '11 00:12

pventura


2 Answers

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)
like image 145
Gert Avatar answered Oct 06 '22 01:10

Gert


Grab Phil Hagelberg's durendal package, which provide some clojure-specific enhancements to slime, then try this snippet:

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

In future, Phil may include the functionality of durendal in swank-clojure itself as an additional lisp payload, at which point the above would become unnecessary.

like image 20
sanityinc Avatar answered Oct 06 '22 00:10

sanityinc