emacs 23 python.el自动缩进样式 - 可以配置吗?

bri*_*dum 13 python emacs coding-style indentation

我已经使用emacs 23(python.el)一个多月了,我对默认的自动缩进设置不满意.

目前,我的Python文件是自动缩进的,如下所示:

x = a_function_with_dict_parameter({
                                   'test' : 'Here is a value',
                                   'second' : 'Another value',
                                   })
a_function_with_multiline_parameters(on='First', line='Line',
                                     now_on='Second', next_line='Line',
                                     next='Third', finally='Line')
Run Code Online (Sandbox Code Playgroud)

我更喜欢如果我可以设置自动缩进设置,以便可以轻松格式化相同的代码:

x = a_function_with_dict_parameter({
    'test' : 'Here is a value',
    'second' : 'Another value',
})
a_function_with_multiline_parameters(on='First', line='Line',
    now_on='Second', next_line='Line', next='Third', finally='Line')
Run Code Online (Sandbox Code Playgroud)

似乎我喜欢自动缩进的逻辑是:

如果前一行的最后一个字符(非注释/空白)是:,则将缩进级别增加1.否则,使用相同的缩进级别.

但是使用该逻辑,TAB需要实际增加当前行的缩进级别.(目前,TAB只将行移动到自动缩进级别)

有谁知道如何修改emacs auto-indentation来实现我想要的风格?

Alv*_*ivi 1

尝试使用最后一个 fgallina 的python.el版本。它包含许多其他改进

我使用这个版本并且TAB具有您想要的行为,但我对 python.el 进行了一些修改,所以我不能确定您会得到相同的行为。如果是这样,请告诉我。