[ESS] fighting indentation in SAS mode

Ross Boylan ross at biostat.ucsf.edu
Wed Nov 6 23:47:31 CET 2013

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;
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 */".

> 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'.

More information about the ESS-help mailing list