[ESS] fighting indentation in SAS mode

Ross Boylan ross at biostat.ucsf.edu
Fri Nov 8 22:26:36 CET 2013


On Fri, Nov 08, 2013 at 03:12:26PM -0600, Darin England wrote:
> I have the same indentation problem as Ross when using ess[SAS] mode. A fix
> to the problem that Ross described would be greatly appreciated. I'm
> willing to look into it myself, it just may take me some time to get
> familiar with how to diagnose the lisp code and suggest a patch.
> 
> Ross, I don't see any attached file. I'm not sure that attachments are
> allowed on this email list ???
> 
> Darin
> 

They must be stripped out--or perhaps it happened along the way.

Now that I know C-tab reverses the indentation permanently I might prefer
ESS SAS mode to text mode!  But it would certainly be nice if it were better.

Here's the sample code inline, with an even lower probability of
preserving original tabs vs spaces:

/* Illustrates some problems with indentation in ESS SAS mode */
data foo;
    set bar;
/* to get back to the left margin requires hitting backspace repeatedly.
However C-Tab does it in one step. */
data foo;
    set bar;
/* now I will try hitting tab after typing set bar.  In some
    other emacs modes that will cause proper indentation to the left.
    I have no idea why this line and the previous one do not start
    on the left edge.  I am hitting enter to break the lines.
    */
    data foo;  * note this is indented too;
    set bar;    * I hit the tab key after the semicolon;
                
                data foo; * hitting enter takes me to the furthest right tab I used;
                    set bar;
                
                data foo;
                    set bar;
                    /* Here is a comment
                        with            X a tab all the way to X
                                        */
                                        * and here is where subsequent lines start;
                                        data foo;
                                            set bar;
                                        data foo;
                                            set bar;
* I hit C-tab to get back to left margin;
data foo;
    set bar;
    * which seems to have undone things;
    /*Now I will                X tab to here
                                and correct by hitting backspace after this comment ends
                                and I hit enter. */
data foo;
                                set bar;
                                * so C-tab resets the margin but backspacing does not;
                                

Ross
> 
> On Wed, Nov 6, 2013 at 4:47 PM, Ross Boylan <ross at biostat.ucsf.edu> wrote:
> 
> > On Wed, 2013-11-06 at 16:14 -0600, Rodney Sparapani wrote:
> > > On 11/06/2013 03:17 PM, Ross Boylan wrote:
> > > > Third, deleting at a tab stop always takes you back one space, not one
> > > > tab stop.
> > >
> > > C-TAB takes you to the tab stop to the left...
> > Thanks for the  tip; that works.  Also, it resets the margin, which
> > backspace does not.
> >
> > I've attached a file illustrating some of the issues, as Vitalie
> > requested.  However, the file probably has all the tabs converted to
> > spaces, and so may act differently than what I see.  Also, as noted, the
> > behavior depends on the order in which keys are hit (the reset margin
> > affects code entered later, even if it's entered above where the tab
> > occurs).  However, there is narrative.
> >
> > But the basic problem seems to be that once you hit tab it resets the
> > left margin to be at that tab stop.  This makes sense if you are within
> > a procedure or proc, e.g., in
> > data foo;
> >    set bar;
> >    x=3;
> >    output;
> > one wants x=3 and output to be indented.
> >
> > But backspacing should reset it and tabs within comments should have no
> > effect, at least outside the comments.
> >
> > For non-SAS types, there are 3 styles of SAS comments:
> > /* C-style comments of one or more lines */
> >
> > * SAS comments that start with * and end with a semi-colon.  May be
> > multiple lines.;
> >
> > %* I am a macro comment.  Like a SAS comment except with an extra % at
> > the start.;
> >
> > C-style comments can be interpolated basically anywhere (not in the
> > middle of words or data) while the other 2 styles can appear wherever a
> > statement can appear.  If something is in quotes it's a string, even if
> > it "/* looks like a comment */".
> >
> > Ross
> > >
> > > ess-sas-edit-keys-toggle is a variable defined in `ess-sas-a.el'.
> > > Its value is t
> > >
> > > Documentation:
> > > Toggle TAB/RET key in `SAS-mode'.
> > > nil binds TAB to `sas-indent-line' and RET to `newline-and-indent'.
> > > Non-nil binds TAB to `ess-sas-tab-to-tab-stop',
> > > C-TAB to `ess-sas-backward-delete-tab', and RET to `newline'.
> > >
> >
> >
> > ______________________________________________
> > ESS-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
> >
> >
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list