I am quite new to emacs, but already convinced of the power of this tool.
I would be very interested if you could share some configurations (.el files) or tips that go with super-collider.
I am sure others would be curious as well !
I don’t really know what to add more, if there are additional tweaks that worth it and goes well with it.
Curiously, I systematically have a bug when working in emacs with a .sc file: After calling sclang-start then booting the server, when navigating through a document, the mini buffer throws me an error SCLang: Error in command handler, which only goes away when calling the function sclang-ac-mode (the auto complete mode).
When I add the package sclang-extension, I got other kind of errors when sclang-ac-mode is activated. When I type some code into the buffer, or simply move the cursor around the text, for example
{SinOsc.ar(440);}.play
the post window continuously throws me errors that look like
ERROR: Parse error
in interpreted text
line 1 char 30:
try { Emacs.message((({SinOsc).class).asCompileString) } {|err| err;}
^
-----------------------------------
opening bracket was a '{', but found a ')'
in interpreted text line 1 char 30
ERROR: syntax error, unexpected BADTOKEN, expecting '}'
in interpreted text
line 1 char 30:
try { Emacs.message((({SinOsc).class).asCompileString) } {|err| err;}
^
-----------------------------------
ERROR: Command line parse failed
ERROR: Class not defined.
in interpreted text
line 1 char 37:
try { Emacs.message((Meta_Meta_SinOsc.methods.collect {|m| [m.name, m.argList, m.ownerClass] }).asCompileString) } {|err| err;}
Any idea?
I reduced my configuration in my init.el to these simple lines, and I still get the errors
I did some digging, and found that the those error messages shown in the consol come when either of the following three modes are activated: sclang-ac-mode, sclang-doc-mode, sclang-extensions-mode. It looks like they appear when those modes should enter in action. For example, when finishing typing SinOsc., putting the last dot triggers the following error in the post window:
ERROR: Class not defined.
in interpreted text
line 1 char 37:
try { Emacs.message((Meta_Meta_SinOsc.superclasses).asCompileString) } {|err| err;}
The only solution so far is to disable sclang-extension-mode, and all the other modes.
Just using this thread to revive it and ask a related question.
I played around with emacs and SC today and I got it running, including simple auto completion.
As I want to learn SC I thought it’s a good idea to also get used to emacs (or nvim). Meanwhile I prefer emacs. The configuration of emacs turned out to be simpler in my opinion.
Then I adjusted the paths in my init.el file (see below). In the default configuration the post window was opened on the bottom and with the help of this forum and chatGPT I was able to open it on the right like in scIDE.
The help browser can be opened with C-c h .
For auto completion I installed company with the melpa package manager. This worked out of the box. The init file was adjusted with chatGPT.
Two things I’m currently still missing:
In the default scIDE I get suggestions for the arguments after entering e.g. SinOsc.ar( . Is this also working in emacs? I watched some youtube videos (e.g. https://www.youtube.com/watch?v=n01nAN4I8wM ) and this does not seem to be the case. edit: also this works. With C-c RET it is shown on the bottom of the page.
Is it possible to execute a code block embraced in (…) with one command?
edit: it’s working with C-M-x (Ctrl + Alt + x)
BTW. Installing the emacs extensions from here: GitHub - chrisbarrett/sclang-extensions: UNMAINTAINED made the configuration unusable. This seems to be outdated meanwhile or I just did it wrong. After deleting the package it worked again.
;; ------------------------
;; Package Manager Setup
;; ------------------------
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;; Ensure use-package is installed
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;; ------------------------
;; Startup UI
;; ------------------------
(setq inhibit-startup-screen t) ;; disable welcome screen
(setq initial-scratch-message "") ;; empty scratch buffer
;; ------------------------
;; Theme
;; ------------------------
(use-package dracula-theme
:ensure t
:config
(load-theme 'dracula t))
;; ------------------------
;; Company-mode (autocomplete)
;; ------------------------
(use-package company
:ensure t
:hook (after-init . global-company-mode)
:config
(setq company-idle-delay 0.2 ;; show completions after 0.2 sec
company-minimum-prefix-length 1))
;; Configure company for SuperCollider specifically
(add-hook 'sclang-mode-hook
(lambda ()
(company-mode 1)
(setq-local company-backends
'(company-capf company-dabbrev-code))
(setq sclang-autocomplete-enable t)))
;; ------------------------
;; SuperCollider Emacs Integration
;; ------------------------
;; Adjust this path to where you installed the SC Quark 'scel'
(add-to-list 'load-path "~/.local/share/SuperCollider/downloaded-quarks/scel/el")
(require 'sclang)
;; Associate .scd and .sc files automatically
(add-to-list 'auto-mode-alist '("\\.scd$" . sclang-mode))
(add-to-list 'auto-mode-alist '("\\.sc$" . sclang-mode))
;; Move PostBuffer to right side window
(add-to-list 'display-buffer-alist
'("\\*SCLang:PostBuffer\\*"
(display-buffer-in-side-window)
(side . right)
(window-width . 30)))
;; ------------------------
;; Custom-set Variables (generated by Emacs, keep as is)
;; ------------------------
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(company dracula-theme use-package)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)