This tutorial assumes a reasonably new version of Emacs (24.4+)
Erlang Development Tool Suite aims to provide common IDE like functionality.
use-package is a simple way to keep various configurations under a top level sexp in a nice and clean manner.
Packages for Emacs can be installed from various package repositories like MELPA.
Add this to `~/.emacs.d/init.el` to set remote repositories and update cache the first time Emacs is started.
(setq package-archives
'(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
;; Fetch packages the first time
(unless (file-exists-p package-user-dir)
(package-refresh-contents))
Now install required packages
M-x package-install-package <RET> use-package M-x package-install-package <RET> edts M-x package-install-package <RET> flycheck
If EDTS installation fails, cd to installation path (`~/.emacs.d/elpa/edts-<version>`) and run `make` to complete the installation manually.
Require the packages
(eval-and-compile
(require 'use-package))
(use-package erlang
:init
(add-to-list 'auto-mode-alist '("\\.P\\'" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.E\\'" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.S\\'" . erlang-mode))
:config
(add-hook 'erlang-mode-hook
(lambda ()
(setq mode-name "erl"
erlang-compile-extra-opts '((i . "../include"))
erlang-root-dir "/usr/local/lib/erlang"))))
(use-package edts
:init
(setq edts-inhibit-package-check t
edts-man-root "~/.emacs.d/edts/doc/18.2.1"))
Evaluate all sexp or restart.
Follow instructions here here to setup docs. Match the version the configuration above.
Flycheck provides very powerful syntax checking for GNU Emacs. `C-c ! l` in any erlang buffer lists all possible errors and warnings in a dedicated buffer.
(use-package flycheck
:diminish flycheck-mode
:config
(add-hook 'after-init-hook 'global-flycheck-mode)
(setq flycheck-display-errors-function nil
flycheck-erlang-include-path '("../include")
flycheck-erlang-library-path '()
flycheck-check-syntax-automatically '(save)))