caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocp-indent beta release
@ 2013-02-08 15:25 Louis Gesbert
  2013-02-08 15:55 ` Gabriel Kerneis
                   ` (6 more replies)
  0 siblings, 7 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-08 15:25 UTC (permalink / raw)
  To: caml-list

OCamlPro is proud to announce the beta-release of ocp-indent.

Ocp-indent is a simple tool, entirely written in OCaml, which sole purpose is to
indent OCaml code. It can plug-in seamlessly into emacs' tuareg mode, or be run
from vim.

You can try it now with:

$ opam install ocp-indent

$ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"

$ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs

$ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim' >>~/.vimrc


Or check it out at https://github.com/OCamlPro/ocp-indent



It presents many improvements over the tuareg indentation engine, a much better
understanding of the syntax, linear complexity, specific handling for many
cases. Also, it was intentionally provided with much less customisation options.

Feel free to submit any code snippet that is not indented to your taste, to help
us improve ocp-indent further.


Some comparison with tuareg on a few big OCaml projects can be seen at
http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
tests/blob/master/status.html


--
Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
@ 2013-02-08 15:55 ` Gabriel Kerneis
  2013-02-08 16:09   ` Louis Gesbert
  2013-02-08 16:02 ` Daniel Bünzli
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Gabriel Kerneis @ 2013-02-08 15:55 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

Hi,

On Fri, Feb 08, 2013 at 04:25:29PM +0100, Louis Gesbert wrote:
> Some comparison with tuareg on a few big OCaml projects can be seen at
> http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-tests/blob/master/status.html

How do you evaluate which line is "correctly" indented on this page?

Best,
-- 
Gabriel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
  2013-02-08 15:55 ` Gabriel Kerneis
@ 2013-02-08 16:02 ` Daniel Bünzli
  2013-02-08 16:22   ` Louis Gesbert
  2013-02-08 17:50 ` Romain Bardou
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Daniel Bünzli @ 2013-02-08 16:02 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

Hello, 

To which extents does it support the programming guidelines [1] ? 

Best,

Daniel

[1] http://caml.inria.fr/resources/doc/guides/guidelines.en.html



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:55 ` Gabriel Kerneis
@ 2013-02-08 16:09   ` Louis Gesbert
  0 siblings, 0 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-08 16:09 UTC (permalink / raw)
  To: Gabriel Kerneis; +Cc: caml-list

Le vendredi 8 février 2013 16:55:20, Gabriel Kerneis a écrit :
> Hi,
> 
> On Fri, Feb 08, 2013 at 04:25:29PM +0100, Louis Gesbert wrote:
> > Some comparison with tuareg on a few big OCaml projects can be seen at
> > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-tests/
> > blob/master/status.html
> 
> How do you evaluate which line is "correctly" indented on this page?
> 
> Best,

Well, the assumption, admittedly quite wrong, is that the existing source code 
is already "well" indented (ie, any change made by the indenter is wrong). That 
is why we should'nt aim for a 100% score in this table.

I take the opportunity to point out that most of these projects has probably 
been written using tuareg, which gives a certain bias. On the other hand, our 
unit tests (of which most have been written to show tuareg's weaknesses) have an 
opposite bias, and tuareg fails the vast majority of them.

--
Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 16:02 ` Daniel Bünzli
@ 2013-02-08 16:22   ` Louis Gesbert
  0 siblings, 0 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-08 16:22 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: caml-list

Le vendredi 8 février 2013 17:02:25, Daniel Bünzli a écrit :
> Hello,
> 
> To which extents does it support the programming guidelines [1] ?
> 
> Best,
> 
> Daniel
> 
> [1] http://caml.inria.fr/resources/doc/guides/guidelines.en.html

They should be fully supported -- please report a bug if you find any 
inconsistency.

One exception is that we indent match-cases if the match doesn't start the line, 
not just when it is after a let:

let x =
  y + match _ with
    | _ -> ...

this gives more readability IMHO

--
Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
  2013-02-08 15:55 ` Gabriel Kerneis
  2013-02-08 16:02 ` Daniel Bünzli
@ 2013-02-08 17:50 ` Romain Bardou
  2013-02-12 11:33   ` Louis Gesbert
  2013-02-08 18:10 ` Ashish Agarwal
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Romain Bardou @ 2013-02-08 17:50 UTC (permalink / raw)
  To: caml-list

I tried it very quickly, it seems to work fine.

I'm curious though, when did this way of indenting pattern-matching 
became a thing? When I started programming in OCaml, the default Tuareg 
behavior was:

match x with
   | A ->
       b

Now it seems everywhere I go it's like this never existed.

Cheers,

-- 
Romain Bardou

Le 08/02/2013 16:25, Louis Gesbert a écrit :
> OCamlPro is proud to announce the beta-release of ocp-indent.
>
> Ocp-indent is a simple tool, entirely written in OCaml, which sole purpose is to
> indent OCaml code. It can plug-in seamlessly into emacs' tuareg mode, or be run
> from vim.
>
> You can try it now with:
>
> $ opam install ocp-indent
>
> $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
>
> $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")'>>~/.emacs
>
> $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'>>~/.vimrc
>
>
> Or check it out at https://github.com/OCamlPro/ocp-indent
>
>
>
> It presents many improvements over the tuareg indentation engine, a much better
> understanding of the syntax, linear complexity, specific handling for many
> cases. Also, it was intentionally provided with much less customisation options.
>
> Feel free to submit any code snippet that is not indented to your taste, to help
> us improve ocp-indent further.
>
>
> Some comparison with tuareg on a few big OCaml projects can be seen at
> http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> tests/blob/master/status.html
>
>
> --
> Louis Gesbert, OCamlPro
>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
                   ` (2 preceding siblings ...)
  2013-02-08 17:50 ` Romain Bardou
