I would like rainbow parens for editing Clojure in Emacs and since VI does this I assume that in Emacs it should be something like M-x butterfly or something :)
3 Answers
This is an old question now, but I recently wrote RainbowDelimiters mode for this. It's a 'rainbow parens'-type mode which colors all parens, brackets and braces, made with Clojure programming in mind.
It highlights the whole buffer, not just the parens surrounding point.
The most important thing is that it's FAST - all the other rainbow paren modes I've tried slow down editing (especially scrolling) quite a lot. I put significant effort into profiling and optimizing it so doesn't have any noticeable impact on scrolling/editing speed.
You can find info about it at the EmacsWiki page, and the mode itself is at rainbow-delimiters.el.

- 20,575
- 8
- 83
- 77

- 820
- 10
- 7
-
3+1 for making it file-wide, fast, easy to administer the settings and providing clear instructions on the EmacsWiki. – semperos Mar 21 '11 at 14:41
-
I made a few important changes today, so you'll want to go download the latest version. Thanks for the comments. :) – Jeremy Rayman Mar 22 '11 at 20:24
-
Do you keep a changelog? What are the new features? – semperos Mar 22 '11 at 21:00
-
Several changes (the changelog is in the file). I've ticked everything off my list except XML/HTML tag highlighting. – Jeremy Rayman Mar 25 '11 at 14:43
-
this is EXACTLY what i have been looking for! thank you very much! – Arthur Ulfeldt Mar 29 '11 at 19:06
-
Is RainbowDelimiters compatible with paredit? Can the two modes be used together? – SyntaxT3rr0r Sep 27 '11 at 16:25
I'm using highlight-parentheses-mode
from the script mquander mentioned. It doesn't provide much of a rainbow effect out of the box, but it is customisable:
(setq hl-paren-colors
'(;"#8f8f8f" ; this comes from Zenburn
; and I guess I'll try to make the far-outer parens look like this
"orange1" "yellow1" "greenyellow" "green1"
"springgreen1" "cyan1" "slateblue1" "magenta1" "purple"))
I believe I've lifted the actual colours from Vimclojure. Note that Vimclojure highlights all parentheses in the file, whereas with highlight-parentheses-mode
only the parens which actually contain the point will be highlighted (and only a limited number of levels). I happen to find this behaviour useful, but it is perhaps a bit lacking in the prettiness area in comparison with the Vimclojure way.
I now notice I've never gotten 'round to fixing those outer paren colours actually... Maybe I will now that you've reminded me about it.

- 83,634
- 13
- 201
- 212
-
Gorgeous. I really like this. Thanks you. Is there a way to turn it on automatically for any lisp file? – John Lawrence Aspden Mar 10 '10 at 15:40
-
1Glad to hear that. :-) And yes, you can include it in the default setup for Lisp editing by placing something like `(add-hook 'clojure-mode-hook (lambda () (highlight-parentheses-mode t) (paredit-mode t)))` in your `~/.emacs`. You can do the same thing with `slime-repl-mode-hook`, `emacs-lisp-mode-hook` etc., although in that case you'll probably want to factor out the `lambda` to a named function and use something like `(add-hook 'clojure-mode-hook #'my-lisp-setup)`. – Michał Marczyk Mar 10 '10 at 20:34
-
5Um, somehow `paredit` slipped in there... Which is ok, as that is the Holy Grail of Lisp editing. Every Lisper needs to try it out, and if you're already using Emacs it's an *absolute must*. – Michał Marczyk Mar 10 '10 at 20:36
-
Awesome. Thank you very much! I wish I could upvote you again. – John Lawrence Aspden Mar 11 '10 at 13:27
-
The parentheses are too narrow(default), and you have to be in that code block. [rainbow-delimiters](https://github.com/Fanael/rainbow-delimiters) is recommended, the colors of parentheses are more distinct. – CodyChan Nov 28 '14 at 08:01
Here's a mode for that which I have used in the past briefly. Here's another one which I haven't tried.

- 70,359
- 14
- 95
- 123