[ESS] how to make close-parens indent identically to close-brace?
Murat Tasan
mmuurr at gmail.com
Wed Dec 10 20:58:54 CET 2014
Amaze!
Thanks!
-Murat
On Mon, Dec 8, 2014 at 7:02 PM, Vitalie Spinu <spinuvit at gmail.com> wrote:
>
> I have just added a new indentation control variable
> `ess-close-paren-offset`. This is the doc:
>
> "Extra indentation for closing parenthesis.
> When a number, adjustment is made with respect to the opening
> parenthesis taking into account the value of
> `ess-arg-function-offset-new-line'. With N = 0:
>
> some.function(arg1,
> arg2
> )
>
> When list of of form '(N), where N is a number,
> adjust with respect to the indentation of the line containing an
> opening parenthesis. With N = 0:
>
> {
> some.function(arg1,
> arg2 = X
> )
> }
>
> You would probably like to set it to '(0).
>
> Vitalie
>
> >>> Murat Tasan on Mon, 8 Dec 2014 17:05:23 -0700 wrote:
>
> > 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
>
> > ______________________________________________
> > ESS-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
More information about the ESS-help
mailing list