Re: [ESS] Ever consider changing indentation on #?

2017-05-06 Thread Stephen Eglen
since we are throwing ideas out there...  perhaps what the R universe
could do with is something similar to "gofmt" for the go language.  All
Go code looks the same, because there is a formatting tool, and everyone
uses it.  How about something similar for R...?!?


Stephen

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] Ever consider changing indentation on #?

2017-05-06 Thread Tyler Smith
Richard M. Heiberger writes:

> When people send me code with consistent use of #, I can't read it
> because all the comments fly off to the right and are nowhere near
> what they are talking about.

Does ESS do this automatically, or do you need to explicitly ask it to
reindent the code for this to happen?

Most code I receive is very poorly and inconsistently formatted to begin
with, so applying any conventions usually makes it better, or at least
easier to tweak into a sensible structure.

> On Thu, May 4, 2017 at 10:49 PM, Paul Johnson  wrote:
>> Please raise your hand if you have EVER used # to document R code in
>> the way mentioned on the LISP coding standards page.

I learned R and ESS concurrently starting ca. 2004, so this convention
is normal for me. I find it handy to be able to append short noted with
#, and the distinction between ## and ### is intuitively useful.

Once code gets complex enough to warrant sectioning and folding, I
usually switch to Rmd and wrap it in markdown code blocks. Or org-mode,
if I'm going to be mixing multiple code languages.

 On Thu, May 4, 2017 at 10:25 AM, Lionel Henry  wrote:
>
> Emacs is for people willing to put the effort into customisation.
> Your students are probably better off with RStudio. That said I
> agree that good defaults are important.

Yes, RStudio has been a boon for teaching. I can demonstrate on Linux
without my students on Mac or Windows noticing the difference, and the
interface is intuitive enough as to not add to the cognitive load of
learning R.

That said, it's kind of entertaining to watch the development of
RStudio: every few months there's another whiz-bang feature added on to
great fanfare, that reproduces, partially, something we've had in ESS
for years. Brings to mind the old quote about reimplmenting Lisp.

It's really too bad that markdown didn't happen before org-mode came
into it's own. If org-mode had built off the markdown syntax, the
potential for cross-pollination between Emacs/Org/ESS and
RStudio/Rmarkdown would have been much stronger. At this point it looks
like RMarkdown will slowly accumulate a subset of org-mode features.

Best,

Tyler

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] Ever consider changing indentation on #?

2017-05-06 Thread Kasper Daniel Hansen
I agree the default is worthwhile changing, especially Paul's nice
suggestion of letting
  # be flush left
 ## indentation level
which would not affect my memory typing (since I never use `#`) and solve
irritating indentation issues when I work with other peoples code.

Best,
Kasper

On Sat, May 6, 2017 at 6:30 AM, Lionel Henry  wrote:

