Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installation via package managers #39

Merged
merged 17 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dyfer marked this conversation as resolved.
Show resolved Hide resolved
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/)
173 changes: 109 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,130 @@
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
dyfer marked this conversation as resolved.
Show resolved Hide resolved
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`
dyfer marked this conversation as resolved.
Show resolved Hide resolved
The scel repository will be downloaded to your local file system and the path
will be added to your default `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/jxa/Library/Application Support/SuperCollider/downloaded-quarks
dyfer marked this conversation as resolved.
Show resolved Hide resolved
```

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/jxa/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

Installation (detailed)
-----------------------
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.

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):
### Install Option 2: Debian package

```
(add-to-list 'load-path "~/emacs")
(require 'sclang)
```
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:

for the HTML help system to fully function also add
```
(require 'w3m)
``` shell
sudo apt install supercollider-emacs
```

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):
### Install Option 3: Installing from source
dyfer marked this conversation as resolved.
Show resolved Hide resolved

```
includePaths:
[~/SuperCollider/Emacs]
```
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.
dyfer marked this conversation as resolved.
Show resolved Hide resolved

(note normally this is not needed as they are put into sclang's library
path during installation with scons).
## Installation requirements

For the HTML help system, you will need emacs-w3m support, but you can still use
the rest of the functionality without the w3m dependency.

Usage
-----
```emacs-lisp
;; in ~/.emacs
(require 'w3m)
```
dyfer marked this conversation as resolved.
Show resolved Hide resolved

In order to automatically start sclang when invoking emacs, use the following command line:
## Usage

```
$> emacs -sclang
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`.

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

you're now ready to edit, inspect and execute sclang code!
## Configuration

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

`M-x sclang-customize`

If you want to change from the default `sclang_conf.yaml` file used by your
emacs sessions you can customize the `sclang-library-configuration-file`
variable, but make sure that file loads the scel quark, or you won't be
able to run sclang code.
dyfer marked this conversation as resolved.
Show resolved Hide resolved

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

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

Expand All @@ -87,11 +134,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 +157,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)
dyfer marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all these eval-when-compile calls because we need to require at runtime when autoloading

(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)
dyfer marked this conversation as resolved.
Show resolved Hide resolved
(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")))
dyfer marked this conversation as resolved.
Show resolved Hide resolved

(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")
dyfer marked this conversation as resolved.
Show resolved Hide resolved
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
7 changes: 2 additions & 5 deletions el/sclang-minor-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

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

(require 'sclang-util)
(require 'sclang-mode)

(easy-mmode-define-minor-mode sclang-minor-mode
"Toggle sclang-minor-mode.
Expand Down
Loading