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

how can I normalize elm indentation to standard spacing #125

Open
buhman opened this issue Oct 29, 2017 · 8 comments
Open

how can I normalize elm indentation to standard spacing #125

buhman opened this issue Oct 29, 2017 · 8 comments

Comments

@buhman
Copy link

buhman commented Oct 29, 2017

https://ptpb.pw/oVV2.gif

I expect 4 spaces, but I get very strange combinations of 6, 2, and 1-space, depending on moon phase and cosmic rays.

@purcell
Copy link
Collaborator

purcell commented Oct 29, 2017

What you're seeing is different levels of "bounce indenting" in order to achieve alignment with elements such as the empty list on the line above. If you want to disable that, it looks like you can (add-hook 'elm-mode-hook 'turn-off-elm-indent).

@purcell
Copy link
Collaborator

purcell commented Oct 29, 2017

P.S. I personally feel that the best solution is to embrace elm-format... :-)

@buhman
Copy link
Author

buhman commented Oct 29, 2017

If you want to disable [bounce indenting] … you can
(add-hook 'elm-mode-hook 'turn-off-elm-indent)

It seems like this has the opposite effect, elm-indent doesn't seem to be bounce-indenting, while turning it off does bounce-indent:

https://ptpb.pw/Cckz.gif
https://ptpb.pw/Lecz.gif

@purcell
Copy link
Collaborator

purcell commented Oct 29, 2017

I've made this more straightforward in the latest code, which should build into a MELPA package automatically in the next few hours: specifically, all you'll need to do will be (remove-hook 'elm-mode-hook 'elm-indent-mode).

@purcell
Copy link
Collaborator

purcell commented Oct 29, 2017

The "bounce indentation" you're seeing without elm-indent-mode is your Emacs-wide default behaviour of trying to align indentation with previous indentations. In the latter screen capture, with elm-indent-mode, it looks like it's positioning the [ relative to where it thinks the [ ] should be, not where it is.

@buhman
Copy link
Author

buhman commented Oct 29, 2017

all you'll need to do will be (remove-hook 'elm-mode-hook 'elm-indent-mode)

I do like the cycling though, is it not possible to make it match elm-format behavior, or at least snap to a multiple of 4 spaces?

@purcell
Copy link
Collaborator

purcell commented Oct 29, 2017

If you want multiples of 4 spaces, there'll be a default Emacs indentation function for that. Re. exactly matching elm-format, I doubt that will happen, since the indentation system is already quite complex. If the elm-format style is the right one for you, elm-format-on-save is the way to go IMO: indent with tab until syntactically valid, then save. That's my personal strategy. :-)

@ranjanified
Copy link

I've made this more straightforward in the latest code, which should build into a MELPA package automatically in the next few hours: specifically, all you'll need to do will be (remove-hook 'elm-mode-hook 'elm-indent-mode).

For me, I took this approach. At least with this, the new line isn't adding a "tab" of its own.

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

No branches or pull requests

3 participants