diff --git a/lib/indent_printer.ml b/lib/indent_printer.ml index d7a23550..93867f51 100644 --- a/lib/indent_printer.ml +++ b/lib/indent_printer.ml @@ -1267,6 +1267,7 @@ let program ?source ?macros:m (fs : Form.t list) : string = in spelling := (fun _ -> None); inside := (fun _ -> false); + classes := []; (* With the source, its comments go back where they were; without it the tags come out and nothing goes in. *) Source_text.weave ~starts:(Source_text.form_starts fs) diff --git a/lib/source.ml b/lib/source.ml index 8bc9e0f4..ba670faf 100644 --- a/lib/source.ml +++ b/lib/source.ml @@ -72,9 +72,11 @@ let read_paren ?(line = 1) ?(col = 1) ~file src = in go [] -(** Editor code, in the request's syntax and at its position. With [expr], an - indented snippet of several statements is one expression, [(do ...)]: a - block of lines means its lines in order. *) +(** Editor code, in the request's syntax and at its position. With [expr], + an indented snippet of several statements is one expression, + [(do ...)]: a block of lines means its lines in order. A [let] is a + global only in code from column 1 that is not an expression: a form cut + from inside a body, for a macroexpansion say, keeps its lets local. *) let read_code ?(expr = false) ~file code = let line, col = match !code_at with Some (l, c) -> (l, c) | None -> (1, 1) @@ -82,7 +84,7 @@ let read_code ?(expr = false) ~file code = match !code_syntax with | Paren -> read_paren ~line ~col ~file code | Indented -> - (match Indent_reader.read_all ~line ~col ?indent:!code_indent ~global_let:(not expr) + (match Indent_reader.read_all ~line ~col ?indent:!code_indent ~global_let:(not expr && col = 1) ~file code with | (first :: _ :: _ as forms) when expr -> let last = List.nth forms (List.length forms - 1) in