@ 2013-02-08 18:10 ` Ashish Agarwal
  2013-02-08 18:19   ` Ashish Agarwal
  2013-02-12 10:42 ` Didier Remy
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Ashish Agarwal @ 2013-02-08 18:10 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]

I installed typerex and ocp-indent, but don't find ocp-indent.el. And opam
update says I'm up to date.

$ opam info typerex
             package: typerex
   installed-version: typerex.1.99.0-beta [4.00.1+short-types]
         description: Set of tools and libraries for OCaml, developed by
OCamlPro and INRIA

$ opam info ocp-indent
             package: ocp-indent
   installed-version: ocp-indent.0.1.0 [4.00.1+short-types]
         description: A simple tool to indent OCaml programs

$ cd ~/.opam
$ find . -name "ocp-indent.el"
(* no output *)


On Fri, Feb 8, 2013 at 10:25 AM, Louis Gesbert
<louis.gesbert@ocamlpro.com>wrote:

> OCamlPro is proud to announce the beta-release of ocp-indent.
>
> Ocp-indent is a simple tool, entirely written in OCaml, which sole purpose
> is to
> indent OCaml code. It can plug-in seamlessly into emacs' tuareg mode, or
> be run
> from vim.
>
> You can try it now with:
>
> $ opam install ocp-indent
>
> $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
>
> $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
>
> $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
> >>~/.vimrc
>
>
> Or check it out at https://github.com/OCamlPro/ocp-indent
>
>
>
> It presents many improvements over the tuareg indentation engine, a much
> better
> understanding of the syntax, linear complexity, specific handling for many
> cases. Also, it was intentionally provided with much less customisation
> options.
>
> Feel free to submit any code snippet that is not indented to your taste,
> to help
> us improve ocp-indent further.
>
>
> Some comparison with tuareg on a few big OCaml projects can be seen at
> http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> tests/blob/master/status.html
>
>
> --
> Louis Gesbert, OCamlPro
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 3190 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 18:10 ` Ashish Agarwal
@ 2013-02-08 18:19   ` Ashish Agarwal
  0 siblings, 0 replies; 24+ messages in thread
From: Ashish Agarwal @ 2013-02-08 18:19 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

On Fri, Feb 8, 2013 at 1:10 PM, Ashish Agarwal <agarwal1975@gmail.com>wrote:

I installed typerex and ocp-indent, but don't find ocp-indent.el.


My mistake... I didn't sync with the ocamlpro repo.

[-- Attachment #2: Type: text/html, Size: 497 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
                   ` (3 preceding siblings ...)
  2013-02-08 18:10 ` Ashish Agarwal
@ 2013-02-12 10:42 ` Didier Remy
  2013-02-12 11:20   ` Louis Gesbert
  2013-02-13  3:48 ` Ivan Gotovchits
  2013-02-15 13:57 ` [Caml-list] ocp-indent 1.0.0 release Louis Gesbert
  6 siblings, 1 reply; 24+ messages in thread
From: Didier Remy @ 2013-02-12 10:42 UTC (permalink / raw)
  To: caml-list


> OCamlPro is proud to announce the beta-release of ocp-indent.  Ocp-indent
> is a simple tool, entirely written in OCaml, which sole purpose is to
> indent OCaml code. It can plug-in seamlessly into emacs' tuareg mode, or
> be run from vim.

Why is the choice of tuareg-mode wired-in?
Is is possible to use ocp-indent on top of the default caml-mode?

         Didier

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-12 10:42 ` Didier Remy
@ 2013-02-12 11:20   ` Louis Gesbert
  2013-02-14 16:18     ` Daniel Bünzli
  0 siblings, 1 reply; 24+ messages in thread
From: Louis Gesbert @ 2013-02-12 11:20 UTC (permalink / raw)
  To: caml-list

> Why is the choice of tuareg-mode wired-in?
> Is is possible to use ocp-indent on top of the default caml-mode?

Hmm, good remark, there is no real reason for that except that we use tuareg-
mode. I'll see how to remove this dependency from our emacs script.

Thanks for the feedback,

--
Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 17:50 ` Romain Bardou
@ 2013-02-12 11:33   ` Louis Gesbert
  0 siblings, 0 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-12 11:33 UTC (permalink / raw)
  To: caml-list

You can get this behaviour with `ocp-indent --config with=3,match_clause=4`

