Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line/region indentation feature (emacs integration) #1207

Closed

Conversation

gpetiot
Copy link
Collaborator

@gpetiot gpetiot commented Jan 15, 2020

the workflow is:

  • dune build @install && dune install
  • add (require 'ocamlformat) to your .emacs

Disclaimer: so far what it does is applying the indentation of the (virtually) formatted output to the unformatted input, so if you break a line like this you can observe cases like:

let foo =
foooo
|> bar

because once formatted it is formatted on a single line (indented to 0)

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a nice feature ! But the fact that you have to give it line numbers in the formatted output makes it unusable, I think.
How hard it is to fix that ?

@emillon
Copy link
Collaborator

emillon commented Jan 16, 2020

I agree that we'll need something like this, but it's not super clear to me how much needs to be done in ocamlformat and how much will be done by the editor.

Editor integration will be fairly large amount of work, and I think we need to step back a bit from the code and work out a spec first, and see what kind of features we'll need based on that. Then we'll be able to iterate on both. We don't want to ship a new option that will end up not being useful.

@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 91845d0 to f64cf4d Compare February 17, 2020 18:13
@gpetiot gpetiot changed the title Return the indentation of a given line (new option --indent) [WIP] Return the indentation of a given line (new option --indent) Feb 18, 2020
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 521d3e0 to 971b725 Compare April 21, 2020 14:53
@gpetiot gpetiot changed the title [WIP] Return the indentation of a given line (new option --indent) Return the indentation of a given line (new option --indent) Apr 21, 2020
@gpetiot gpetiot marked this pull request as draft April 21, 2020 15:56
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 6973351 to 9037a70 Compare April 28, 2020 15:30
@gpetiot gpetiot changed the title Return the indentation of a given line (new option --indent) Return the indentation of a given set of lines (new option --numeric) Apr 28, 2020
@gpetiot gpetiot changed the title Return the indentation of a given set of lines (new option --numeric) Return the indentation of a line range (new option --numeric) Apr 28, 2020
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 081bc88 to e4c6998 Compare May 5, 2020 11:44
@gpetiot gpetiot changed the title Return the indentation of a line range (new option --numeric) Return the indentation of a line range (--numeric) May 5, 2020
@gpetiot gpetiot marked this pull request as ready for review May 5, 2020 12:20
@gpetiot
Copy link
Collaborator Author

gpetiot commented May 5, 2020

For reference there is a PR on opam-user-setup to add ocamlformat: ocaml-opam/opam-user-setup#48 I'm not familiar with the way it works but I'm not sure there is an easy way to switch from ocp-indent to ocamlformat in this tool. I'm still digging but if someone has experience with this feel free to help :)

@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch 4 times, most recently from abf0d2e to dd4f310 Compare May 13, 2020 12:03
@gpetiot gpetiot marked this pull request as draft May 13, 2020 12:15
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch 2 times, most recently from 558d948 to b284293 Compare May 13, 2020 18:10
@gpetiot gpetiot marked this pull request as ready for review May 13, 2020 18:11
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch 3 times, most recently from b3cc4cb to d213d63 Compare May 15, 2020 13:53
@gpetiot gpetiot marked this pull request as draft May 18, 2020 09:46
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch 6 times, most recently from 3617ec0 to a59e3c6 Compare October 12, 2020 13:42
@gpetiot gpetiot marked this pull request as draft December 23, 2020 17:39
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from a59e3c6 to 76ffd29 Compare December 23, 2020 19:39
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 76ffd29 to 64ce012 Compare January 4, 2021 18:38
@gpetiot gpetiot marked this pull request as ready for review January 5, 2021 09:51
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 64ce012 to 33567ff Compare January 11, 2021 13:17
@gpetiot gpetiot force-pushed the ocamlformat-indent-for-editor branch from 33567ff to 08c8528 Compare January 25, 2021 14:50
@gpetiot
Copy link
Collaborator Author

gpetiot commented Jan 26, 2021

I've reused some code from #1188 to reduce the time overhead of this feature, but there is still too much overhead compared to the current reindent feature in emacs.

@gpetiot
Copy link
Collaborator Author

gpetiot commented Mar 8, 2021

Replaced by #1609

@gpetiot gpetiot closed this Mar 8, 2021
@gpetiot gpetiot deleted the ocamlformat-indent-for-editor branch March 8, 2021 13:27
@gpetiot gpetiot restored the ocamlformat-indent-for-editor branch March 30, 2021 10:25
@gpetiot gpetiot deleted the ocamlformat-indent-for-editor branch March 27, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants