R-emacs / r-mode

Major mode for editing R code
2 stars 1 forks source link

Default indentation style #6

Open vspinu opened 8 years ago

vspinu commented 8 years ago

@lionel, I have kept only RRR+, Rstudio and Rstudio- styles and made the DEFAULT the real default. Do you have an opinion on this?

As to the default style, I am now favoring indent-ofset of 2 as the default. Not being able to work properly with R-studio code is annoying. I am also thinking of deactivating fancy comments as a default. At least not to indent # to collumn 40 when they are at bol.

With respect to other parameters I am not that decided. On one hand I am convinced of the visual appeal of argument alignment in RRR style and would like to keep as close to RRR as possible for ESS' sake. On the other hand being fully compatible with R-studio projects is kinda a big deal.

vspinu commented 8 years ago

I also would like to change +- to > and < to indicate the shift direction. I think +,- are not suggestive enough.

lionel- commented 8 years ago

I have kept only RRR+, Rstudio and Rstudio- styles and made the DEFAULT the real default. Do you have an opinion on this?

That's a good idea to cleanup all those old styles away. I think I'd prefer the default style to be called ESS.

As to the default style, I am now favoring indent-ofset of 2 as the default. Not being able to work properly with R-studio code is annoying.

I agree. 2 is the convention in R world.

I am also thinking of deactivating fancy comments as a default. At least not to indent # to collumn 40 when they are at bol.

Would this mean that only comments not at bol would be indented at 40? That's an awesome idea.

I also would like to change +- to > and < to indicate the shift direction. I think +,- are not suggestive enough.

I think + and - are better as RRR> looks a bit like a prompt. No strong opinion on this though.

On the other hand being fully compatible with R-studio projects is kinda a big deal.

It's a really big deal to me. I don't use (and don't like) ESS aligned style.

vspinu commented 8 years ago

default style to be called ESS.

The default is DEFAULT because it picks from global states. ESS might not even exist in several years from now.

Would this mean that only comments not at bol would be indented at 40? That's an awesome idea.

It will mess up indented comments though. So, I think it's either all or nothing. I also see that fancy comments are not used besides lisp modes.

It's a really big deal to me. I don't use (and don't like) ESS aligned style.

Well, this is very much habit dependent. If I look at Rstudo-.R and RRR.R, style side by side, the latter is way more aired and readable (mostly because of the argument alignment and 4 space indentation).

lionel- commented 8 years ago

The default is DEFAULT because it picks from global states.

Ok. Shouldn't the default be nil then? And not hardcoded in r-style-alist, so that users can actually change settings. We also need to make sure local variables have precedence over style when it is set.

Well, this is very much habit dependent.

I agree, that's why it's good to have flexibility. We put a lot of thought into this UI, I think we can leave it as is (of course we can improve on it).

vspinu commented 8 years ago

Shouldn't the default be nil then?

Yes. Good idea.

hardcoded in r-style-alist,

It should not be hardcoded either way. That is, the style should be initialized at the run time of r-mode. If that's not happening it should be fixed.

At least now you can set the style as file local or dir local variable, something which is not possible with ESS.

vspinu commented 8 years ago

It should not be hardcoded either way.

Done. The principle is now different than in ESS, r-indent-style-alist contains unevaluated expressions which are set to corresponding values during r-mode initialization. This way any change in global values will immediately affect indentation in new buffers.

lionel- commented 8 years ago

Now that I think of it, the buffer local variables are applied after mode initialisation, so they will get precedence (if I'm not mistaken), which is great. Glad to have user settings finally getting sorted out!