2021-07-25 23:55:00 +00:00
# scel - sclang-mode for emacs
2009-01-02 19:06:25 +00:00
2013-06-29 17:13:38 +00:00
SuperCollider/Emacs interface
2021-07-25 23:55:00 +00:00
## Installation
2013-07-01 15:01:42 +00:00
2021-08-16 00:20:18 +00:00
There are 3 options for installation:
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
1. Using SuperCollider Quarks (recommended)
2022-07-30 17:15:38 +00:00
2. Using an Emacs package manager
3. From debian package `supercollider-emacs`
4. From source
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
Option #1 is the best cross-platform option, and is recommended. Whatever option
2021-09-04 13:46:59 +00:00
you choose, *make sure not to mix installation methods* . In particular, do not
2021-08-20 00:53:11 +00:00
install the Quark if you already have the supercollider-emacs package or if you
compiled SuperCollider with the `-DSC_EL=ON` option. Otherwise you will get an
error from SuperCollider about duplicated classes.
2021-08-16 00:20:18 +00:00
2021-08-20 00:53:11 +00:00
### Install Option 1: SuperCollider's own package manager
2021-08-16 00:20:18 +00:00
The repository contains two subprojects. `/el` contains the emacs-lisp
2021-08-20 00:53:11 +00:00
implementation. `/sc` contains the SuperCollider code required to
implement the Emacs interface. SuperCollider has its own package system
called Quarks, which we can use to install both halves.
2021-08-16 00:20:18 +00:00
2021-08-20 00:53:11 +00:00
Evaluate this code in the SuperCollider GUI by pasting it and pressing
shift+enter:
2013-07-01 15:01:42 +00:00
2021-07-25 23:55:00 +00:00
``` supercollider
Quarks.install("https://github.com/supercollider/scel");
```
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
The scel repository will be downloaded to your local file system and the path
2021-09-04 16:39:05 +00:00
will be added to your currently used `sclang_conf.yaml` file. (You can find its
2021-08-20 00:53:11 +00:00
location by evaluating `Platform.userConfigDir` )
2021-08-16 00:20:18 +00:00
2021-08-20 00:53:11 +00:00
Next, find out where scel was installed. You will use this install-path in your
emacs config.
2021-08-16 00:20:18 +00:00
2021-08-20 00:53:11 +00:00
``` supercollider
Quarks.folder.postln;
2018-03-30 02:22:31 +00:00
2021-09-04 13:46:59 +00:00
// -> /Users/< username > /Library/Application Support/SuperCollider/downloaded-quarks
2013-07-01 15:13:24 +00:00
```
2021-08-16 00:20:18 +00:00
2021-08-20 00:53:11 +00:00
Now in your emacs config, add the `/el` subdirectory to your load path
2021-07-25 23:55:00 +00:00
``` emacs-lisp
2021-08-16 00:20:18 +00:00
;; in ~/.emacs
2021-08-20 00:53:11 +00:00
;; Paste path from above, appending "/scel/el"
2021-09-04 13:46:59 +00:00
(add-to-list 'load-path "/Users/< username > /Library/Application Support/SuperCollider/downloaded-quarks/scel/el")
2013-07-01 13:02:18 +00:00
(require 'sclang)
```
2021-08-16 00:20:18 +00:00
#### On macOS
2021-07-25 23:55:00 +00:00
2021-08-16 00:20:18 +00:00
If `sclang` executable is not on your path, you may need to add it to your
exec-path.
2021-07-25 23:55:00 +00:00
``` emacs-lisp
2021-08-20 00:53:11 +00:00
;; in ~/.emacs
2021-07-25 23:55:00 +00:00
(setq exec-path (append exec-path '("/Applications/SuperCollider.app/Contents/MacOS/")))
2013-07-01 13:02:18 +00:00
```
2009-01-02 19:06:25 +00:00
2022-07-30 17:15:38 +00:00
### Install Option 2: Emacs package manager
2021-08-20 00:53:11 +00:00
2022-07-30 17:15:38 +00:00
The `sclang` package can be installed from [MELPA ](https://melpa.org/#/sclang ) and configured with [use-package ](https://github.com/jwiegley/use-package ).
It's possible to install with
2021-08-20 00:53:11 +00:00
[straight.el ](https://github.com/raxod502/straight.el ),
[use-package ](https://github.com/jwiegley/use-package ),
[doom ](https://github.com/hlissner/doom-emacs ), etc. Instructions for doing so
are beyond the scope of this README, but note that `autoloads` are implemented
for entry-point functions so if you like to have a speedy start-up time you can
use the `:defer t` option.
2022-07-30 17:15:38 +00:00
### Install Option 3: Debian package
2021-08-16 00:20:18 +00:00
There is a debian package which provides emacs integration called
`supercollider-emacs` . Option #1 will likely be more recent, but
if you prefer you can install the package with:
``` shell
sudo apt install supercollider-emacs
```
2022-07-30 17:15:38 +00:00
### Install Option 4: Installing from source
2013-07-01 15:01:42 +00:00
2021-08-16 00:20:18 +00:00
If you are building SuperCollider from source, you can optionally compile and
install this library along with it. The cmake `-DSC_EL` flag controls whether
2021-09-04 16:41:16 +00:00
scel will be compiled. On Linux machines `-DSC_EL=ON` by default. See the
2021-08-16 00:20:18 +00:00
supercollider README files for more info.
2009-01-02 19:06:25 +00:00
2021-09-04 13:46:59 +00:00
``` emacs-lisp
;; in ~/.emacs
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/SuperCollider/") ;; path will depend on your compilation settings
(require 'sclang)
```
## Optional Installation Requirements
2009-01-02 19:06:25 +00:00
2021-09-04 13:46:59 +00:00
There are two options for SuperCollider help files. They can be opened in the
help browser that ships with SuperCollider, or if you prefer an emacs-only
workflow they can be opened using the w3m browser. The browse-in-emacs option
requires an additional dependency.
2009-01-02 19:06:25 +00:00
2021-07-25 23:55:00 +00:00
```emacs-lisp
2021-08-16 00:20:18 +00:00
;; in ~/.emacs
2013-07-01 13:02:18 +00:00
(require 'w3m)
```
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
## Usage
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
The main function which starts interacting with the sclang interpreter is
`sclang-start` . You can execute that anywhere with `M-x sclang-start` , or from
within a `.scd` buffer by pressing `C-c C-o` .
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
If you know you want to launch sclang when you start emacs you can use the `-f`
option to execute that function right away:
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
``` shell
# in your terminal
emacs -f sclang-start
```
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
## Configuration
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
To fine-tune the installation from within emacs' graphical customization
interface, type:
2009-01-02 19:06:25 +00:00
2021-08-20 00:53:11 +00:00
`M-x sclang-customize`
2009-01-02 19:06:25 +00:00
2021-09-04 13:46:59 +00:00
NOTE: If you use an sclang configuration file different from the default
`sclang_conf.yaml` , you need to specify it in scel by customizing the
`sclang-library-configuration-file ` variable. Otherwise, even after installing
the Quark in SuperCollider, you won't be able to run sclang code in emacs.
2013-07-01 15:01:42 +00:00
2021-07-25 23:55:00 +00:00
## Getting help
2009-01-02 19:06:25 +00:00
2013-06-29 17:13:38 +00:00
Inside an sclang-mode buffer (e.g. by editing a .sc file), execute
2009-01-02 19:06:25 +00:00
2013-06-29 17:13:38 +00:00
`C-h m`
2009-01-02 19:06:25 +00:00
2013-06-29 17:13:38 +00:00
and a window with key bindings in sclang-mode will pop up.
2009-01-02 19:06:25 +00:00
2013-06-29 17:13:38 +00:00
`C-x C-h` lets you search for a help file
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
`C-M-h` opens or switches to the Help browser (if no Help file has been opened,
the default Help file will be opened).
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
`E` copies the buffer, puts it in text mode and sclang-minor-mode, to enable you
to edit the code parts to try out variations of the provided code in the help
file. With `C-M-h` you can then return to the Help browser and browse further
from the Help file.
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
`C-c C-e` allows you to edit the source of the HTML file, for example if you
want to improve it and commit it to the repository.
2009-01-02 19:06:25 +00:00
To enable moving around in the help file with arrow keys add the following
2013-06-29 17:13:38 +00:00
in your `~/.emacs` :
2009-01-02 19:06:25 +00:00
2013-07-01 15:13:24 +00:00
```
2009-01-02 19:06:25 +00:00
(eval-after-load "w3m"
'(progn
(define-key w3m-mode-map [left] 'backward-char)
(define-key w3m-mode-map [right] 'forward-char)
(define-key w3m-mode-map [up] 'previous-line)
(define-key w3m-mode-map [down] 'next-line)))
2013-06-29 17:13:38 +00:00
```
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
This ensures that the arrow keys are just for moving through the document, and
not from hyperlink to hyperlink, which is the default in w3m-mode.
2009-01-02 19:06:25 +00:00
2021-07-25 23:55:00 +00:00
## Server control
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
In the post buffer window, right-click on the server name; by default the two
servers `internal` and `localhost` are available. You will get a menu with
common server control operations.
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
To select another server, step through the server list by left-clicking on the
server name.
2009-01-02 19:06:25 +00:00
2021-08-16 00:20:18 +00:00
Servers instantiated from the language will automatically be available in the
mode line.