Setup SuperCollider in Emacs

While SuperCollider IDE is more convenient than any other text editor, as it is tailor-made solution for editing sclang, I like to use Emacs for interactive coding. This post will demonstrate how to configure Emacs with SC3. The solution is based on this blog post by Gene De Lisa. This setup assumes that you have install SC3 using the pre-build dmg image file.

Get the resources

Emacs Lisp files

Make sure to get the Emacs Lisp files for SC3 integration. You can find these files in Github SuperCollider page. To do so, just git clone supercollider repository to your computer.


cd $HOME
mkdir sources
cd sources
git clone https://github.com/supercollider/supercollider.git

Now you can find the *.el files in this path: ~/sources/supercollider/editors/scel/el.

SC3 class files

The SC3 class files are in this path: ~/sources/supercollider/editors/scel/sc. Copy all *.sc in your Class Library Extensions (~/Library/Application Support/SuperCollider/Extensions).

Emacs init file

Go to your Emacs init and add the following code.


(add-to-list 'load-path "~/sources/supercollider/editors/scel/el")
(require 'sclang)

(setenv "PATH" (concat (getenv "PATH") ":/Applications/SuperCollider:/Applications/SuperCollider/SuperCollider.app/Contents/MacOS"))
(setq exec-path (append exec-path '("/Applications/SuperCollider"  "/Applications/SuperCollider/SuperCollider.app/Contents/MacOS" )))
  • NOTE 1: In the blog post by Gene De Lisa the environment path for Emacs is Applications/SuperCollider/SuperCollider.app/Contents/Resources. I noticed that sclang executable has been moved to MacOS folder so I changed the path.
  • NOTE 2: When you reload your Emacs init configuration you will get an error related to sclang-vars.el. To handle this error, rename sclang-vars.el.in to sclang-vars.el and reload your Emacs init configuration. This aforementioned file is located here: ~/sources/supercollider/editors/scel/el.

Run sclang in Emacs

Open Emacs and run M-x sclang-start. Using C-c C-c you can execute a line of code or a highlithed region, with C-c C-d you can execute a region enclosed in parens, if you place the cursor next the rightmost parenthesis.