The default behaviour was chosen to reflect the most common current indentation 
practices (and the guidelines, 
http://caml.inria.fr/resources/doc/guides/guidelines.en.html) ; I guess it was 
found that indenting the | doesn't improve readability and makes you run into 
the right margin more quickly.

--
Louis Gesbert

Le vendredi 8 février 2013 18:50:06, Romain Bardou a écrit :
> I tried it very quickly, it seems to work fine.
> 
> I'm curious though, when did this way of indenting pattern-matching
> became a thing? When I started programming in OCaml, the default Tuareg
> behavior was:
> 
> match x with
> 
>    | A ->
> 
>        b
> 
> Now it seems everywhere I go it's like this never existed.
> 
> Cheers,
> 
> > OCamlPro is proud to announce the beta-release of ocp-indent.
> > 
> > Ocp-indent is a simple tool, entirely written in OCaml, which sole
> > purpose is to indent OCaml code. It can plug-in seamlessly into emacs'
> > tuareg mode, or be run from vim.
> > 
> > You can try it now with:
> > 
> > $ opam install ocp-indent
> > 
> > $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
> > 
> > $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")'>>~/.emacs
> > 
> > $ echo 'autocmd FileType ocaml source
> > '"$INSTDIR"'/ocp-indent.vim'>>~/.vimrc
> > 
> > 
> > Or check it out at https://github.com/OCamlPro/ocp-indent
> > 
> > 
> > 
> > It presents many improvements over the tuareg indentation engine, a much
> > better understanding of the syntax, linear complexity, specific handling
> > for many cases. Also, it was intentionally provided with much less
> > customisation options.
> > 
> > Feel free to submit any code snippet that is not indented to your taste,
> > to help us improve ocp-indent further.
> > 
> > 
> > Some comparison with tuareg on a few big OCaml projects can be seen at
> > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> > tests/blob/master/status.html
> > 
> > 
> > --
> > Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
                   ` (4 preceding siblings ...)
  2013-02-12 10:42 ` Didier Remy
@ 2013-02-13  3:48 ` Ivan Gotovchits
  2013-02-13  9:00   ` Louis Gesbert
  2013-02-15 13:57 ` [Caml-list] ocp-indent 1.0.0 release Louis Gesbert
  6 siblings, 1 reply; 24+ messages in thread
From: Ivan Gotovchits @ 2013-02-13  3:48 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

Louis Gesbert <louis.gesbert@ocamlpro.com> writes:

> Ocp-indent is a simple tool, entirely written in OCaml, which sole purpose is to
> indent OCaml code. It can plug-in seamlessly into emacs' tuareg mode, or be run
> from vim.

1. Is it possible to use ocp-indent with typerex?

2. What about mly and mli files? Do the supported?

-- 
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
...."Have you mooed today?"...

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-13  3:48 ` Ivan Gotovchits
@ 2013-02-13  9:00   ` Louis Gesbert
  0 siblings, 0 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-13  9:00 UTC (permalink / raw)
  To: caml-list; +Cc: Ivan Gotovchits

1. Indeed, ocp-indent is compatible with typerex-mode

2.
* .mli are supported, just as .ml.
* mly are not handled at the moment, having a quite different syntax.
* mll are very usable with the upcoming --extend option, with a few glitches 
(toplevel 'let' constructs ending with an operator like '*' and opening brace 
of the footer).



Le Wednesday 13 February 2013 04:48:17, Ivan Gotovchits a écrit :
> Louis Gesbert <louis.gesbert@ocamlpro.com> writes:
> > Ocp-indent is a simple tool, entirely written in OCaml, which sole
> > purpose is to indent OCaml code. It can plug-in seamlessly into emacs'
> > tuareg mode, or be run from vim.
> 
> 1. Is it possible to use ocp-indent with typerex?
> 
> 2. What about mly and mli files? Do the supported?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-12 11:20   ` Louis Gesbert
@ 2013-02-14 16:18     ` Daniel Bünzli
  2013-02-15  0:00       ` Daniel Bünzli
  0 siblings, 1 reply; 24+ messages in thread
From: Daniel Bünzli @ 2013-02-14 16:18 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

Le mardi, 12 février 2013 à 12:20, Louis Gesbert a écrit :
> Hmm, good remark, there is no real reason for that except that we use tuareg-
> mode. I'll see how to remove this dependency from our emacs script.

I second that.  

By the way there's one big issue for me, in my whole code base I strictly stick to 80 columns and use the other acceptable convention mentioned here [1]. This means that I do not indent the top most cases so that you don't run into the 80 character limit too quickly.  

Here's what I mean:

let f = function
| A -> ...
| B -> ...

let f x = match x with
| A -> ...
| B -> ...

From a readability point of view I find that indenting the cases at that point is useless, wasteful and detrimental to code compactness. Is there any way to emulate that with ocp-indent (setting base to 0 breaks too many other patterns) ?  

Best,

Daniel

[1] http://caml.inria.fr/resources/doc/guides/guidelines.en.html#id158149

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-14 16:18     ` Daniel Bünzli
@ 2013-02-15  0:00       ` Daniel Bünzli
  2013-02-15 11:01         ` Louis Gesbert
  0 siblings, 1 reply; 24+ messages in thread
From: Daniel Bünzli @ 2013-02-15  0:00 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]

Le jeudi, 14 février 2013 à 17:18, Daniel Bünzli a écrit :
> By the way there's one big issue for me, in my whole code base I strictly stick to 80 columns and use the other acceptable convention mentioned here [1]. This means that I do not indent the top most cases so that you don't run into the 80 character limit too quickly.
>  
> Here's what I mean:
>  
> let f = function
> | A -> ...
> | B -> ...
>  
> let f x = match x with
> | A -> ...
> | B -> ...

In fact it's not only the top most cases. These ones:

let f =  
  let g = function  
  | A -> "A"
  | B -> "B"


  in
  g

also seem to be annoyingly indented to  

let f =  
  let g = function  
    | A -> "A"
    | B -> "B"
  in
  g



this really wastes too much space and is unusable for me, especially if you have local, nested function definitions.  

I have attached a file with the examples (email rendering is not very reliable). For me there should be a setting that lets that file unchanged.  

In typerex I could get this behaviour by having at least (don't remember exactly which conjunction does the thing):

(setq typerex-let-always-indent nil)
(setq typerex-with-indent 0)
(setq typerex-function-indent 0)
(setq typerex-fun-indent 0)
(setq typerex-type-indent 0)
(setq typerex-if-then-else-indent 0)



Best,

Daniel






[-- Attachment #2: fundefbycase.ml --]
[-- Type: application/octet-stream, Size: 383 bytes --]

let f x = match x with
| `A -> "A"
| `B -> "B"
    
let f = function
| `A -> "A"
| `B -> "B"
    
let f = fun x -> match x with
| `A -> "A"
| `B -> "B"
    
let f = 
  let g x = match x with
  | `A -> "A"
  | `B -> "B"
  in
  g
    
let f = 
  let g = function 
  | `A -> "A"
  | `B -> "B"
  in
  g
    
let f = 
  let g = fun x -> match x with
  | `A -> "A"
  | `B -> "B"
  in
  g


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-15  0:00       ` Daniel Bünzli
@ 2013-02-15 11:01         ` Louis Gesbert
  2013-02-15 11:30           ` Daniel Bünzli
  0 siblings, 1 reply; 24+ messages in thread
From: Louis Gesbert @ 2013-02-15 11:01 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: caml-list

Hi Daniel,

Well, I can't say I really agree with your readability argument -- «wasteful and 
detrimental to code compactness» :) -- but you know... matter of taste.

