我一直在使用emacs 23(python.el)一個多月,我對默認的自動縮進設置感到不滿。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')
看起來,我想如何執行自動縮進的邏輯是:
如果上一行的最後一個字符(非註釋/空白)爲a,則增加t他縮進1級。 否則,使用相同的縮進級別。
但是使用該邏輯,TAB
需要實際增加當前行的縮進級別。 (目前,TAB
只能將行移動到自動縮進級別)
有誰知道我如何修改emacs自動縮進以實現我想要的樣式?
不幸的是,這並不像我所描述的那樣工作。自動縮進之後,不斷按下「TAB」會使該線滾動通過負值(朝向邊距)縮進級別。此外,如果我手動操作縮進級別,後續行不會保持在同一級別。好消息是我可以查看python.el源代碼,看看我能否弄清楚事情是如何工作的,並且可能會自己弄清楚如何修改它。 – brildum 2011-02-24 15:01:36