[m-users.] Indenting issues

emacstheviking objitsu at gmail.com
Sun Jun 30 03:10:05 AEST 2019


Hi,

I use metal-mercury-mode in emacs but I am slowly but surely getting a
little sick and tired of it seemingly not lining things up. I copied the
code from page 15 of the Ralph Becket tutoral and it just doesn't line up.
Normally if emacs indenting is out then you left a bracket out somewhere
but didn't see it yet.
For example, this is the code as I want it

   9 │main(!IO) :-
  10 │    io.read_line_as_string(Result, !IO),
  11 │    (
  12 │        Result = eof,
  13 │        io.format("bye bye...\n", [], !IO)
  14 │    ;
  15 │        Result = ok(String),
  16 │        (
  17 │            if
  18 │                string.to_int(string.strip(String), N)
  19 │            then
  20 │                io.format("fib(%d) = %d\n", [i(N), i(fib(N))], !IO)
  21 │            else
  22 │                io.format("That isn't a number\n", [], !IO)
  23 │        ),
  24 │        main(!IO)
  25 │    ;
  26 │        Result = error(ErrorCode),
  27 │        io.format("%s...\n", [s(io.error_message(ErrorCode))], !IO)
  28 │    ).

but when I select the main predicate and let rip with "indent-region" it
looks like this...
   9 │main(!IO) :-
  10 │    io.read_line_as_string(Result, !IO),
  11 │    (
  12 │        Result = eof,
  13 │        io.format("bye bye...\n", [], !IO)
  14 │    ;
  15 │        Result = ok(String),
  16 │        (
  17 │            if
  18 │                string.to_int(string.strip(String), N)
  19 │            then
  20 │                io.format("fib(%d) = %d\n", [i(N), i(fib(N))], !IO)
  21 │            else
  22 │                io.format("That isn't a number\n", [], !IO)
  23 │            ),
  24 │                main(!IO)
  25 │            ;
  26 │                Result = error(ErrorCode),
  27 │                io.format("%s...\n",
[s(io.error_message(ErrorCode))], !IO)
  28 │            ).

Lines 24-28 just won't go back....I almost give up with it all today.
Nothing behaves!!!

I have also noticed that the comments don't always line up especially if
there is a word like "if" in the comment.

What does everybody else use...it's driving me nuts TBH.

Sean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190629/fb9381ed/attachment.html>


More information about the users mailing list