elixir-mode -- Emacs major mode for Elixir
Simply add to your load path and require the mode to install.
In your shell...
% git clone git://github.com/elixir/emacs-elixir ~/.emacs.d/emacs-elixir
% $EDITOR ~/.emacs
In the editor...
(add-to-list 'load-path "~/.emacs.d/emacs-elixir)
(require 'elixir-mode-setup)
(elixir-mode-setup)
Save and reload with M-x load-file
~/.emacs
.
Any file that matches the glob *.ex[s]
or *.elixir
is
automatically opened in Elixir mode, but you can change this
functionality easily.
;; Highlights *.elixir2 as well
(add-to-list 'auto-mode-alist '("\\.elixir2\\'" . elixir-mode))
(For the M-x
prompt.)
Switches to elixir-mode.
Applies compile-on-save minor mode.
Launch IEX
inside Emacs.
Open the GitHub page for Elixir.
Compile Elixir files. Works fine on exs
files, too, if needed.
Go to Elixir README in the browser.
Print version info for elixir-mode.
Indent the current line. (Buggy right now.)
Hooks can be used to add functionality to elixir-mode. This example adds compile on save.
(defun elixir-mode-compile-on-save ()
"Elixir mode compile files on save."
(and (file-exists (buffer-file-name))
(file-exists (elixir-mode-compiled-file-name))
(elixir-cos-mode t)))
(add-hook 'elixir-mode-hook 'elixir-mode-compile-on-save)
Custom variables for elixir-mode.
Command to compile Elixir code.
Command to start an interactive REPL in IEX
.
Should operators be colored? (Currently not working properly.)
Should Cygwin paths be used on Windows?
The prefix for Cygwin-style paths.
Keymaps can be added to the elixir-mode-map
variable.
There are no keyboard shortcuts included by default.
This is still very alpha software; there are probably several bugs. Right now the indentation implementation needs some work, and the IEX mode appears entirely untested.
If you want to use ruby-end-mode
for a more comfortable editing
experience, you can add the following to your elixir-mode-hook
:
(add-to-list 'elixir-mode-hook
(defun auto-activate-ruby-end-mode-for-elixir-mode ()
(set (make-variable-buffer-local 'ruby-end-expand-keywords-before-re)
"\\(?:^\\|\\s-+\\)\\(?:do\\)")
(set (make-variable-buffer-local 'ruby-end-check-statement-modifiers) nil)
(ruby-end-mode +1)))
This mode is based on the Emacs mode by secondplanet.