[erlang-questions] erlang-mode: follow more Emacs idioms

Andrew Pennebaker andrew.pennebaker@REDACTED
Fri May 3 21:47:07 CEST 2013

In modern Emacs, it's recommended to install
MELPA<http://melpa.milkbox.net/>and use M-x install-package RET
erlang-mode RET to get Erlang mode up and
running. With most major modes, this is all that is required, however
erlang-mode needs some manual configuration that we should probably work on
automating during its installation. Currently, Emacs users must modify
several lines in ~/.emacs in order to setup erlang-mode:

(autoload 'erlang-mode "erlang" "" t)
(add-to-list 'auto-mode-alist '("\\.erl\\'" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.escript\\'" . erlang-mode))
(add-hook 'erlang-mode-hook
          (lambda ()
            (setq erlang-indent-level tab-width)))

The first three collectively register the ".erl" and ".escript" file
extensions with erlang-mode. In modern Emacs, the idiom is to register
these autoloads as part of installation. For example, go-mode successfully
does this. https://code.google.com/p/go/source/browse/#hg%2Fmisc%2Femacs

Also, it's more idiomatic for Emacs users to set a global tab-width, and
modify it by file type with hooks. As we see above, erlang-mode in its
current form does not respect the conventional variable tab-width, using
erlang-indent-level instead. We can improve this a bit, while maintaining
backwards compatibility, by defaulting erlang-indent-level to tab-width
when a buffer enters erlang-mode.

What do you think?


Andrew Pennebaker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130503/73e5327b/attachment.htm>

More information about the erlang-questions mailing list