Run of fresh-snapshots for ocp-indent

Merge these changes:

git pull https://janitor.debian.net/git/ocp-indent fresh-snapshots/main
git pull https://janitor.debian.net/git/ocp-indent fresh-snapshots/pristine-tar
git pull https://janitor.debian.net/git/ocp-indent fresh-snapshots/upstream

Summary

Merged new upstream version: 1.8.2+git20211019.1.7c4d434 (was: 1.8.2).

Diff

Branch: main

diff --git a/debian/changelog b/debian/changelog
index 767679a..3b4f187 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ocp-indent (1.8.2+git20211019.1.7c4d434-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 May 2022 03:59:12 -0000
+
 ocp-indent (1.8.2-1) unstable; urgency=medium
 
   * Team upload
diff --git a/debian/patches/fix-spelling b/debian/patches/fix-spelling
index 8736622..2ba8298 100644
--- a/debian/patches/fix-spelling
+++ b/debian/patches/fix-spelling
@@ -1,7 +1,9 @@
 Description: Fix a small spelling mistake
 
---- a/src/indentArgs.ml
-+++ b/src/indentArgs.ml
+Index: ocp-indent/src/indentArgs.ml
+===================================================================
+--- ocp-indent.orig/src/indentArgs.ml
++++ ocp-indent/src/indentArgs.ml
 @@ -57,7 +57,7 @@ let options =
      Arg.(value & flag & info ["i";"inplace"] ~doc)
    in
diff --git a/src/indentBlock.ml b/src/indentBlock.ml
index 3f03ad0..9933965 100644
--- a/src/indentBlock.ml
+++ b/src/indentBlock.ml
@@ -811,7 +811,16 @@ let rec update_path config block stream tok =
         | TRY -> KTry
         | _ -> assert false
       in
-      let p = fold_expr block.path in
+      let p =
+        if config.i_match_tail_cascade &&
+           (match block.path with
+            | {kind = KArrow (KMatch|KTry)} :: _ -> true
+            | _ -> false)
+        then
+          Path.maptop (fun n -> {n with pad = 0}) block.path
+        else
+          fold_expr block.path
+      in
       if starts_line then append k L p
       else
         let enforce_strict =
diff --git a/src/indentConfig.ml b/src/indentConfig.ml
index 741d62c..027a88b 100644
--- a/src/indentConfig.ml
+++ b/src/indentConfig.ml
@@ -31,6 +31,7 @@ type t = {
   i_strict_comments: bool;
   i_align_ops: bool;
   i_align_params: threechoices;
+  i_match_tail_cascade: bool;
 }
 
 let default = {
@@ -46,6 +47,7 @@ let default = {
   i_strict_comments = false;
   i_align_ops = true;
   i_align_params = Auto;
+  i_match_tail_cascade = false;
 }
 
 let presets = [
@@ -54,7 +56,7 @@ let presets = [
     i_ppx_stritem_ext = 2;
     i_max_indent = None;
     i_strict_with = Never; i_strict_else = Always; i_strict_comments = false;
-    i_align_ops = true; i_align_params = Always };
+    i_align_ops = true; i_align_params = Always; i_match_tail_cascade = false };
   "normal",
   default;
   "JaneStreet",
@@ -62,7 +64,7 @@ let presets = [
     i_ppx_stritem_ext = 2;
     i_max_indent = Some 2;
     i_strict_with = Auto; i_strict_else = Always; i_strict_comments = true;
-    i_align_ops = true; i_align_params = Always };
+    i_align_ops = true; i_align_params = Always; i_match_tail_cascade = false };
 ]
 
 let threechoices_of_string = function
@@ -100,7 +102,8 @@ let to_string ?(sep=",") indent =
      strict_else = %s%s\
      strict_comments = %b%s\
      align_ops = %b%s\
-     align_params = %s"
+     align_params = %s%s\
+     match_tail_cascade = %b"
     indent.i_base sep
     indent.i_type sep
     indent.i_in sep
@@ -112,7 +115,8 @@ let to_string ?(sep=",") indent =
     (string_of_threechoices indent.i_strict_else) sep
     indent.i_strict_comments sep
     indent.i_align_ops sep
-    (string_of_threechoices indent.i_align_params)
+    (string_of_threechoices indent.i_align_params) sep
+    indent.i_match_tail_cascade
 
 exception Fail_of_string of [`Int | `Bool | `Threechoices | `Intoption ]
 
@@ -142,6 +146,8 @@ let set ?(extra=fun _ -> None) t var_name value =
     | "align_ops" -> {t with i_align_ops = parse `Bool bool_of_string}
     | "align_params" -> {t with i_align_params =
                                   parse `Threechoices threechoices_of_string}
