OCamlPro / ocp-indent

Indentation tool for OCaml, to be used from editors like Emacs and Vim.
http://www.typerex.org/ocp-indent.html
Other
200 stars 63 forks source link

Fix location of semicolon in record when the semicolon is alone on its line (Janestreet style) #209

Closed mbarbin closed 8 years ago

mbarbin commented 8 years ago

Example:

let f () =
  { a = int
      ; <- this semicolon

This is currently indents the ';' below the 'a' char as in:

let f () =
  { a = int
    ;

We would like it to be aligned under the open curly bracket:

let f () =
  { a = int
  ;

The main reason for being attached to this is so we can turn on electric mode for that case in emacs and have the semicolon aligned automatically as soon as the user types it.

AltGr commented 8 years ago

Note that the behaviour makes sense outside of records, because we want:

let f () =
  print_endline "a"
  ;
  print_endline "b"

where unindenting would be ugly. An exception should be added when within a record.

ghost commented 8 years ago

Is #210 working for you ?

mbarbin commented 8 years ago

I tested it in emacs this morning with electric mode enabled, and it is aligning it as intended. Thank you for the fix. :+1: