* [Caml-list] Tuareg mode: Indentation of application arguments @ 2012-09-12 14:58 Romain Bardou [not found] ` <20120917.222210.832076572642519350.Christophe.Troestler@umons.ac.be> 0 siblings, 1 reply; 10+ messages in thread From: Romain Bardou @ 2012-09-12 14:58 UTC (permalink / raw) To: caml-list Hello Caml-list, I have finally took the time to configure tuareg to correctly indent after a "| ... ->" clause. After several years of doing it by hand, this feels soooo much better :) To do this I had to add "(setq tuareg-use-smie t)" to my .emacs (which I found a little confusing, by the way). However, now it's indentation of application arguments which is messed up (to my tastes). Let's say I am writing: a_very_long_function_name argument_1 argument_2 argument_3 argument_4 Now I want to put argument_4 on a new line. Before, I would obtain: a_very_long_function_name argument_1 argument_2 argument_3 argument_4 which I liked. Now, I obtain: a_very_long_function_name argument_1 argument_2 argument_3 argument_4 Note that if I put all arguments on their own lines, indentation does not depend on the function name: a_very_long_function_name argument_1 argument_2 argument_3 argument_4 I did not find any variable controlling this behavior in the tuareg group. Do you know how I can obtain my beloved behavior back? Or is it a bug, in which case I should submit a bug report? The reason I don't like this behavior is that it causes several issues: - changing one function name would imply that one would have to reindent everything (non-local indentation: bad!); - the indentation is not simply "indentation of previous line + N" where N is the same everywhere (complex indentation rule: bad!); - the indentation size may be very long (sudden-death indentation: bad!). My version of tuareg is 2.0.6. Cheers, -- Romain Bardou ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20120917.222210.832076572642519350.Christophe.Troestler@umons.ac.be>]
* [Caml-list] Re: Tuareg mode: Indentation of application arguments [not found] ` <20120917.222210.832076572642519350.Christophe.Troestler@umons.ac.be> @ 2012-09-18 3:08 ` Stefan Monnier 2012-09-21 13:42 ` [Caml-list] " Romain Bardou 1 sibling, 0 replies; 10+ messages in thread From: Stefan Monnier @ 2012-09-18 3:08 UTC (permalink / raw) To: caml-list >> Now I want to put argument_4 on a new line. Before, I would obtain: >> >> a_very_long_function_name argument_1 argument_2 argument_3 >> argument_4 >> >> which I liked. Now, I obtain: >> >> a_very_long_function_name argument_1 argument_2 argument_3 >> argument_4 >> >> Note that if I put all arguments on their own lines, indentation does >> not depend on the function name: >> >> a_very_long_function_name >> argument_1 >> argument_2 >> argument_3 >> argument_4 >> >> I did not find any variable controlling this behavior in the tuareg >> group. The nice thing about this behavior is that you don't need any config var to control it: just split your lines at a different place instead. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments [not found] ` <20120917.222210.832076572642519350.Christophe.Troestler@umons.ac.be> 2012-09-18 3:08 ` [Caml-list] " Stefan Monnier @ 2012-09-21 13:42 ` Romain Bardou 2012-09-21 20:11 ` Kristopher Micinski 1 sibling, 1 reply; 10+ messages in thread From: Romain Bardou @ 2012-09-21 13:42 UTC (permalink / raw) To: Christophe TROESTLER; +Cc: caml-list > a configuration variable to change this behavior. (BTW, do you know > that M-q re-indent the current expression, so re-indenting after a name > change is effortless.) I know about M-q but I disagree that it is effortless: if you change a variable name, and this name is used in N places, you have to go to all those N places and re-indent there. Note that those N places can be different files. Cheers, -- Romain ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-21 13:42 ` [Caml-list] " Romain Bardou @ 2012-09-21 20:11 ` Kristopher Micinski 2012-09-22 13:22 ` Romain Bardou 0 siblings, 1 reply; 10+ messages in thread From: Kristopher Micinski @ 2012-09-21 20:11 UTC (permalink / raw) To: Romain Bardou; +Cc: Christophe TROESTLER, caml-list On Fri, Sep 21, 2012 at 9:42 AM, Romain Bardou <romain.bardou@inria.fr> wrote: >> a configuration variable to change this behavior. (BTW, do you know >> that M-q re-indent the current expression, so re-indenting after a name >> change is effortless.) > > > I know about M-q but I disagree that it is effortless: if you change a > variable name, and this name is used in N places, you have to go to all > those N places and re-indent there. Note that those N places can be > different files. > Hmm.... why don't you simply try an indent-buffer, ...? http://emacsblog.org/2007/01/17/indent-whole-buffer/ If I have a large amount of stuff I need to reindent I either select and indent-region, or write some elisp to hack things up as needed.. kris ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-21 20:11 ` Kristopher Micinski @ 2012-09-22 13:22 ` Romain Bardou 2012-09-22 13:53 ` Dmitry Grebeniuk ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Romain Bardou @ 2012-09-22 13:22 UTC (permalink / raw) To: Kristopher Micinski; +Cc: caml-list Le 21/09/2012 22:11, Kristopher Micinski a écrit : > On Fri, Sep 21, 2012 at 9:42 AM, Romain Bardou<romain.bardou@inria.fr> wrote: >>> a configuration variable to change this behavior. (BTW, do you know >>> that M-q re-indent the current expression, so re-indenting after a name >>> change is effortless.) >> >> >> I know about M-q but I disagree that it is effortless: if you change a >> variable name, and this name is used in N places, you have to go to all >> those N places and re-indent there. Note that those N places can be >> different files. >> > > Hmm.... why don't you simply try an indent-buffer, ...? > > http://emacsblog.org/2007/01/17/indent-whole-buffer/ > > If I have a large amount of stuff I need to reindent I either select > and indent-region, or write some elisp to hack things up as needed.. > > kris Thank you for your input, Kristopher. One big issue I have with indent-buffer (and also with M-q, actually) is that it will reindent stuff I have indented by hand to bypass some rules of Tuareg I don't like. Even if I had an "indent correctly and instantly all files of my project" button, I still would not find the current indentation rule for application acceptable. I believe that good indentation rules should not rely on automation to actually be usable. I'm not fluent at all with elisp and that's not something I am really interested in learning. That's just personal taste really though. Cheers, -- Romain Bardou ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-22 13:22 ` Romain Bardou @ 2012-09-22 13:53 ` Dmitry Grebeniuk 2012-09-22 18:13 ` Kristopher Micinski 2012-10-08 15:17 ` [Caml-list] " Stefan Monnier 2 siblings, 0 replies; 10+ messages in thread From: Dmitry Grebeniuk @ 2012-09-22 13:53 UTC (permalink / raw) To: Romain Bardou Hello. > that it will reindent stuff I have indented by hand to bypass some rules of > Tuareg I don't like. > I believe that good indentation rules should not rely on > automation to actually be usable. This is the common problem of all IDE's for OCaml I've tried, strangely. For example, TypeRex, good IDE, lacks an option to disable autoindentation, so I doubt whether I'll be fighting with autoindentation or will stop to use TypeRex at all in some near future. (of course I filed a github issue, it was 2 months ago, https://github.com/OCamlPro/typerex/issues/58 , still no reaction.) I don't want to learn elisp to fix this, too. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-22 13:22 ` Romain Bardou 2012-09-22 13:53 ` Dmitry Grebeniuk @ 2012-09-22 18:13 ` Kristopher Micinski 2012-09-23 0:27 ` Edgar Friendly 2012-10-08 15:17 ` [Caml-list] " Stefan Monnier 2 siblings, 1 reply; 10+ messages in thread From: Kristopher Micinski @ 2012-09-22 18:13 UTC (permalink / raw) To: Romain Bardou; +Cc: caml-list On Sat, Sep 22, 2012 at 9:22 AM, Romain Bardou <romain.bardou@inria.fr> > Thank you for your input, Kristopher. > > One big issue I have with indent-buffer (and also with M-q, actually) is > that it will reindent stuff I have indented by hand to bypass some rules of > Tuareg I don't like. > > Even if I had an "indent correctly and instantly all files of my project" > button, I still would not find the current indentation rule for application > acceptable. I believe that good indentation rules should not rely on > automation to actually be usable. > > I'm not fluent at all with elisp and that's not something I am really > interested in learning. > > That's just personal taste really though. > > Cheers, I completely understand that: indentation is something that requires human intelligence (and good indentation is an art rather than science). For the same reasons I do not indent a whole buffer at once, usually.. FYI some open source projects have as part of their build process a call to GNU indent, super annoying when indentation is not as you describe.. That being said, if there is a part of tuareg mode that you need to modify to accommodate your needs (the change of a variable name, as you mention), hacking on the elisp might be preferable. And yes, I understand emacs lisp is this somewhat scary and involved language, more for reasons related to emacs (as an API) rather than anything having to do with lisp.. :-/ kris ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-22 18:13 ` Kristopher Micinski @ 2012-09-23 0:27 ` Edgar Friendly 2012-09-23 1:18 ` Kristopher Micinski 0 siblings, 1 reply; 10+ messages in thread From: Edgar Friendly @ 2012-09-23 0:27 UTC (permalink / raw) To: caml-list On 9/22/2012 2:13 PM, Kristopher Micinski wrote: > ... indentation is something that requires > human intelligence (and good indentation is an art rather than > science). I admit that under some circumstances, code can be made easier to read by giving it crafted indentation. But having a single indentation standard (and probably code layout) for all OCaml code would be better. In exchange for the occasional inability to indent code for extra readability (maybe comments would suffice instead), we would gain a community-wide improvement in our ability to read each others' code. E. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Caml-list] Tuareg mode: Indentation of application arguments 2012-09-23 0:27 ` Edgar Friendly @ 2012-09-23 1:18 ` Kristopher Micinski 0 siblings, 0 replies; 10+ messages in thread From: Kristopher Micinski @ 2012-09-23 1:18 UTC (permalink / raw) To: Edgar Friendly; +Cc: caml-list On Sat, Sep 22, 2012 at 8:27 PM, Edgar Friendly <thelema314@gmail.com> wrote: > On 9/22/2012 2:13 PM, Kristopher Micinski wrote: >> >> ... indentation is something that requires >> >> human intelligence (and good indentation is an art rather than >> science). > > I admit that under some circumstances, code can be made easier to read by > giving it crafted indentation. But having a single indentation standard (and > probably code layout) for all OCaml code would be better. In exchange for > the occasional inability to indent code for extra readability (maybe > comments would suffice instead), we would gain a community-wide improvement > in our ability to read each others' code. > > E. > To be honest, most of the time it doesn't matter, because whoever you work for will enforce a coding standard... kris ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Caml-list] Re: Tuareg mode: Indentation of application arguments 2012-09-22 13:22 ` Romain Bardou 2012-09-22 13:53 ` Dmitry Grebeniuk 2012-09-22 18:13 ` Kristopher Micinski @ 2012-10-08 15:17 ` Stefan Monnier 2 siblings, 0 replies; 10+ messages in thread From: Stefan Monnier @ 2012-10-08 15:17 UTC (permalink / raw) To: caml-list > One big issue I have with indent-buffer (and also with M-q, actually) is > that it will reindent stuff I have indented by hand to bypass some rules of > Tuareg I don't like. If the places where you need to override Tuareg's indentation are very few, and if you use Tuareg's SMIE indenter, then you might be able to use the (* fixindent *) comment, which tells Tuareg to not mess with this line's indentation. Lots of "if"s, I know. But for now, it's best I could come up with. Of course, maybe the particular indentation you want to use could be mechanized as well, so you might want to report the "poorly indented" cases as bugs. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-10-08 15:17 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-09-12 14:58 [Caml-list] Tuareg mode: Indentation of application arguments Romain Bardou [not found] ` <20120917.222210.832076572642519350.Christophe.Troestler@umons.ac.be> 2012-09-18 3:08 ` [Caml-list] " Stefan Monnier 2012-09-21 13:42 ` [Caml-list] " Romain Bardou 2012-09-21 20:11 ` Kristopher Micinski 2012-09-22 13:22 ` Romain Bardou 2012-09-22 13:53 ` Dmitry Grebeniuk 2012-09-22 18:13 ` Kristopher Micinski 2012-09-23 0:27 ` Edgar Friendly 2012-09-23 1:18 ` Kristopher Micinski 2012-10-08 15:17 ` [Caml-list] " Stefan Monnier
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox