On Thu, May 4, 2017 at 3:51 AM, Stephen Eglen <sj...@cam.ac.uk> wrote: > > hi Paul, > >> "what the Hell, the folding is borked!". This is more and more common >> with the adoption of markdown-style commentary within R files. > > can you give an example of the markdown-style commentary? > >
Here is an R file that has "Rstudio sections" that begin with #. I just tested with their gui and the magic recipe for howto is written below. It is something like Emacs org mode, I suppose. Code folding. This is an example of a file that gets "destroyed" by Emacs/ESS indentation ## Paul Johnson ## 20170504 ## Open this file in Rstudio, you'll see what I mean # Here is a section from Code-> insert section ---------------------------- x <- rnorm(100) y <- rnorm(100) ## The effect of "Code -> Insert section" is to create a left aligned single #. ## Apparently, it follows with dots out to right edge. # Here is a second section from Code -> insert section -------------------- z <- function(a, b, c){ y <-3 y + 7 } ## After this, in editor Rstudio, then the sections can be folded (hidden) # Third section ---- ## How to create a section without using Rstudio menu? ## TO create this section, I did not use Rstudio menu. I insert ## 1. one # ## 2. a space ## 3. some words ## 4. Four dashes ## the # at begin and dashes at end is signal to R studio this is a section. 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. I'm not an Rstudio user, but try to cooperate with some of them :) pj >> Until now, I've said "too bad" when they complain about their code, >> but now I'm thinking we ought to consider changing the behavior of >> Emacs/ESS. Does it really really need to do # indentation that way? >> Why? I've always thought it is odd. And counterintuitive. In what >> backwards world would one suppose # gets the most indent, while ### >> gets none?. I don't see any benefit in that # indentation that way. I >> do see a big benefit in the ## indent at the code level. I'm only >> quibbling about #. > > just for background context, ESS follows the Emacs convention for > comments (### for column 0, ## for same level, # for col 32 or more), that is > used widely in elisp. It is probably fair to say though that these > conventions are not widely known outside of Emacs. > >> Would you ever consider changing the ESS default for R files so # is >> flush left? Could I offer you some cash to consider it? >> >> I understand I *could* learn code for my emacs.init to do that, but it >> seems like a change that would be broadly beneficial to new Emacs & >> ESS users. I preach the message about Emacs to the students here, but >> little quirks like this seem like an unnecessary hassle. > > Its likely to be fixable, but first it might be worth hearing Martin's > views on this, as he may deal with differing commenting styles a lot in > R-core. > > Stephen -- 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