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

Johan Claesson johanclaesson@REDACTED
Sat May 4 00:38:14 CEST 2013



The MELPA archive can be added to GNU Emacs 24 with:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))

After that the following will install the erlang package:

M-x package-install RET erlang RET

(Or do M-x list-packages RET, go to erlang package and hit `i' and `x')

The two first lisp lines in your post is already in this package.  Note
that they are in erlang-autoloads.el and not in erlang.el.

The ".escript" extension is not added to auto-mode-list but instead an
entry to interpreter-mode-alist is added.  It will make any file
starting with for example the line "#!/usr/bin/escript" enter erlang
mode.

To initialize erlang-indent-level to tab-width would break backwards
compatibility since the default value of erlang-indent-level is 4 and
the default value of tab-width is 8.

Regards,

/Johan




Andrew Pennebaker <andrew.pennebaker@REDACTED> writes:

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



More information about the erlang-questions mailing list