The best way to edit your alda files in Emacs!
Alda mode is a simple mode to provide syntax highlighting and other basic language features for Alda,the music programming language written in Clojure.
The easiest way to install alda-mode is through melpa. Simply
M-x package-install
alda-mode
.
Once installed, place (require 'alda-mode)
in your init.el.
For evil integration, simply install evil before alda-mode.
Alda files (.alda
extension) should now have syntax highlighting via
font-lock-mode when opened.
If melpa won’t work for you, M-x package-install-file
alda-mode.el
from this repository instead.
alda-mode can play segments of alda from within Emacs! Simply highlight a section of alda code and run:
M-x alda-play-region
This will take a while during the first call, which will start the alda
server within Emacs (if not already on your system). alda
will need to
be on your path.
If you want to use a custom alda binary, set alda-binary-location
to
your alda binary. Ex:
(setq alda-binary-location "/usr/local/bin/alda")
Keep in mind, the server will only see the selection you make, and this
has consequences. For example, you must run a snippet of code defining
an instrument before you hear anything (or defining a marker before
using it). alda-play-region
will use a running alda server if it finds
one, but will start one within Emacs if not found. Support is currently
only tested under Linux for this command. Mac will probably work depending
on your emacs install.
Please submit any bugs with this feature as issues to this repository.
Evil integration is automatically applied if you install evil before alda-mode. If you are installing evil after alda-mode, please reinstall/recompile alda-mode.
(package-install 'evil)
(package-install 'alda-mode)
(require 'alda-mode)
This will make a evil operator called alda-evil-play-region
, defined
when you require evil. If evil was not installed, this is replaced with
a warning message.
alda-mode adds a couple simple keybindings by default. These are documented below:
Keybind | Function | Explanation |
---|---|---|
C-c C-r | alda-play-region | Plays selected text |
C-c C-c | alda-play-block | Plays the paragraph on point |
C-c C-n | alda-play-line | Plays a single line |
C-c C-b | alda-play-buffer | Plays the entire buffer, as text (not as a file) |
Here are some simple example keybinds for evil integration (or if you want to add your own custom keybindings):
(global-set-key (kbd "C-c a") 'alda-play-region) ;; Global alda-play-map
;; Requires evil integration
(define-key evil-motion-state-map "gp" 'alda-evil-play-region)
This will map C-c a
to play a selected region, and gp
to be an evil
operator to do the same thing! (gpp
will play the current line,
gp20j
plays 20 lines, etc).
If you find a bug or want to improve alda-mode, submit a PR! =)
alda-mode is licensed under the GPLv3.