> I don't use it either (though I tried at some point).
> Any objection to change the default Martin?
>
> Lionel
>
>
> > On 6 mai 2017, at 11:44, Vitalie Spinu  wrote:
> >
> >
> > I would add here that other modes in emacs except lisp don't usually
> respect
> > this convention.
> >
> >  Vitalie
> >
> >>> On Fri, May 05 2017 23:52, Steven McKinney wrote:
> >
> >> As an old lisp programmer I use # and ## and ### in all my code.
> >
> >> ### 
> >> ### for code block and function headers
> >> ### (this was actually functional in
> >> ###  SPLUS for auto-generating help)
> >> ### 
> >
> >>## for inline comments in code, and   # brief margin notes
> >
> >> I find it useful, but all things change over time.
> >
> >> Steven McKinney
> >
> >>> -Original Message-
> >>> From: ESS-help [mailto:ess-help-boun...@r-project.org] On Behalf Of
> Paul
> >>> Johnson
> >>> Sent: May-04-17 7:50 PM
> >>> To: ess-help
> >>> Subject: Re: [ESS] Ever consider changing indentation on #?
> >>>
> >>> Please raise your hand if you have EVER used # to document R code in
> >>> the way mentioned on the LISP coding standards page.
> >>>
> >>> pj
> >>>
> >>> On Thu, May 4, 2017 at 10:52 AM, Brahm, David
> >>>  wrote:
>  Since we're on the topic, is there a style to make the # comments
> right-
> >>> justified against
>  "fill-column" (which is 97 for me, as that makes printouts look good)
> >>> and/or the window
>  width?  So as you type the comment, it marches leftward.  E.g.:
> 
>  x <- y + z   #
> This
> >>> comment ends on column 97
> 
> >>> 123456789012345678901234567890123456789012345678901234567890
> 123456789012345
> >>> 6789012345678901234567
> 
>  -- David Brahm (br...@alum.mit.edu)
> 
> 
>  -Original Message-
>  From: ESS-help [mailto:ess-help-boun...@r-project.org] On Behalf Of
> >>> Charles C. Berry
>  Sent: Thursday, May 04, 2017 11:38 AM
>  To: Ista Zahn
>  Cc: Stephen Eglen; ess-help
>  Subject: Re: [ESS] Ever consider changing indentation on #?
> 
>  On Thu, 4 May 2017, Ista Zahn wrote:
> 
> > On Thu, May 4, 2017 at 10:25 AM, Lionel Henry 
> >>> wrote:
> >>
> >>> On 4 mai 2017, at 16:22, Paul Johnson 
> wrote:
> >>>
> >>> I understand I can fix my init.el go avoid this, but it would be
> nicer
> >>> for my purpose
> >>> if this were in ESS itself, because I keep telling students to use
> it
> >>> and they are put off/discouraged
> >>> by this.
> >>
> >> Emacs is for people willing to put the effort into customisation.
> >> Your students are probably better off with RStudio. That said
> >> I agree that good defaults are important.
> >
> 
>  And there are a bunch of styles from which to choose a personal
> default.
>  See below.
> 
> > Yes, IMO Emacs/ESS isn't going to compete with Rstudio on
> > out-of-the-box convenience. But we can compete on features! Put this
> > in your config file
> >
> > (add-hook 'ess-mode-hook
> > (lambda()
> >   ;; don't indent comments
> >   (setq ess-indent-with-fancy-comments nil)
> >   ;; turn on outline mode
> >   (setq-local outline-regexp "[# ]+")
> >   (outline-minor-mode t)))
> >
> > and not only will single # comments not be aligned at comment-column,
> > but code folder will work too!
> >
> >
> 
>  There are `off-the-shelf' styles like `Rstudio' that might satisfy
> Paul's
>  student.
> 
>  Setting `ess-default-style' to `Rstudio' gives these settings:
> 
>   (RStudio
>    (ess-indent-offset . 2)
>    (ess-offset-arguments . open-delim)
>    (ess-offset-arguments-newline . prev-line)
>    (ess-offset-block . prev-line)
>    (ess-offset-continued . straight)
>    (ess-align-nested-calls)
>    (ess-align-arguments-in-calls "function[ ]*(")
>    (ess-align-continuations-in-calls)
>    (ess-align-blocks)
>    (ess-indent-from-lhs arguments)
>    (ess-indent-from-chain-start . t)
>    (ess-indent-with-fancy-comments))
> 
> 
>  Or one can customize the `OWN' style and select it. See the
>  `ess-style-alist' docstring for more details.
> 
>  HTH,
> 
>  Chuck
> 
>  __
>  

Re: [ESS] Ever consider changing indentation on #?

2017-05-06 Thread Vitalie Spinu

I would add here that other modes in emacs except lisp don't usually respect
this convention.

  Vitalie

>> On Fri, May 05 2017 23:52, Steven McKinney wrote:

> As an old lisp programmer I use # and ## and ### in all my code.

> ### 
> ### for code block and function headers
> ### (this was actually functional in 
> ###  SPLUS for auto-generating help)
> ### 

> ## for inline comments in code, and   # brief margin notes

> I find it useful, but all things change over time.

> Steven McKinney