Anyway, you've been heard: there is now an option "with_never=true" that states 
exactly what you asked for (never indent after try/match with, or function). 
Your example code has been added to our tests with this option and passes just 
fine.

Best,
Louis


PS: concerned commit is here:
https://github.com/OCamlPro/ocp-
indent/commit/62012b5b5bb4f2ee76105ae1cd3bb08a224c631a

Le vendredi 15 février 2013 01:00:35, Daniel Bünzli a écrit :
> Le jeudi, 14 février 2013 à 17:18, Daniel Bünzli a écrit :
> > By the way there's one big issue for me, in my whole code base I strictly
> > stick to 80 columns and use the other acceptable convention mentioned
> > here [1]. This means that I do not indent the top most cases so that you
> > don't run into the 80 character limit too quickly.
> > 
> > Here's what I mean:
> > 
> > let f = function
> > 
> > | A -> ...
> > | B -> ...
> > 
> > let f x = match x with
> > 
> > | A -> ...
> > | B -> ...
> 
> In fact it's not only the top most cases. These ones:
> 
> let f =
>   let g = function
> 
>   | A -> "A"
>   | B -> "B"
> 
>   in
>   g
> 
> also seem to be annoyingly indented to
> 
> let f =
>   let g = function
> 
>     | A -> "A"
>     | B -> "B"
> 
>   in
>   g
> 
> 
> 
> this really wastes too much space and is unusable for me, especially if you
> have local, nested function definitions.
> 
> I have attached a file with the examples (email rendering is not very
> reliable). For me there should be a setting that lets that file unchanged.
> 
> In typerex I could get this behaviour by having at least (don't remember
> exactly which conjunction does the thing):
> 
> (setq typerex-let-always-indent nil)
> (setq typerex-with-indent 0)
> (setq typerex-function-indent 0)
> (setq typerex-fun-indent 0)
> (setq typerex-type-indent 0)
> (setq typerex-if-then-else-indent 0)
> 
> 
> 
> Best,
> 
> Daniel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent beta release
  2013-02-15 11:01         ` Louis Gesbert
@ 2013-02-15 11:30           ` Daniel Bünzli
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel Bünzli @ 2013-02-15 11:30 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

Cool thanks. 

Daniel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
                   ` (5 preceding siblings ...)
  2013-02-13  3:48 ` Ivan Gotovchits
@ 2013-02-15 13:57 ` Louis Gesbert
  2013-02-16 20:34   ` Niki Yoshiuchi
  6 siblings, 1 reply; 24+ messages in thread
From: Louis Gesbert @ 2013-02-15 13:57 UTC (permalink / raw)
  To: caml-list

Thanks for all the feedback and few bug reports during the past  week of beta-
test.

We can now announce the 1.0.0 release of ocp-indent, available on opam.

Enjoy!

--
Louis, OCamlPro

