[ESS] how to make close-parens indent identically to close-brace?
Murat Tasan
mmuurr at gmail.com
Tue Dec 9 01:05:23 CET 2014
Ah, yeah, I hadn't thought of auto-insertion of closing braces (as I
always keep such auto-insertions off).
The common style (closing all parens at end of expression) works fine
until one finds themselves n functions deep in nesting (where n is,
say, > 3).
Adding optional arguments during development then becomes a serious chore.
This is particularly noticeable when using some R paradigms/frameworks
like Shiny, where nearly all presentation-control functions take
nothing but ... arguments, and where each argument itself is usually a
function that takes more ... arguments.
Is the code behind ess-dont-vertically-align-closing-paren on a
development branch of ESS?
I'd love to give it a try :-)
Cheers,
-murat
On Mon, Dec 8, 2014 at 4:50 PM, Vitalie Spinu <spinuvit at gmail.com> wrote:
>
> 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