Skip to content

Commit

Permalink
Merge pull request #39 from jxa/packaging
Browse files Browse the repository at this point in the history
Allow installation via package managers
  • Loading branch information
dyfer authored Sep 4, 2021
2 parents 9d6067b + 35b972f commit d8296a9
Show file tree
Hide file tree
Showing 30 changed files with 265 additions and 123 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
emacs_version:
- 27.2
- 26.3
- 25.3

steps:
- name: Set up Emacs
uses: purcell/setup-emacs@master
with:
version: ${{matrix.emacs_version}}

- name: Install Eldev
run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh

- name: Check out the elisp source code
uses: actions/checkout@v2

- name: Test the uncompiled source
run: |
cd el
eldev -p -dtT test
- name: Compile and run tests again
run: |
cd el
eldev compile
eldev -p -dtT test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
*.elc
.eldev
/el/sclang-autoloads.el
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Ability to distribute via package managers
- Support for `completion-at-point-functions` and `company` via `company-capf`

### Changed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_subdirectory(el)
add_subdirectory(sc)
add_subdirectory(sc/scide_scel)
install(DIRECTORY HelpSource
DESTINATION share/SuperCollider/Extensions/scide_scel/)
176 changes: 115 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,139 @@
Scel
====
# scel - sclang-mode for emacs

SuperCollider/Emacs interface

## Installation

Installation requirements
-------------------------
There are 3 options for installation:

For the HTML help system, you will need emacs-w3m support.
1. Using SuperCollider Quarks (recommended)
2. From debian package `supercollider-emacs`
3. From source

Option #1 is the best cross-platform option, and is recommended. Whatever option
you choose, *make sure not to mix installation methods*. In particular, do not
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.

Installation (default)
----------------------
### Install Option 1: SuperCollider's own package manager

By default emacs-lisp files are installed in
The repository contains two subprojects. `/el` contains the emacs-lisp
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.

`$prefix/share/emacs/site-lisp`
Evaluate this code in the SuperCollider GUI by pasting it and pressing
shift+enter:

SuperCollider files are put in
``` supercollider
Quarks.install("https://github.com/supercollider/scel");
```

`$prefix/share/SuperCollider/Extensions/scide_scel`
The scel repository will be downloaded to your local file system and the path
will be added to your currently used `sclang_conf.yaml` file. (You can find its
location by evaluating `Platform.userConfigDir`)

Next, find out where scel was installed. You will use this install-path in your
emacs config.

The only thing you need to do is loading the sclang interface in your `~/.emacs`:
``` supercollider
Quarks.folder.postln;
// -> /Users/<username>/Library/Application Support/SuperCollider/downloaded-quarks
```

Now in your emacs config, add the `/el` subdirectory to your load path
``` emacs-lisp
;; in ~/.emacs
;; Paste path from above, appending "/scel/el"
(add-to-list 'load-path "/Users/<username>/Library/Application Support/SuperCollider/downloaded-quarks/scel/el")
(require 'sclang)
```
#### On macOS