+    | "match_tail_cascade" -> {t with i_match_tail_cascade =
+                                        parse `Bool bool_of_string}
     | var_name ->
         match extra var_name with
         | Some f -> f value; t
@@ -309,6 +315,21 @@ let man =
            \        match foo with\n\
            \        | _ -> some_fun\n\
            \               $(b,..)parameter"
+  @
+    `I (option_name "match_tail_cascade" "BOOL"
+          (string_of_bool default.i_match_tail_cascade),
+        "If `true', the default indentation is suppressed for matches \
+         directly following a match arrow. This can avoid shifting to the \
+         right when matches eliminate specific cases in succession, which \
+         Gabriel Scherer coined as \"cascading style\", as opposed to the \
+         usual \"nesting style\". This is similar to what happens with \
+         `strict_else=$(b,auto).")
+    :: pre "    Example with `match_tail_cascade=$(b,true)':\n\
+           \        match foo with\n\
+           \        | Error err -> fail_foo_error err\n\
+           \        | Ok y ->\n\
+           \          match bar y with\n\
+           \        | Error err ->"
   @ [
     `P "Available presets are `normal', the default, `apprentice' which may \
         make some aspects of the syntax more obvious for beginners, and \
diff --git a/src/indentConfig.mli b/src/indentConfig.mli
index 7842960..a69e78c 100644
--- a/src/indentConfig.mli
+++ b/src/indentConfig.mli
@@ -34,6 +34,7 @@ type t = {
   i_strict_comments: bool;
   i_align_ops: bool;
   i_align_params: threechoices;
+  i_match_tail_cascade: bool;
 }
 
 (** Documentation of the indentation options, in the Cmdliner 'Manpage.block' format *)
diff --git a/tools/ocp-indent.el b/tools/ocp-indent.el
index 4de456f..4e99a33 100644
--- a/tools/ocp-indent.el
+++ b/tools/ocp-indent.el
@@ -27,8 +27,7 @@
 ;; Eval this file to automatically use ocp-indent on caml/tuareg buffers.
 
 ;;; Code:
-
-(require 'cl)
+(require 'cl-lib)
 
 (defgroup ocp-indent nil
   "ocp-indent OCaml indenter binding configuration"
@@ -76,8 +75,8 @@ are blanks."
    (list "--numeric"
          "--lines" (format "%d-%d" start-line end-line))
    (if ocp-indent-config (list "--config" ocp-indent-config) nil)
-   (reduce (lambda (acc syn) (list* "--syntax" syn acc))
-           ocp-indent-syntax :initial-value nil)))
+   (cl-reduce (lambda (acc syn) (list* "--syntax" syn acc))
+              ocp-indent-syntax :initial-value nil)))
 
 (defun ocp-indent-file-to-string (file)
   (replace-regexp-in-string
@@ -126,7 +125,7 @@ buffer."
       (delete-file errfile))
     (save-excursion
       (goto-char start)
-      (mapcar
+      (mapc
        #'(lambda (indent) (indent-line-to indent) (forward-line))
        indents))
     (when (ocp-in-indentation-p) (back-to-indentation))))

Branch: pristine-tar

diff --git a/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.delta b/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.delta
new file mode 100644
index 0000000..daecdb6
Binary files /dev/null and b/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.delta differ
diff --git a/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.id b/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.id
new file mode 100644
index 0000000..9678f9b
--- /dev/null
+++ b/ocp-indent_1.8.2+git20211019.1.7c4d434.orig.tar.gz.id
@@ -0,0 +1 @@
+4b815fd5028b2df1c7000bb431f43bb0811fd0a7

Branch: upstream

Tag: upstream/1.8.2+git20211019.1.7c4d434
diff --git a/src/indentBlock.ml b/src/indentBlock.ml
index 3f03ad0..9933965 100644
--- a/src/indentBlock.ml
+++ b/src/indentBlock.ml
@@ -811,7 +811,16 @@ let rec update_path config block stream tok =
         | TRY -> KTry
         | _ -> assert false
       in
-      let p = fold_expr block.path in
+      let p =
+        if config.i_match_tail_cascade &&
+           (match block.path with
+            | {kind = KArrow (KMatch|KTry)} :: _ -> true
+            | _ -> false)
+        then
+          Path.maptop (fun n -> {n with pad = 0}) block.path
+        else
+          fold_expr block.path
+      in
       if starts_line then append k L p
       else
         let enforce_strict =
diff --git a/src/indentConfig.ml b/src/indentConfig.ml
index 741d62c..027a88b 100644
--- a/src/indentConfig.ml
+++ b/src/indentConfig.ml
@@ -31,6 +31,7 @@ type t = {
   i_strict_comments: bool;
   i_align_ops: bool;
   i_align_params: threechoices;
+  i_match_tail_cascade: bool;
 }
 
 let default = {
@@ -46,6 +47,7 @@ let default = {
   i_strict_comments = false;
   i_align_ops = true;
   i_align_params = Auto;
+  i_match_tail_cascade = false;
 }
 
 let presets = [
@@ -54,7 +56,7 @@ let presets = [
     i_ppx_stritem_ext = 2;
     i_max_indent = None;
     i_strict_with = Never; i_strict_else = Always; i_strict_comments = false;
-    i_align_ops = true; i_align_params = Always };
+    i_align_ops = true; i_align_params = Always; i_match_tail_cascade = false };
   "normal",
   default;
   "JaneStreet",
@@ -62,7 +64,7 @@ let presets = [
     i_ppx_stritem_ext = 2;
     i_max_indent = Some 2;
     i_strict_with = Auto; i_strict_else = Always; i_strict_comments = true;
-    i_align_ops = true; i_align_params = Always };
+    i_align_ops = true; i_align_params = Always; i_match_tail_cascade = false };
 ]
 
 let threechoices_of_string = function