>> -Original Message-
>> From: ESS-help [mailto:ess-help-boun...@r-project.org] On Behalf Of Paul
>> Johnson
>> Sent: May-04-17 7:50 PM
>> To: ess-help
>> Subject: Re: [ESS] Ever consider changing indentation on #?
>> 
>> Please raise your hand if you have EVER used # to document R code in
>> the way mentioned on the LISP coding standards page.
>> 
>> pj
>> 
>> On Thu, May 4, 2017 at 10:52 AM, Brahm, David
>>  wrote:
>> > Since we're on the topic, is there a style to make the # comments right-
>> justified against
>> > "fill-column" (which is 97 for me, as that makes printouts look good)
>> and/or the window
>> > width?  So as you type the comment, it marches leftward.  E.g.:
>> >
>> > x <- y + z   # This
>> comment ends on column 97
>> >
>> 123456789012345678901234567890123456789012345678901234567890123456789012345
>> 6789012345678901234567
>> >
>> > -- David Brahm (br...@alum.mit.edu)
>> >
>> >
>> > -Original Message-
>> > From: ESS-help [mailto:ess-help-boun...@r-project.org] On Behalf Of
>> Charles C. Berry
>> > Sent: Thursday, May 04, 2017 11:38 AM
>> > To: Ista Zahn
>> > Cc: Stephen Eglen; ess-help
>> > Subject: Re: [ESS] Ever consider changing indentation on #?
>> >
>> > On Thu, 4 May 2017, Ista Zahn wrote:
>> >
>> >> On Thu, May 4, 2017 at 10:25 AM, Lionel Henry 
>> wrote:
>> >>>
>>  On 4 mai 2017, at 16:22, Paul Johnson  wrote:
>> 
>>  I understand I can fix my init.el go avoid this, but it would be nicer
>>  for my purpose
>>  if this were in ESS itself, because I keep telling students to use it
>>  and they are put off/discouraged
>>  by this.
>> >>>
>> >>> Emacs is for people willing to put the effort into customisation.
>> >>> Your students are probably better off with RStudio. That said
>> >>> I agree that good defaults are important.
>> >>
>> >
>> > And there are a bunch of styles from which to choose a personal default.
>> > See below.
>> >
>> >> Yes, IMO Emacs/ESS isn't going to compete with Rstudio on
>> >> out-of-the-box convenience. But we can compete on features! Put this
>> >> in your config file
>> >>
>> >> (add-hook 'ess-mode-hook
>> >>  (lambda()
>> >>;; don't indent comments
>> >>(setq ess-indent-with-fancy-comments nil)
>> >>;; turn on outline mode
>> >>(setq-local outline-regexp "[# ]+")
>> >>(outline-minor-mode t)))
>> >>
>> >> and not only will single # comments not be aligned at comment-column,
>> >> but code folder will work too!
>> >>
>> >>
>> >
>> > There are `off-the-shelf' styles like `Rstudio' that might satisfy Paul's
>> > student.
>> >
>> > Setting `ess-default-style' to `Rstudio' gives these settings:
>> >
>> >   (RStudio
>> >(ess-indent-offset . 2)
>> >(ess-offset-arguments . open-delim)
>> >(ess-offset-arguments-newline . prev-line)
>> >(ess-offset-block . prev-line)
>> >(ess-offset-continued . straight)
>> >(ess-align-nested-calls)
>> >(ess-align-arguments-in-calls "function[ ]*(")
>> >(ess-align-continuations-in-calls)
>> >(ess-align-blocks)
>> >(ess-indent-from-lhs arguments)
>> >(ess-indent-from-chain-start . t)
>> >(ess-indent-with-fancy-comments))
>> >
>> >
>> > Or one can customize the `OWN' style and select it. See the
>> > `ess-style-alist' docstring for more details.
>> >
>> > HTH,
>> >
>> > Chuck
>> >
>> > __
>> > ESS-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/ess-help> >
>> > __
>> > ESS-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/ess-help> 
>> 
>> 
>> --
>> Paul E. Johnson   http://pj.freefaculty.org> Director, Center for Research 
>> Methods and Data Analysis http://crmda.ku.edu> 
>> To write to me directly, please address me at pauljohn at ku.edu.
>> 
>> __
>> ESS-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help

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

__
ESS-help@r-project.org mailing list