修复 ESS/Stata 中不良的 EMACS 选项卡行为
emacs 中的 ESS/Stata 模式错误地缩进以运算符结尾的行。它似乎错误地将这些行解释为多行命令。
例如:
gen foo = 1
/* generate another variable */
gen bar = 1
“gen bar = 1”行不应缩进。看起来 EMACS 将注释中的尾部斜杠解释为运算符,并认为这行代码跨越两行。
事实上,stata 中的多行命令有 3 个尾部斜杠,没有 3 个尾部斜杠的换行符表示语句的结束。例如,以下缩进是正确的:
gen bar = 1
gen ///
foo = 1
我可以在 .emacs 中放入一些内容来纠正此行为吗?我不想完全放弃自动制表符 - 它对所有内容都非常有效,除了 /* 看起来像这样 */ 的注释。
谢谢,
Pnj
ESS/Stata mode in emacs incorrectly indents lines that follow lines ending in operators. It seems to incorrectly interpret these lines as multiline commands.
For example:
gen foo = 1
/* generate another variable */
gen bar = 1
The line "gen bar = 1" should not be indented. It looks like EMACS interprets the trailing slash in the comment as an operator, and thinks this line of code spans two lines.
In fact, multiline commands in stata have 3 trailing slashes, and newlines without 3 trailing slashes indicate the end of a statement. e.g. the following indentation would be correct:
gen bar = 1
gen ///
foo = 1
Is there something I can put in my .emacs to correct this behavior? I don't want to give up automatic tabbing completely - it works very well for everything except comments that /* look like this */.
Thanks,
Pnj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,ESS 将尾随的
/
解释为行继续的指示。这是硬编码到函数ess-continued-statement-p
中的,因此要修改行为,您必须重写代码。以下代码(在您的.emacs
中)适用于您的示例。You're right, ESS interprets the trailing
/
as an indication of line continuation. This is hard-coded into the functioness-continued-statement-p
, so to modify the behaviour you have to rewrite the code. The following code (in your.emacs
) works for your examples.