Working with SuperCollider in Emacs

Summary

I had much trouble getting the SuperCollider extension to work in Emacs and gave up several times because the default IDE is good enough. I still wanted to edit and evaluate my SC projects like I would for other languages.

I spent, like for everything Emacs related when you don’t know Elisp well, an ungodly amount of time trying to fix that. This post shortly describes what worked for me.

SuperCollider mode for emacs

HowTo

I use a custom distribution of Emacs named Angurgapi because I liked how the little guy looked and I needed a namespace. It’s kind of janky but so is everything else in this bitch of a world.

Those instructions imply Emacs is using both use-package and straight.el for package management.

First in the init.el, or whatever file you want the declaration to be:

;; SuperCollider
(use-package sclang
  :defer t
  :straight (:host github :repo "supercollider/scel" :files ("el/*.el"))
  :config
  (setq sclang-auto-scroll-post-buffer t)
  :bind
  (("C-<return>" . sclang-eval-defun)
   ("C-." . sclang-main-stop)))

Ignore the bind and config blocks to taste, but since muscle memory from SuperCollider IDE already did its work, I’m happy to keep that in Emacs. (I didn’t notice sclang-eval-defun was a thing until I read this thread)

Without the next step, sclang-start won’t go beyond the welcome message and nothing can be evaluated in sclang-mode buffer.

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.01 seconds


*** Welcome to SuperCollider 3.13.0. *** For help type C-c C-y.

While bughunting I found some people had the same issue but the proposed solution didn’t work in my case. Some alternative installation instructions can be found in the issue tracker but appear to be specific to MacOS.

On a Debian 12 install, this is what was required for the extension to work properly on my side:

cp -r ~/.emacs.d/straight/repos/scel/sc/scide_scel/* ~∕.local/share/SuperCollider/Extensions/

Evaluating sclang-start again will open a SuperCollider Workspace buffer and the post buffer will ouput some logs showing the whole thingie is usable this time:

Emacs: Index help topics in 0.459 seconds
Emacs: Built symbol table in 0.0229 seconds
server 'localhost' unresponsive, rebooting ...
'/quit' message sent to server 'localhost'.

Everything else can be learned from the help buffer (C-h m), but the first default binding to learn is C-c C-s, to stop all sound. No time for grace and elegance when you accidentally borked the multiplier of a synth or passed a negative frequency to a filter and there is no limiter on.

I also want to add that you can have a quick overview of the current object’s method signature in the minibuffer by pressing C-c C-m. Completion frameworks like company won’t work here but this is perfectly serviceable.

The Debian package supercollider-emacs worked well when I tried it, so consider installing it if you don’t want to spend more time debugging something like that.