如何在Emacs中打开括号后控制缩进

lac*_*ker 19 javascript emacs indentation actionscript-3 python-mode

当我使用emacs python-mode时,如果一行的最后一个字符是一个左括号,它只是从前一行的缩进中缩进下一行.

call_some_function(
    some_very_long_argument_that_I_want_to_put_on_its_own_line)
Run Code Online (Sandbox Code Playgroud)

我喜欢.现在在ecmascript模式(我用于动作脚本3),它总是缩进到前一个括号的级别.

call_some_function(
                   this_is_not_really_saving_me_any_horizontal_space);
Run Code Online (Sandbox Code Playgroud)

在这方面我怎么能像ecthon-mode那样制作ecmascript-mode缩进?

Tör*_*bor 20

由于ecmascript模式基于cc模式,因此您可以使用c-set-offset它来允许您使用首选值自定义任何语法符号的偏移量.

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

您也可以在dotemacs中以编程方式执行此操作,例如:

(add-hook 'ecmascript-mode-hook
          (lambda ()
            (c-set-offset 'arglist-intro '+)
            (c-set-offset 'arglist-close 0)))
Run Code Online (Sandbox Code Playgroud)