Emacs ESS Mode TAB stops indenting

旧街凉风 提交于 2019-12-07 10:14:12

问题


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?


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/12903270/emacs-ess-mode-tab-stops-indenting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!