Mon Jun 27 12:45:10 CEST 2005
Mats Cronqvist wrote:
> i'm trying to make a erl-html filter using syntax-tools (works so-so),
> but i've found this annoying behaviour. if i have this in a file (named
> running this beauty;
> will give this;
> "foo(Bla,\n X) ->%hello\n Bla.
> there shouldn't be a line break between Bla and X. and indeed, if the
> comment is removed there isn't.
> anybody got any advice?
It's been a while since I wrote that stuff, so I had to try it out to see why
this happens. Although it might certainly be irritating, it's not without logic
(and I don't know if it can be fixed). The comment is attached to the nearest
construct in the parse tree, in this case the variable 'X' (and not the
function clause). Then, the formatting will not like that an element in a
parameter list has an attached comment (because comments must end with a line
break), and will lay out the sequence vertically. (After that, the comment will
be moved outside the ")->" part, but that is by another mechanism.)
Consider this slight modification, and you might see that your example is
just a special case:
Of course, that doesn't make it less irritating, but now you know what is
causing it. Feel free to try to solve the problem. And welcome to the wonderful
world of layout engines.
More information about the erlang-questions