Domanda

I'm using Emacs 24 on Windows to write some R code. Up until about 30 minutes ago, whenever I would write a new function, ESS would automatically indent the lines following the function declaration and pressing the tab key on a new blank line would jump me to the appropriately indented starting position inside the declaration.

EG:

foo <- function() {
    first line started here
    second line here.  .etc
}

Now, it is hard wrapping everything to the left, and not responding by automatically indenting after the function declaration or when I hit the tab key.

foo <- function() {
first line
second line
}

I've googled, but my google-fu is failing me on this. Anyone know how to restore default tab behavior to ESS in Emacs?

È stato utile?

Soluzione

Try to add a space after "#". I don't think ESS-mode handles # as a comment unless you have space after it.

Altri suggerimenti

just for the record. Whenever such things happens, select the whole buffer C-x h and press C-M-\ to indent the whole region. This will show unambiguously the syntax error.

I just came across the same problem you describe.

None of the above seemed to work, but I narrowed it down to using a carriage return and then an open parenthesis inside a string, like so:

### indent ( <tab> ) working fine up to here 
   s1 <- "string
(then this in brackets)"
### now indent does nothing!

The fact that it's balanced later doesn't help. I think EMACS reads this as opening a new expression/ block in spite of the fact that it occurs in a quoted string. This seems to apply also to expression openers { and [. It only seems to happen when the 'open expression' symbol appears at the start of the line...

In my case the string was part of a plot label, so the solution was to use \n instead.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top