[ESS] Indentation like the R parser: 5th level and more + ignoring call continuation

Mathieu Basille basille.web at ase-research.org
Mon Jan 23 02:26:57 CET 2017


Dear ESS-ers,

I am trying to implement an indentation style that would mimic what the R
parser would do (I know the R parser completely reformat the code, but I'm
really focusing on indentation at the moment). For that, I have pretty much
reconfigured all ESS variables regarding indentation:

  (custom-set-variables
   '(ess-own-style-list
     (quote
      ((ess-indent-offset . 4)
       (ess-offset-arguments . prev-line)
       (ess-offset-arguments-newline . prev-line)
       (ess-offset-block . prev-line)
       (ess-offset-continued . straight)
       (ess-align-nested-calls)
       (ess-align-arguments-in-calls)
       (ess-align-continuations-in-calls)
       (ess-align-blocks control-flow)
       (ess-indent-from-lhs)
       (ess-indent-from-chain-start)
       (ess-indent-with-fancy-comments . t)))))

I think this gives me almost exactly what I want, except for two cases:

1) Indentation  after the 5th level

Consider the following (silly) function:

function() {
    {
        {
            {
                {
                    {
                        {
                            bla
                        }
                    }
                }
            }
        }
    }
}

After the 5th level, the R parser indents with 2 characters only :

function() {
    {
        {
            {
                {
                  {
                    {
                      bla
                    }
                  }
                }
            }
        }
    }
}

I don't think it can presently be handled by ESS… Is this something that
could be considered in the future?

2) Continuation in calls

Setting the variable 'ess-align-continuations-in-calls' to nil, I get:

1234567890 + (1234567890 + 1234567890 + 1234567890 + 1234567890 +
                  1234567890)

instead of:

1234567890 + (1234567890 + 1234567890 + 1234567890 + 1234567890 +
              1234567890)

as documented. However, what I really want to have is:

1234567890 + (1234567890 + 1234567890 + 1234567890 + 1234567890 +
    1234567890)

like the R parser would render, that is ignoring the call continuation
altogether. I tried setting to prev-line like for the other variables, but
it seems that this variable only accepts nil or t (which is any non-nil
value). How can I have it to ignore call continuation?

==========  Side not on custom styles ============

I can see in the documentation that I should really define a new style, but
I cannot figure out how to do it based on the explanations.

==================================================

Any help on this would be greatly appreciated!
Mathieu.


-- 

Mathieu Basille

basille at ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

This message is signed to guarantee its authenticity.
For a true private correspondence, use my public key
to encrypt your messages:

  http://mathieu.basille.net/pub.asc

Learn more: http://mzl.la/1BsOGiZ



More information about the ESS-help mailing list