@@ -100,7 +102,8 @@ let to_string ?(sep=",") indent =
      strict_else = %s%s\
      strict_comments = %b%s\
      align_ops = %b%s\
-     align_params = %s"
+     align_params = %s%s\
+     match_tail_cascade = %b"
     indent.i_base sep
     indent.i_type sep
     indent.i_in sep
@@ -112,7 +115,8 @@ let to_string ?(sep=",") indent =
     (string_of_threechoices indent.i_strict_else) sep
     indent.i_strict_comments sep
     indent.i_align_ops sep
-    (string_of_threechoices indent.i_align_params)
+    (string_of_threechoices indent.i_align_params) sep
+    indent.i_match_tail_cascade
 
 exception Fail_of_string of [`Int | `Bool | `Threechoices | `Intoption ]
 
@@ -142,6 +146,8 @@ let set ?(extra=fun _ -> None) t var_name value =
     | "align_ops" -> {t with i_align_ops = parse `Bool bool_of_string}
     | "align_params" -> {t with i_align_params =
                                   parse `Threechoices threechoices_of_string}
+    | "match_tail_cascade" -> {t with i_match_tail_cascade =
+                                        parse `Bool bool_of_string}
     | var_name ->
         match extra var_name with
         | Some f -> f value; t
@@ -309,6 +315,21 @@ let man =
            \        match foo with\n\
            \        | _ -> some_fun\n\
            \               $(b,..)parameter"
+  @
+    `I (option_name "match_tail_cascade" "BOOL"
+          (string_of_bool default.i_match_tail_cascade),
+        "If `true', the default indentation is suppressed for matches \
+         directly following a match arrow. This can avoid shifting to the \
+         right when matches eliminate specific cases in succession, which \
+         Gabriel Scherer coined as \"cascading style\", as opposed to the \
+         usual \"nesting style\". This is similar to what happens with \
+         `strict_else=$(b,auto).")
+    :: pre "    Example with `match_tail_cascade=$(b,true)':\n\
+           \        match foo with\n\
+           \        | Error err -> fail_foo_error err\n\
+           \        | Ok y ->\n\
+           \          match bar y with\n\
+           \        | Error err ->"
   @ [
     `P "Available presets are `normal', the default, `apprentice' which may \
         make some aspects of the syntax more obvious for beginners, and \
diff --git a/src/indentConfig.mli b/src/indentConfig.mli
index 7842960..a69e78c 100644
--- a/src/indentConfig.mli
+++ b/src/indentConfig.mli
@@ -34,6 +34,7 @@ type t = {
   i_strict_comments: bool;
   i_align_ops: bool;
   i_align_params: threechoices;
+  i_match_tail_cascade: bool;
 }
 
 (** Documentation of the indentation options, in the Cmdliner 'Manpage.block' format *)
diff --git a/tools/ocp-indent.el b/tools/ocp-indent.el
index 4de456f..4e99a33 100644
--- a/tools/ocp-indent.el
+++ b/tools/ocp-indent.el
@@ -27,8 +27,7 @@
 ;; Eval this file to automatically use ocp-indent on caml/tuareg buffers.
 
 ;;; Code:
-
-(require 'cl)
+(require 'cl-lib)
 
 (defgroup ocp-indent nil
   "ocp-indent OCaml indenter binding configuration"
@@ -76,8 +75,8 @@ are blanks."
    (list "--numeric"
          "--lines" (format "%d-%d" start-line end-line))
    (if ocp-indent-config (list "--config" ocp-indent-config) nil)
-   (reduce (lambda (acc syn) (list* "--syntax" syn acc))
-           ocp-indent-syntax :initial-value nil)))
+   (cl-reduce (lambda (acc syn) (list* "--syntax" syn acc))
+              ocp-indent-syntax :initial-value nil)))
 
 (defun ocp-indent-file-to-string (file)
   (replace-regexp-in-string
@@ -126,7 +125,7 @@ buffer."
       (delete-file errfile))
     (save-excursion
       (goto-char start)
-      (mapcar
+      (mapc
        #'(lambda (indent) (indent-line-to indent) (forward-line))
        indents))
     (when (ocp-in-indentation-p) (back-to-indentation))))

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1257, max open: 300)
  • ☑ change set a3170f4b-4c42-46c2-b16f-aecea008dc85 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots libocp-indent-ocaml-dbgsymapt install -t fresh-snapshots libocp-indent-ocaml-devapt install -t fresh-snapshots libocp-indent-ocamlapt install -t fresh-snapshots ocp-indent-dbgsymapt install -t fresh-snapshots ocp-indent

Lintian Result

Full worker log Full build log