[erlang-questions] Is there any erlang code formatting tool?

70 views
Skip to first unread message

Liu Yubao

unread,
Feb 3, 2009, 1:46:14 AM2/3/09
to erlang-q...@erlang.org
Hi,

I prefer Vim to edit and Emacs to format erlang code but
switching between two editors is very inconvenient. Is
there any erlang code formatting tool? Or how can I use emacs
to format erlang source files in batch?

The default setting of erlang-mode indent code by tab characters
and spaces, I prefer four spaces to one tab, how to change the
setting of erlang-mode to make it indent code with four spaces?

Below is output from vim(et ts=4 sw=4) and emacs(default setting):

---------------vim, formatted with "gg=G":
{ehtml,
{table, [{border, "1"}, {cellpadding, "2"}, {cellspacing, "2"}],
[{thead, [],
{tr, [],
[{th, [], "File path"},
{th, [], "Module name"},
{th, [], "Last modified time"},
{th, [], "Status"}]}},
{tbody, [], Rows}]}}.

----------------emacs:
{ehtml,
{table, [{border, "1"}, {cellpadding, "2"}, {cellspacing, "2"}],
[{thead, [],
{tr, [],
[{th, [], "File path"},
{th, [], "Module name"},
{th, [], "Last modified time"},
{th, [], "Status"}]}},
{tbody, [], Rows}]}}.
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions

Bengt Kleberg

unread,
Feb 3, 2009, 1:59:09 AM2/3/09
to erlang-q...@erlang.org
Greetings,

I have used parts of the Syntax_Tools
(http://erlang.org/doc/apps/syntax_tools/index.html) for Erlang
formatting without Emacs.
For batch processing of files you might want to look at erl_tidy
(http://erlang.org/doc/man/erl_tidy.html).
If you want a tool that takes care of a function in a file, you can talk
to me.


bengt

Liu Yubao

unread,
Feb 3, 2009, 10:21:13 PM2/3/09
to bengt....@ericsson.com, erlang-q...@erlang.org
Hi,

Thank you very much, I should have digged the document more carefully.

Csaba Hoch

unread,
Feb 13, 2009, 10:10:33 AM2/13/09
to erlang-q...@erlang.org
Liu Yubao wrote:
> I prefer Vim to edit and Emacs to format erlang code but
> switching between two editors is very inconvenient. Is
> there any erlang code formatting tool? Or how can I use emacs
> to format erlang source files in batch?

Hi,

If you put this in your .vimrc, you can ask Emacs to indent the file
that you are editing by typing :IndentErl.

command! IndentErl call IndentErlangWithEmacs()

function! IndentErlangWithEmacs()
exec '!emacs --eval "(progn (find-file \"' . expand('%:p') . '\")' .
\ '(erlang-indent-current-buffer) (save-buffer) '.
\ '(save-buffers-kill-emacs))"'
endfunction

Csaba

Torbjorn Tornkvist

unread,
Feb 13, 2009, 6:13:28 PM2/13/09
to erlang-q...@erlang.org
Csaba Hoch <csaba...@gmail.com> writes:

> Liu Yubao wrote:
>> I prefer Vim to edit and Emacs to format erlang code but
>> switching between two editors is very inconvenient. Is
>> there any erlang code formatting tool? Or how can I use emacs
>> to format erlang source files in batch?

Have a look here:

http://blog.tornkvist.org/blog.yaws?id=1233867602690448

--Tobbe

>
> Hi,
>
> If you put this in your .vimrc, you can ask Emacs to indent the file
> that you are editing by typing :IndentErl.
>
> command! IndentErl call IndentErlangWithEmacs()
>
> function! IndentErlangWithEmacs()
> exec '!emacs --eval "(progn (find-file \"' . expand('%:p') . '\")' .
> \ '(erlang-indent-current-buffer) (save-buffer) '.
> \ '(save-buffers-kill-emacs))"'
> endfunction
>
> Csaba

--
KREDITOR EUROPE AB
S:t Eriksgatan 117
SE-113 43 Stockholm, Sweden
Tel: +46(0)8-120 120 00
Fax: +46(0)8-120 120 99
Email: torbjorn....@kreditor.se
Web: www.kreditor.se

Reply all
Reply to author
Forward
0 new messages