When I open a Clojure file, and I'm not using Paredit, I expect to be able to type unbalanced parentheses and brackets. I can type any of these characters: ()[]{, balanced on not. But if I try to type a } that has no matching start {, it won't let me.

Why is this? And how do I turn it off? I expect this type of behavior in paredit-mode, but outside of that mode I want to be free to type any characters.

GNU Emacs 25.3.1 on macOS. Clojure mode 5.8.2.

  • 1
    Do you see this if you start Emacs with emacs -Q (no init file)? If so, please provide a step-by-step recipe to reproduce it. If not, bisect your init file to find the culprit. – Drew Jan 7 at 16:07
  • 1
    I can't reproduce this in Emacs 27.0.50 and Clojure mode 20190105 from Melpa. It's possible it's a problem with the particular versions you're using, but more likely a problem in your init as @Drew suggests – Tyler Jan 7 at 18:39
  • 2
    Okay, thanks. I just noticed that it doesn't happen until I enable paredit-mode and then try to turn it off. So it seems like some remnant of paredit stays around and prevents the } character. – Rob N Jan 7 at 20:08

The problem only occurs after you've turned paredit on and off: this is because clojure-mode adds a hook to paredit-mode, and that hook adds some paredit-mode keybindings to the clojure-mode map.

In other words, turning on paredit-mode makes changes to clojure-mode keybindings and those changes stick even if you turn off paredit-mode. The really surprising thing is if you edit a file in clojure-mode, then use paredit-mode in a different file, returning to the clojure file you'll get the paredit keybindings for "{" and "}".

That's arguably a bug in clojure-mode.


You can insert unbalanced parentheses with C-q (quoted-insert).

If you really don't want Clojure Mode to bind { and } to ParEdit keys, here is a work-around:

(add-hook 'clojure-mode-hook
          (lambda () (remove-hook 'paredit-mode-hook #'clojure-paredit-setup)))

(You need to restart Emacs, since once clojure-paredit-setup runs, the keys is set)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.