Le vendredi 8 février 2013 16:25:29, Louis Gesbert a écrit :
> OCamlPro is proud to announce the beta-release of ocp-indent.
> 
> Ocp-indent is a simple tool, entirely written in OCaml, which sole purpose
> is to indent OCaml code. It can plug-in seamlessly into emacs' tuareg
> mode, or be run from vim.
> 
> You can try it now with:
> 
> $ opam install ocp-indent
> 
> $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
> 
> $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
> 
> $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
> >>~/.vimrc
> 
> 
> Or check it out at https://github.com/OCamlPro/ocp-indent
> 
> 
> 
> It presents many improvements over the tuareg indentation engine, a much
> better understanding of the syntax, linear complexity, specific handling
> for many cases. Also, it was intentionally provided with much less
> customisation options.
> 
> Feel free to submit any code snippet that is not indented to your taste, to
> help us improve ocp-indent further.
> 
> 
> Some comparison with tuareg on a few big OCaml projects can be seen at
> http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> tests/blob/master/status.html
> 
> 
> --
> Louis Gesbert, OCamlPro

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-15 13:57 ` [Caml-list] ocp-indent 1.0.0 release Louis Gesbert
@ 2013-02-16 20:34   ` Niki Yoshiuchi
  2013-02-17 18:05     ` Raphael Proust
  0 siblings, 1 reply; 24+ messages in thread
From: Niki Yoshiuchi @ 2013-02-16 20:34 UTC (permalink / raw)
  To: Louis Gesbert; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2990 bytes --]

I've started using this with vim and I've noticed a few things.  I'm not
sure if it's by design or if they are bugs.

First, I have vim setup to use 4 spaces for indentation.  When editing an
OCaml file, it continues to respect the 4 space indent while writing code.
In other words, while writing code I'll end up with something like this
(dots represent spaces):

let my_fun f =
. . . . let nested_fun g =
. . . . . . . . (* content *)

However if I then select the text and and hit "=" it re-indents it using
two spaces per nesting level.

The second thing I've noticed is that "=" indents only relative to the
selected text.  In other words, if I have


let my_fun f =
. . let nested_fun g =
. . . . (* content *)
. . . . (* more content *)

and I hit "=" while the cursor is on the third line I end up with:

let my_fun f =
. . let nested_fun g =
(* content *)
. . . . (* more content *)

Doing something like "ggVG=" will properly indent the text.

Thanks for the great work on making OCaml more usable!  My code has never
looked cleaner.

-Niki Yoshiuchi

On Fri, Feb 15, 2013 at 8:57 AM, Louis Gesbert
<louis.gesbert@ocamlpro.com>wrote:

> Thanks for all the feedback and few bug reports during the past  week of
> beta-
> test.
>
> We can now announce the 1.0.0 release of ocp-indent, available on opam.
>
> Enjoy!
>
> --
> Louis, OCamlPro
>
> Le vendredi 8 février 2013 16:25:29, Louis Gesbert a écrit :
> > OCamlPro is proud to announce the beta-release of ocp-indent.
> >
> > Ocp-indent is a simple tool, entirely written in OCaml, which sole
> purpose
> > is to indent OCaml code. It can plug-in seamlessly into emacs' tuareg
> > mode, or be run from vim.
> >
> > You can try it now with:
> >
> > $ opam install ocp-indent
> >
> > $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
> >
> > $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
> >
> > $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
> > >>~/.vimrc
> >
> >
> > Or check it out at https://github.com/OCamlPro/ocp-indent
> >
> >
> >
> > It presents many improvements over the tuareg indentation engine, a much
> > better understanding of the syntax, linear complexity, specific handling
> > for many cases. Also, it was intentionally provided with much less
> > customisation options.
> >
> > Feel free to submit any code snippet that is not indented to your taste,
> to
> > help us improve ocp-indent further.
> >
> >
> > Some comparison with tuareg on a few big OCaml projects can be seen at
> > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> > tests/blob/master/status.html
> >
> >
> > --
> > Louis Gesbert, OCamlPro
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

[-- Attachment #2: Type: text/html, Size: 4116 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-16 20:34   ` Niki Yoshiuchi
@ 2013-02-17 18:05     ` Raphael Proust
  2013-02-17 18:30       ` Török Edwin
                         ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Raphael Proust @ 2013-02-17 18:05 UTC (permalink / raw)
  To: Niki Yoshiuchi; +Cc: caml-list

On Sat, Feb 16, 2013 at 8:34 PM, Niki Yoshiuchi <aplusbi@gmail.com> wrote:
> I've started using this with vim and I've noticed a few things.  I'm not
> sure if it's by design or if they are bugs.
>
> First, I have vim setup to use 4 spaces for indentation.  When editing an
> OCaml file, it continues to respect the 4 space indent while writing code.
> In other words, while writing code I'll end up with something like this
> (dots represent spaces):
>
> let my_fun f =
> . . . . let nested_fun g =
> . . . . . . . . (* content *)
>
> However if I then select the text and and hit "=" it re-indents it using two
> spaces per nesting level.

This is not a bug in either vim nor ocp-indent. It is a bug in your
configurations (they are not in sync). You can either setup ocp-indent
to use 4 spaces or vim to use 2. See `ocp-indent --config help` for
the former, and `:h tabstop` and `:h softtabstop` for the latter.

>
> The second thing I've noticed is that "=" indents only relative to the
> selected text.  In other words, if I have
>
>
> let my_fun f =
> . . let nested_fun g =
> . . . . (* content *)
> . . . . (* more content *)
>
> and I hit "=" while the cursor is on the third line I end up with:
>
> let my_fun f =
> . . let nested_fun g =
> (* content *)
> . . . . (* more content *)
>
> Doing something like "ggVG=" will properly indent the text.

This is the expected behaviour. ocp-indent is only given the selected
text and thus can only work correctly when receiving complete blocks.
(Indentation is relative to the first line of the chunk that is
passed.)