For the HTML help system to fully function also add
```
(require 'w3m)
If `sclang` executable is not on your path, you may need to add it to your
exec-path.

``` emacs-lisp
;; in ~/.emacs
(setq exec-path (append exec-path '("/Applications/SuperCollider.app/Contents/MacOS/")))
```

#### Installing with an emacs package manager

It's completely possible to install with
[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.

Installation (detailed)
-----------------------
### Install Option 2: Debian package

Put all `*.el` files in emacs' load-path. e.g. if you put them in
`~/emacs/`, add the following lines to `~/.emacs` (or whatever your init
file is called):
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
```
(add-to-list 'load-path "~/emacs")

### Install Option 3: Installing from source

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
scel will be compiled. On Linux machines `-DSC_EL=ON` by default. See the
supercollider README files for more info.

``` 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)
```

for the HTML help system to fully function also add
```
## Optional Installation Requirements

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.

```emacs-lisp
;; in ~/.emacs
(require 'w3m)
```

now put all `*.sc` files in sclang's library path, e.g. if you put them
in a non-standard location, such as `~/SuperCollider/Emacs`, add the
following to `~/.config/SuperCollider/sclang_conf.yaml` (Linux) or `~/Library/Application Support/SuperCollider/sclang_conf.yaml` (macOS):
## Usage

```
includePaths:
[~/SuperCollider/Emacs]
```
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`.

(note normally this is not needed as they are put into sclang's library
path during installation with scons).
If you know you want to launch sclang when you start emacs you can use the `-f`
option to execute that function right away:

``` shell
# in your terminal
emacs -f sclang-start
```

Usage
-----
## Configuration

In order to automatically start sclang when invoking emacs, use the following command line:
To fine-tune the installation from within emacs' graphical customization
interface, type:

```
$> emacs -sclang
```
`M-x sclang-customize`

you're now ready to edit, inspect and execute sclang code!
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.


Getting help
------------
## Getting help

Inside an sclang-mode buffer (e.g. by editing a .sc file), execute

Expand All @@ -87,11 +143,16 @@ and a window with key bindings in sclang-mode will pop up.

`C-x C-h` lets you search for a help file

`C-M-h` opens or switches to the Help browser (if no Help file has been opened, the default Help file will be opened).
`C-M-h` opens or switches to the Help browser (if no Help file has been opened,
the default Help file will be opened).

`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.
`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.

`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.
`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.

To enable moving around in the help file with arrow keys add the following
in your `~/.emacs`:
Expand All @@ -105,25 +166,18 @@ in your `~/.emacs`:
(define-key w3m-mode-map [down] 'next-line)))
```

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.


Customization
-------------

To fine-tune the installation from within emacs' graphical customization interface, type:

`M-x sclang-customize`

In particular, you will have to customize `sclang-runtime-directory'.
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.


Server control
--------------
## Server control

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.
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.

To select another server, step through the server list by left-clicking on the server name.
To select another server, step through the server list by left-clicking on the
server name.

Servers instantiated from the language will automatically be available
in the mode line.
Servers instantiated from the language will automatically be available in the
mode line.
6 changes: 6 additions & 0 deletions el/Eldev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; -*- mode: emacs-lisp; lexical-binding: t -*-
;
;; You can obtain eldev from https://github.com/doublep/eldev
;; We use it for package development and running tests

(eldev-use-plugin 'autoloads)
9 changes: 2 additions & 7 deletions el/sclang-dev.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
;; USA


(eval-when-compile
(require 'sclang-util)
(require 'sclang-interp)
)


(require 'sclang-util)
(require 'sclang-interp)

(sclang-set-command-handler
'openDevSource
Expand Down
31 changes: 25 additions & 6 deletions el/sclang-help.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@
(require 'sclang-interp)
(require 'sclang-language)
(require 'sclang-mode)
(require 'sclang-vars)
(require 'sclang-vars nil 'ignore-missing-file)
(require 'sclang-minor-mode)

(defcustom sclang-help-directory "~/SuperCollider/Help"
"*Directory where the SuperCollider help files are kept. OBSOLETE."
(defun sclang-system-root ()
"Find the common install location for the platform."
(cond
((boundp 'sclang-system-data-dir)
sclang-system-data-dir)

((eql 'darwin system-type)
(expand-file-name "~/Library/Application Support/SuperCollider"))

((and (eql 'gnu/linux system-type)
(file-exists-p "/usr/local/share/SuperCollider"))
"/usr/local/share/SuperCollider")

((eql 'gnu/linux system-type)
"/usr/share/SuperCollider")))

(defcustom sclang-system-help-dir (expand-file-name "Help" (sclang-system-root))
"Installation dependent help directory."
:group 'sclang-interface
:version "21.3"
:type 'directory
:options '(:must-match))
:type 'directory)

(defcustom sclang-help-path (list sclang-system-help-dir
"~/.local/share/SuperCollider/Help")
Expand All @@ -41,6 +55,11 @@
:version "21.4"
:type '(repeat directory))

(defcustom sclang-system-extension-dir (expand-file-name "Extensions" (sclang-system-root))
"Installation dependent extension directory."
:group 'sclang-interface
:type 'directory)

(defconst sclang-extension-path (list sclang-system-extension-dir
"~/.local/share/SuperCollider/Extensions")
"List of SuperCollider extension directories.")
Expand Down
6 changes: 3 additions & 3 deletions el/sclang-interp.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
;; USA

(eval-when-compile
(require 'sclang-util)
(require 'compile))
(require 'sclang-util)
(require 'compile)

;; =====================================================================
;; post buffer access
Expand Down Expand Up @@ -303,6 +302,7 @@ If EOB-P is non-nil, positions cursor at end of buffer."
(list "-s"))
(list "-iscel"))))

;;;###autoload (autoload 'sclang-start "sclang" "Start SuperCollider process." t)
(defun sclang-start ()
"Start SuperCollider process."
(interactive)
Expand Down
Loading

0 comments on commit d8296a9

Please sign in to comment.