【发布时间】:2019-05-15 02:38:34
【问题描述】:
对于 R 代码,我当前的 emacs ESS 样式是 C++,结果是
worst <- flights_sml %>%
group_by(year, month, day)
即延续在%>% 之后缩进4 个空格。我希望它是 2 个空格。
我该怎么做?
【问题讨论】:
标签: r emacs indentation ess
对于 R 代码,我当前的 emacs ESS 样式是 C++,结果是
worst <- flights_sml %>%
group_by(year, month, day)
即延续在%>% 之后缩进4 个空格。我希望它是 2 个空格。
我该怎么做?
【问题讨论】:
标签: r emacs indentation ess
你想要什么并不完全清楚。如果在连续语句中只需要 2 个空格,例如管道之后的那些,则以下应该可以工作
(setq ess-offset-continued '(straight 2))
因此,缩进仍将默认为 C++ 样式中设置的 4 个空格,例如。结果看起来像
worst <- flights_sml %>%
group_by(year, month, day)
f <- function(x) {
x
}
否则,如果您总是想要 2 个空间偏移量
(setq ess-indent-offset 2)
您可以在模式挂钩中自定义这些变量,例如。
(defun my-R-hook ()
(setq-local ess-style 'C++)
(setq-local ess-offset-continued '(straight 2)))
有关详细信息,请参阅ess-offset-continued 和 ess-style-alist 的文档。
【讨论】:
ess-style-alist,因为它回答了我所有关于缩进的问题。