You can pass a full paragraph using `=ap` ("ap" stands for "a
paragraph", see `:h ap` for help). You can also use blocks. For more
information on these, see `:h text-objects`.

Note that you can do `gg=G` (move, action, move) instead of `ggvG=`
(move, mode, move, action). It is only marginally shorter but, more
importantly, it will preserve your `'<` and `'>` marks (see, `:h '>`
for more explanations). (And dually, you can replace `=ap` (action,
object) by `vap=` (mode, object, action).)

>
> Thanks for the great work on making OCaml more usable!  My code has never
> looked cleaner.
>
> -Niki Yoshiuchi
>
>
> On Fri, Feb 15, 2013 at 8:57 AM, Louis Gesbert <louis.gesbert@ocamlpro.com>
> wrote:
>>
>> Thanks for all the feedback and few bug reports during the past  week of
>> beta-
>> test.
>>
>> We can now announce the 1.0.0 release of ocp-indent, available on opam.
>>
>> Enjoy!
>>
>> --
>> Louis, OCamlPro
>>
>> Le vendredi 8 février 2013 16:25:29, Louis Gesbert a écrit :
>> > OCamlPro is proud to announce the beta-release of ocp-indent.
>> >
>> > Ocp-indent is a simple tool, entirely written in OCaml, which sole
>> > purpose
>> > is to indent OCaml code. It can plug-in seamlessly into emacs' tuareg
>> > mode, or be run from vim.
>> >
>> > You can try it now with:
>> >
>> > $ opam install ocp-indent
>> >
>> > $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
>> >
>> > $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
>> >
>> > $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
>> > >>~/.vimrc
>> >
>> >
>> > Or check it out at https://github.com/OCamlPro/ocp-indent
>> >
>> >
>> >
>> > It presents many improvements over the tuareg indentation engine, a much
>> > better understanding of the syntax, linear complexity, specific handling
>> > for many cases. Also, it was intentionally provided with much less
>> > customisation options.
>> >
>> > Feel free to submit any code snippet that is not indented to your taste,
>> > to
>> > help us improve ocp-indent further.
>> >
>> >
>> > Some comparison with tuareg on a few big OCaml projects can be seen at
>> > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
>> > tests/blob/master/status.html
>> >
>> >
>> > --
>> > Louis Gesbert, OCamlPro
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>



-- 
______________
Raphaël Proust

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-17 18:05     ` Raphael Proust
@ 2013-02-17 18:30       ` Török Edwin
  2013-02-18  9:50         ` Louis Gesbert
  2013-02-17 18:37       ` David Powers
  2013-02-17 23:51       ` Niki Yoshiuchi
  2 siblings, 1 reply; 24+ messages in thread
From: Török Edwin @ 2013-02-17 18:30 UTC (permalink / raw)
  To: caml-list

On 02/17/2013 08:05 PM, Raphael Proust wrote:
> On Sat, Feb 16, 2013 at 8:34 PM, Niki Yoshiuchi <aplusbi@gmail.com> wrote:
>>
>> The second thing I've noticed is that "=" indents only relative to the
>> selected text.  In other words, if I have
>>
>>
>> let my_fun f =
>> . . let nested_fun g =
>> . . . . (* content *)
>> . . . . (* more content *)
>>
>> and I hit "=" while the cursor is on the third line I end up with:
>>
>> let my_fun f =
>> . . let nested_fun g =
>> (* content *)
>> . . . . (* more content *)
>>
>> Doing something like "ggVG=" will properly indent the text.
> 
> This is the expected behaviour. ocp-indent is only given the selected
> text and thus can only work correctly when receiving complete blocks.
> (Indentation is relative to the first line of the chunk that is
> passed.)

Could ocp-indent consider the indentation of the first line to be correct when it is working on incomplete blocks, and indent everything in relation to that?
i.e. call ocp-indent with a new flag --incomplete, and if first line got 2 spaces, then have the starting indentation be 2 spaces, and then increase/decrease indentation relative to that.
That seems how vim's '=' works for other languages, or without ocp-indent.

Best regards,
--Edwin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-17 18:05     ` Raphael Proust
  2013-02-17 18:30       ` Török Edwin
@ 2013-02-17 18:37       ` David Powers
  2013-02-17 23:51       ` Niki Yoshiuchi
  2 siblings, 0 replies; 24+ messages in thread
From: David Powers @ 2013-02-17 18:37 UTC (permalink / raw)
  To: Raphael Proust; +Cc: Niki Yoshiuchi, caml-list

A nice binding might be something like  

nnoremap == gg=G''

which will rebind the normal == (which isn't that useful here) to reinvent the whole file and return he cursor to the line and column it was on.

-David  


On Sunday, February 17, 2013 at 1:05 PM, Raphael Proust wrote:

> On Sat, Feb 16, 2013 at 8:34 PM, Niki Yoshiuchi <aplusbi@gmail.com (mailto:aplusbi@gmail.com)> wrote:
> > I've started using this with vim and I've noticed a few things. I'm not
> > sure if it's by design or if they are bugs.
> >  
> > First, I have vim setup to use 4 spaces for indentation. When editing an
> > OCaml file, it continues to respect the 4 space indent while writing code.
> > In other words, while writing code I'll end up with something like this
> > (dots represent spaces):
> >  
> > let my_fun f =
> > . . . . let nested_fun g =
> > . . . . . . . . (* content *)
> >  
> > However if I then select the text and and hit "=" it re-indents it using two
> > spaces per nesting level.
>  
>  
>  
> This is not a bug in either vim nor ocp-indent. It is a bug in your
> configurations (they are not in sync). You can either setup ocp-indent
> to use 4 spaces or vim to use 2. See `ocp-indent --config help` for
> the former, and `:h tabstop` and `:h softtabstop` for the latter.
>  
> >  
> > The second thing I've noticed is that "=" indents only relative to the
> > selected text. In other words, if I have
> >  
> >  
> > let my_fun f =
> > . . let nested_fun g =
> > . . . . (* content *)
> > . . . . (* more content *)
> >  
> > and I hit "=" while the cursor is on the third line I end up with:
> >  
> > let my_fun f =
> > . . let nested_fun g =
> > (* content *)
> > . . . . (* more content *)
> >  
> > Doing something like "ggVG=" will properly indent the text.
>  
> This is the expected behaviour. ocp-indent is only given the selected
> text and thus can only work correctly when receiving complete blocks.
> (Indentation is relative to the first line of the chunk that is
> passed.)
>  
> You can pass a full paragraph using `=ap` ("ap" stands for "a
> paragraph", see `:h ap` for help). You can also use blocks. For more
> information on these, see `:h text-objects`.
>  
> Note that you can do `gg=G` (move, action, move) instead of `ggvG=`
> (move, mode, move, action). It is only marginally shorter but, more
> importantly, it will preserve your `'<` and `'>` marks (see, `:h '>`
> for more explanations). (And dually, you can replace `=ap` (action,
> object) by `vap=` (mode, object, action).)
>  
> >  
> > Thanks for the great work on making OCaml more usable! My code has never
> > looked cleaner.
> >  
> > -Niki Yoshiuchi
> >  
> >  
> > On Fri, Feb 15, 2013 at 8:57 AM, Louis Gesbert <louis.gesbert@ocamlpro.com (mailto:louis.gesbert@ocamlpro.com)>
> > wrote:
> > >  
> > > Thanks for all the feedback and few bug reports during the past week of
> > > beta-
> > > test.
> > >  
> > > We can now announce the 1.0.0 release of ocp-indent, available on opam.
> > >  
> > > Enjoy!
> > >  
> > > --
> > > Louis, OCamlPro
> > >  
> > > Le vendredi 8 février 2013 16:25:29, Louis Gesbert a écrit :
> > > > OCamlPro is proud to announce the beta-release of ocp-indent.
> > > >  
> > > > Ocp-indent is a simple tool, entirely written in OCaml, which sole
> > > > purpose
> > > > is to indent OCaml code. It can plug-in seamlessly into emacs' tuareg
> > > > mode, or be run from vim.
> > > >  
> > > > You can try it now with:
> > > >  
> > > > $ opam install ocp-indent
> > > >  
> > > > $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
> > > >  
> > > > $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
> > > >  
> > > > $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
> > > > > > ~/.vimrc
> > > > >  
> > > >  
> > > >  
> > > >  
> > > >  
> > > > Or check it out at https://github.com/OCamlPro/ocp-indent
> > > >  
> > > >  
> > > >  
> > > > It presents many improvements over the tuareg indentation engine, a much
> > > > better understanding of the syntax, linear complexity, specific handling
> > > > for many cases. Also, it was intentionally provided with much less
> > > > customisation options.
> > > >  
> > > > Feel free to submit any code snippet that is not indented to your taste,
> > > > to
> > > > help us improve ocp-indent further.
> > > >  
> > > >  
> > > > Some comparison with tuareg on a few big OCaml projects can be seen at
> > > > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> > > > tests/blob/master/status.html
> > > >  
> > > >  
> > > > --
> > > > Louis Gesbert, OCamlPro
> > >  
> > >  
> > >  
> > > --
> > > Caml-list mailing list. Subscription management and archives:
> > > https://sympa.inria.fr/sympa/arc/caml-list
> > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> > > Bug reports: http://caml.inria.fr/bin/caml-bugs
> >  
>  
>  
>  
>  
>  
> --  
> ______________
> Raphaël Proust
>  
> --  
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-17 18:05     ` Raphael Proust
  2013-02-17 18:30       ` Török Edwin
  2013-02-17 18:37       ` David Powers
@ 2013-02-17 23:51       ` Niki Yoshiuchi
  2 siblings, 0 replies; 24+ messages in thread
