emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
623 stars 162 forks source link

How to make ess style consistent with lintr config? #1261

Open aramirezreyes opened 1 year ago

aramirezreyes commented 1 year ago

HI! this is about the ESS with the R language.

Since ESS supports linting with lintr/flymake out of the box, it would be nice to have them agree on some criteria. This may be difficult to do automatically since lintr can be used out of the emacs/ESS context and thus they do not share configurations.

So I have in ~/.lintr

linters: linters_with_defaults(
    indentation_linter(indent = 2L),
  )
encoding: "UTF-8"

and in .emacs

(setq ess-style 'RStudio-)

With this configuration I get some discrepancies, especially in the indentations. For example, this code is indented by Emacs/ESS as:

log_model(sink_file, ordered, very, long, list, of, arguments
  variance, mean)

But it is flagged by the linter as:

[indentation_linter] Hanging indent should be 15 spaces but is 2 spaces.

So, maybe the Rstudio- and the default lintr (which I think follows the tidy verse style guide) are not fully equivalent, and that is completely okay. Then seems like I need to manually tweak my ESS style. In the general case where one has modified the style of either ESS or linter, how can we make them consistent?

Is there a systematic way of translating versus .lintr configuration and ESS variables? Maybe a dictionary? Is there an automated way?

Thank you.