我使用 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')
我更希望能够设置自动缩进设置,以便可以轻松地格式化相同的代码:
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')
看来我希望自动缩进执行的逻辑是:
如果前一行的最后一个字符(非注释/空格)是 :,则将缩进级别增加 1。
否则,使用相同的缩进级别。
但按照这个逻辑,TAB
实际上需要增加当前行的缩进级别。 (现在,TAB
仅将行移至自动缩进级别)
有谁知道如何修改 emacs 自动缩进以实现我想要的样式?