[ESS] ess-comment-indent

Joel J. Adamson jadamson at PARTNERS.ORG
Thu Apr 5 15:32:51 CEST 2007


Senor Kasper,

Thanks for the tip.  What happens in R mode is that (you are correct)
I was using single #-marks for comments.

Stata has three comment styles: one is like C 

/* everything in here is a comment; is use this most often */

another is for continuing lines

logit ilike Rbetter, /// comment over here; command continues
  use Emacs for a happy life  

Another which I rarely use since there's no way to automatically
invoke it is to put an asterisk at the beginning of the line

* this is a comment

The meddlesome indentation happens with both of the first two styles.

I will look at the documentation, however, can someone explain why
this happens?  It does not continue the indentation level after a
comment for me as Kasper explained: it either sets the comment over
the to the left side (comment-column), which is nice, or it indents
the next line.  In other words, If I'm writing an indented set of
text, then I put in a comment _on its own line_, the next line will be
indented two columns, not to the distance that the previous text was
indented.

Joel

Kasper Daniel Hansen writes:
 > 
 > On Apr 4, 2007, at 1:01 PM, Joel J. Adamson wrote:
 > 
 > > Dear List,
 > >
 > > I'm using XEmacs 21.4.19 (Constant Variable) on Slackware Linux 11.0.
 > > I work most of the time in Stata and sometimes in R.  When I'm writing
 > > out a .do-file (a Stata script), if I put a comment on its own line,
 > > the next line will automatically be indented 2 columns.  I don't want
 > > that to happen.  I'm sure this is ESS code making this happen, since
 > > it also happens in R mode.
 > 
 > This does not happen for me in R mode. This could be a combination  
 > between ESS and other stuff (auto-indentation). I don't know how  
 > Stata does commenst, but in R mode there is a difference between #,  
 > ## and ###
 > 
 > #: comment to the left of the file
 > ##: comment at this level
 > ###: comment to the left, like in
 > 
 > ### Comment 1,
 > tmp = function(){
 >      ## comment 2 - at current indentation level
 >      plot(x)
 >                                     # comment 3, to the "right"
 > ### back to no indentation, even though we are in a function
 >      return(TRUE)
 > }
 > 
 > Try the example above.
 > 
 > I am guessing that you are using a single comment char in R together  
 > with something that does auto-indentation. And it _might_ be a  
 > similar issue for Stata, although I have no idea how the comments  
 > work there.
 > 
 > I guess you should read the ESS manual for how comments are handled.  
 > I remember some stuff being there, but not what it said :)
 > 
 > Kasper
 > 
 > > I've looked through ess-mode.el and found a number of functions.  I
 > > would presume the best way to rectify this would be to put a
 > > replacement function in my init.el:
 > >
 > > (defun misbehaving-function ()
 > >   ())
 > >
 > > or whatever you would suggest.  The biggest complication is that I
 > > don't want to eradicate the desirable behavior.  If there's a variable
 > > I can set (ess-comment-indent-...), instead of replacing the function,
 > > please let me know.  That would be the simplest solution.
 > >
 > > Thanks,
 > > Joel
 > > --  
 > > Joel J. Adamson
 > > Biostatistician
 > > Pediatric Psychopharmacology Research Unit
 > > Massachusetts General Hospital
 > > Boston, MA  02114
 > > (617) 643-1432
 > > (303) 880-3109
 > >
 > >
 > >
 > >
 > >
 > > The information transmitted in this electronic communication is  
 > > intended only for the person or entity to whom it is addressed and  
 > > may contain confidential and/or privileged material. Any review,  
 > > retransmission, dissemination or other use of or taking of any  
 > > action in reliance upon this information by persons or entities  
 > > other than the intended recipient is prohibited. If you received  
 > > this information in error, please contact the Compliance HelpLine  
 > > at 800-856-1983 and properly dispose of this information.
 > >
 > > ______________________________________________
 > > ESS-help at stat.math.ethz.ch mailing list
 > > https://stat.ethz.ch/mailman/listinfo/ess-help
 > 

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109





The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information.




More information about the ESS-help mailing list