[ESS] how to make close-parens indent identically to close-brace?

Vitalie Spinu spinuvit at gmail.com
Tue Dec 9 00:50:29 CET 2014


It could be added as there is now a separate treatment of closing paren
(ess-calculate-indent--closing-paren). But I would be a bit cautious of
that behavior. A widely accepted style is to leave closing parents at
eol after the last statement.

The biggest disadvantage of } is the interaction with the auto-insertion
of closing }.  Whenever you type RET before the closing brace, {|}, you
get indented at the beginning of line till you insert some ore text and
re-indent. There was even a complaint on this list some time ago.

As parenthesis are more common, I personally would be very annoyed by
being indented to wrong place each time I insert a new line after an
opening paren. 

  Vitalie


 >>> Kevin Ushey on Sun, 7 Dec 2014 20:40:15 -0800 wrote:

 > Doh. Sorry, I lied -- that option was something that I had worked on
 > locally but didn't make it into ESS proper. But I recall Vitalie took
 > this work and allowed for this control... hopefully he will have a
 > response.

 > Sorry,
 > Kevin

 > On Sun, Dec 7, 2014 at 8:24 PM, Kevin Ushey <kevinushey at gmail.com> wrote:
 >> Hi Murat,
 >> 
 >> There was a new option added for this recently -- see
 >> `ess-dont-vertically-align-closing-paren`. You can use `(setq
 >> ess-dont-vertically-align-closing-paren t)` to toggle it.
 >> 
 >> FWIW, I have this in my `.emacs` to configure the ESS indentation to
 >> my liking; it should give you a starting place to configure for your
 >> own preferences.
 >> 
 >> (setq ess-ac-R-argument-suffix " = ")
 >> (setq ess-use-auto-complete t)
 >> (add-hook 'ess-mode-hook
 >> (lambda ()
 >> (local-set-key (kbd "<s-return>") 'ess-eval-region-or-line-and-step)
 >> (show-paren-mode t)
 >> (setq ess-indent-level 2)
 >> (setq ess-first-continued-statement-offset 2)
 >> (setq ess-continued-statement-offset 0)
 >> (setq ess-arg-function-offset 2)
 >> (setq ess-arg-function-offset-new-line 2)
 >> (setq ess-dont-vertically-align-closing-paren t)
 >> ))
 >> (ess-toggle-underscore nil)
 >> 
 >> Cheers,
 >> Kevin
 >> 
 >> On Sun, Dec 7, 2014 at 6:53 PM, Murat Tasan <mmuurr at gmail.com> wrote:
 >>> Hi all ---
 >>> 
 >>> Does anyone know how to force ESS to treat closing parentheses like
 >>> closing braces when writing multi-line statements?
 >>> 
 >>> An example is:
 >>> 
 >>> ## existing default indentation
 >>> list(
 >>> a = 1:10,
 >>> b = 10:1,
 >>> )
 >>> 
 >>> But in such cases, where the open-parens is followed immediately by
 >>> whitespace/newline, I'd really like the indentation to be like braces.
 >>> I'd settle with just having the closing parens match up to the start
 >>> of the call, rather than the open-parens, though:
 >>> 
 >>> ## treating parens a bit more like braces
 >>> list(
 >>> a = 1:10,
 >>> b = 10:1,
 >>> )
 >>> 
 >>> Has anyone ever written such a modification for ESS?
 >>> (My Elisp is nowhere near sophisticated-enough to know how to specify
 >>> this type of rule myself :-/ )
 >>> 
 >>> Cheers,
 >>> 
 >>> -murat
 >>> 
 >>> ______________________________________________
 >>> ESS-help at r-project.org mailing list
 >>> https://stat.ethz.ch/mailman/listinfo/ess-help

 > ______________________________________________
 > ESS-help at r-project.org mailing list
 > https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list