如何在Emacs中打开括号后控制缩进 [英] How to control indentation after an open parenthesis in Emacs

查看:196
本文介绍了如何在Emacs中打开括号后控制缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用emacs python-mode时,如果一行的最后一个字符是一个开放的括号,它会缩小下一行,只需从前一行缩进的一个步骤。

  call_some_function(
some_very_long_argument_that_I_want_to_put_on_its_own_line)

我喜欢。现在以ecmascript-mode(我用于actionscript 3),它总是缩进到上一个括号的水平。

  call_some_function(
this_is_not_really_saving_me_any_horizo​​ntal_space);

如何在这方面使ecmascript模式缩进像python-mode?

解决方案

由于 ecmascript-mode 基于cc-mode,您可以使用 c-set-offset ,允许您使用首选值自定义任何句法符号的偏移量。 / p>

在您的情况下,转到缩进级别的点,点击 Cc Co (或键入 Mx c-set-offset ),接受建议的符号( arglist-intro ),并将其设置为新值例如 + ,默认偏移量)。



您还可以在您的dotemac中以编程方式进行操作,例如, :

 (add-hook'ecmascript-mode-hook 
(lambda()
(c- set-offset'arglist-intro'+)
(c-set-offset'arglist-close 0))


When I use emacs python-mode, if the last character of a line is an open parenthesis it indents the next line just one step in from the indentation of the previous line.

call_some_function(
    some_very_long_argument_that_I_want_to_put_on_its_own_line)

I like that. Now in ecmascript-mode (which I am using for actionscript 3), it always indents to the level of the previous parenthesis.

call_some_function(
                   this_is_not_really_saving_me_any_horizontal_space);

How can I make ecmascript-mode indent like python-mode in this respect?

解决方案

Since ecmascript-mode is based on cc-mode, you can use c-set-offset which allows you to customize any syntactic symbol's offset with the preferred value.

In your case, go to the point which is indented in the wrong level, hit C-c C-o (or type M-x c-set-offset), accept the suggested symbol (arglist-intro), and set it a new value (e.g. +, the default offset).

You can also do it programmatically in your dotemacs, for instance, with:

(add-hook 'ecmascript-mode-hook
          (lambda ()
            (c-set-offset 'arglist-intro '+)
            (c-set-offset 'arglist-close 0)))

这篇关于如何在Emacs中打开括号后控制缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