我一直在使用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 auto-indentation以实现我想要的风格?
3 回答
你可以尝试这种代码安静:
现在,这是一个简单的python dict:
成为...
试试最后一个fgallina的python.el版本 . 它包含许多其他improvements .
我使用这个版本,
TAB
有你想要的行为,但我对python.el做了几处修改,所以我可以't be sure that you' ll得到相同的行为 . 如果是这样,请告诉我 .M-x customize-group RET python RET