From: Niki Yoshiuchi @ 2013-02-17 23:51 UTC (permalink / raw)
  To: Raphael Proust; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 4793 bytes --]

Thanks for the clarification!

I might spend some time working on changing the behavior in vim
(particularly for indenting single lines) if other people are also
interested.

On Sun, Feb 17, 2013 at 1:05 PM, Raphael Proust <raphlalou@gmail.com> wrote:

> On Sat, Feb 16, 2013 at 8:34 PM, Niki Yoshiuchi <aplusbi@gmail.com> wrote:
> > I've started using this with vim and I've noticed a few things.  I'm not
> > sure if it's by design or if they are bugs.
> >
> > First, I have vim setup to use 4 spaces for indentation.  When editing an
> > OCaml file, it continues to respect the 4 space indent while writing
> code.
> > In other words, while writing code I'll end up with something like this
> > (dots represent spaces):
> >
> > let my_fun f =
> > . . . . let nested_fun g =
> > . . . . . . . . (* content *)
> >
> > However if I then select the text and and hit "=" it re-indents it using
> two
> > spaces per nesting level.
>
> This is not a bug in either vim nor ocp-indent. It is a bug in your
> configurations (they are not in sync). You can either setup ocp-indent
> to use 4 spaces or vim to use 2. See `ocp-indent --config help` for
> the former, and `:h tabstop` and `:h softtabstop` for the latter.
>
> >
> > The second thing I've noticed is that "=" indents only relative to the
> > selected text.  In other words, if I have
> >
> >
> > let my_fun f =
> > . . let nested_fun g =
> > . . . . (* content *)
> > . . . . (* more content *)
> >
> > and I hit "=" while the cursor is on the third line I end up with:
> >
> > let my_fun f =
> > . . let nested_fun g =
> > (* content *)
> > . . . . (* more content *)
> >
> > Doing something like "ggVG=" will properly indent the text.
>
> This is the expected behaviour. ocp-indent is only given the selected
> text and thus can only work correctly when receiving complete blocks.
> (Indentation is relative to the first line of the chunk that is
> passed.)
>
> You can pass a full paragraph using `=ap` ("ap" stands for "a
> paragraph", see `:h ap` for help). You can also use blocks. For more
> information on these, see `:h text-objects`.
>
> Note that you can do `gg=G` (move, action, move) instead of `ggvG=`
> (move, mode, move, action). It is only marginally shorter but, more
> importantly, it will preserve your `'<` and `'>` marks (see, `:h '>`
> for more explanations). (And dually, you can replace `=ap` (action,
> object) by `vap=` (mode, object, action).)
>
> >
> > Thanks for the great work on making OCaml more usable!  My code has never
> > looked cleaner.
> >
> > -Niki Yoshiuchi
> >
> >
> > On Fri, Feb 15, 2013 at 8:57 AM, Louis Gesbert <
> louis.gesbert@ocamlpro.com>
> > wrote:
> >>
> >> Thanks for all the feedback and few bug reports during the past  week of
> >> beta-
> >> test.
> >>
> >> We can now announce the 1.0.0 release of ocp-indent, available on opam.
> >>
> >> Enjoy!
> >>
> >> --
> >> Louis, OCamlPro
> >>
> >> Le vendredi 8 février 2013 16:25:29, Louis Gesbert a écrit :
> >> > OCamlPro is proud to announce the beta-release of ocp-indent.
> >> >
> >> > Ocp-indent is a simple tool, entirely written in OCaml, which sole
> >> > purpose
> >> > is to indent OCaml code. It can plug-in seamlessly into emacs' tuareg
> >> > mode, or be run from vim.
> >> >
> >> > You can try it now with:
> >> >
> >> > $ opam install ocp-indent
> >> >
> >> > $ INSTDIR="$(opam config var prefix)/share/typerex/ocp-indent"
> >> >
> >> > $ echo '(load-file "'"$INSTDIR/ocp-indent.el"'")' >>~/.emacs
> >> >
> >> > $ echo 'autocmd FileType ocaml source '"$INSTDIR"'/ocp-indent.vim'
> >> > >>~/.vimrc
> >> >
> >> >
> >> > Or check it out at https://github.com/OCamlPro/ocp-indent
> >> >
> >> >
> >> >
> >> > It presents many improvements over the tuareg indentation engine, a
> much
> >> > better understanding of the syntax, linear complexity, specific
> handling
> >> > for many cases. Also, it was intentionally provided with much less
> >> > customisation options.
> >> >
> >> > Feel free to submit any code snippet that is not indented to your
> taste,
> >> > to
> >> > help us improve ocp-indent further.
> >> >
> >> >
> >> > Some comparison with tuareg on a few big OCaml projects can be seen at
> >> > http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-
> >> > tests/blob/master/status.html
> >> >
> >> >
> >> > --
> >> > Louis Gesbert, OCamlPro
> >>
> >> --
> >> Caml-list mailing list.  Subscription management and archives:
> >> https://sympa.inria.fr/sympa/arc/caml-list
> >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> >> Bug reports: http://caml.inria.fr/bin/caml-bugs
> >
> >
>
>
>
> --
> ______________
> Raphaël Proust
>

[-- Attachment #2: Type: text/html, Size: 6725 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Caml-list] ocp-indent 1.0.0 release
  2013-02-17 18:30       ` Török Edwin
@ 2013-02-18  9:50         ` Louis Gesbert
  0 siblings, 0 replies; 24+ messages in thread
From: Louis Gesbert @ 2013-02-18  9:50 UTC (permalink / raw)
  To: caml-list; +Cc: Török Edwin

You can use the --lines option for that purpose: it will assume that all lines 
not in the interval are correctly indented, and indent the lines in the 
interval relative to that (to some extent, see 
https://github.com/OCamlPro/ocp-indent/issues/39).

In your example, you could use '--lines 2-'

However, that supposes that the block you submit is more or less syntactically 
correct. You can also submit the whole file with '--lines <current-line>' to 
guarantee the syntax but indent only the current line; that is how it is done 
in the emacs mode when you press TAB.

Don't hesitate to submit on https://github.com/OCamlPro/ocp-
indent/issues?state=open for further discussion if you are reluctant on 
spamming the caml-list.

--
Louis, OCamlPro

Le Sunday 17 February 2013 19:30:51, Török Edwin a écrit :
> On 02/17/2013 08:05 PM, Raphael Proust wrote:
> > On Sat, Feb 16, 2013 at 8:34 PM, Niki Yoshiuchi <aplusbi@gmail.com> wrote:
> >> The second thing I've noticed is that "=" indents only relative to the
> >> selected text.  In other words, if I have
> >> 
> >> 
> >> let my_fun f =
> >> . . let nested_fun g =
> >> . . . . (* content *)
> >> . . . . (* more content *)
> >> 
> >> and I hit "=" while the cursor is on the third line I end up with:
> >> 
> >> let my_fun f =
> >> . . let nested_fun g =
> >> (* content *)
> >> . . . . (* more content *)
> >> 
> >> Doing something like "ggVG=" will properly indent the text.
> > 
> > This is the expected behaviour. ocp-indent is only given the selected
> > text and thus can only work correctly when receiving complete blocks.
> > (Indentation is relative to the first line of the chunk that is
> > passed.)
> 
> Could ocp-indent consider the indentation of the first line to be correct
> when it is working on incomplete blocks, and indent everything in relation
> to that? i.e. call ocp-indent with a new flag --incomplete, and if first
> line got 2 spaces, then have the starting indentation be 2 spaces, and
> then increase/decrease indentation relative to that. That seems how vim's
> '=' works for other languages, or without ocp-indent.
> 
> Best regards,
> --Edwin

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2013-02-18  9:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 15:25 [Caml-list] ocp-indent beta release Louis Gesbert
2013-02-08 15:55 ` Gabriel Kerneis
2013-02-08 16:09   ` Louis Gesbert
2013-02-08 16:02 ` Daniel Bünzli
2013-02-08 16:22   ` Louis Gesbert
2013-02-08 17:50 ` Romain Bardou
2013-02-12 11:33   ` Louis Gesbert
2013-02-08 18:10 ` Ashish Agarwal
2013-02-08 18:19   ` Ashish Agarwal
2013-02-12 10:42 ` Didier Remy
2013-02-12 11:20   ` Louis Gesbert
2013-02-14 16:18     ` Daniel Bünzli
2013-02-15  0:00       ` Daniel Bünzli
2013-02-15 11:01         ` Louis Gesbert
2013-02-15 11:30           ` Daniel Bünzli
2013-02-13  3:48 ` Ivan Gotovchits
2013-02-13  9:00   ` Louis Gesbert
2013-02-15 13:57 ` [Caml-list] ocp-indent 1.0.0 release Louis Gesbert
2013-02-16 20:34   ` Niki Yoshiuchi
2013-02-17 18:05     ` Raphael Proust
2013-02-17 18:30       ` Török Edwin
2013-02-18  9:50         ` Louis Gesbert
2013-02-17 18:37       ` David Powers
2013-02-17 23:51       ` Niki Yoshiuchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).